Added the forgotten dataRate to begin() default speed is 2MBPS

This commit is contained in:
Henrik Ekblad
2014-03-04 21:54:21 +01:00
parent a684a49501
commit b223879d12
7 changed files with 560 additions and 559 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ int inputPos = 0;
void setup() void setup()
{ {
// Initialize gateway at maximum PA level, channel 70 and callback for write operations // Initialize gateway at maximum PA level, channel 70 and callback for write operations
gw.begin(RF24_PA_MAX, 70, writeEthernet); gw.begin(RF24_PA_MAX, 70, RF24_2MBPS, writeEthernet);
Ethernet.begin(mac, myIp); Ethernet.begin(mac, myIp);
+2 -2
View File
@@ -27,7 +27,7 @@ Gateway::Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_
pinEr = _er; pinEr = _er;
} }
void Gateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, void (*inDataCallback)(char *)) { void Gateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate, void (*inDataCallback)(char *)) {
Serial.begin(BAUD_RATE); Serial.begin(BAUD_RATE);
if (inDataCallback != NULL) { if (inDataCallback != NULL) {
@@ -66,7 +66,7 @@ void Gateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, void (*inDataCallbac
} }
// Start up the radio library // Start up the radio library
setupRadio(paLevel, channel); setupRadio(paLevel, channel, dataRate);
RF24::openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID); RF24::openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
RF24::startListening(); RF24::startListening();
+1 -1
View File
@@ -40,7 +40,7 @@ class Gateway : public Relay
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er); Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er);
/* Use this and pass a function that should be called when you want to process commands that arrive from radio network */ /* Use this and pass a function that should be called when you want to process commands that arrive from radio network */
void begin(rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, void (*dataCallback)(char *)=NULL); void begin(rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS, void (*dataCallback)(char *)=NULL);
void processRadioMessage(); void processRadioMessage();
void parseAndSend(char *inputString); void parseAndSend(char *inputString);
+2 -2
View File
@@ -16,8 +16,8 @@ Relay::Relay(uint8_t _cepin, uint8_t _cspin) : Sensor(_cepin, _cspin) {
} }
void Relay::begin(uint8_t radioId, rf24_pa_dbm_e paLevel, uint8_t channel) { void Relay::begin(uint8_t radioId, rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate) {
Sensor::begin(radioId, paLevel, channel); Sensor::begin(radioId, paLevel, channel, dataRate);
// Read routing table from EEPROM // Read routing table from EEPROM
for (unsigned int i=0;i<sizeof(childNodeTable);i++) { for (unsigned int i=0;i<sizeof(childNodeTable);i++) {
childNodeTable[i] = EEPROM.read(EEPROM_ROUTES_ADDRESS+i); childNodeTable[i] = EEPROM.read(EEPROM_ROUTES_ADDRESS+i);
+2 -2
View File
@@ -35,11 +35,11 @@ class Relay : public Sensor
* Creates a new instance of Relay class. * Creates a new instance of Relay class.
* *
* @param _cepin The pin attached to RF24 Chip Enable on the RF module (default 9) * @param _cepin The pin attached to RF24 Chip Enable on the RF module (default 9)
* @param _cspin The pin attached to RF24 Chip Select (defualt 10) * @param _cspin The pin attached to RF24 Chip Select (default 10)
*/ */
Relay(uint8_t _cepin = 9, uint8_t _cspin = 10); Relay(uint8_t _cepin = 9, uint8_t _cspin = 10);
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76); void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
boolean messageAvailable(); boolean messageAvailable();
boolean send(message_s message, int length); boolean send(message_s message, int length);
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -22,7 +22,7 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <stdarg.h> #include <stdarg.h>
#define DEBUG //#define DEBUG
#ifdef DEBUG #ifdef DEBUG
#define debug(x,...) debugPrint(x, ##__VA_ARGS__) #define debug(x,...) debugPrint(x, ##__VA_ARGS__)
@@ -129,14 +129,15 @@ class Sensor : public RF24
Sensor(uint8_t _cepin=9, uint8_t _cspin=10); Sensor(uint8_t _cepin=9, uint8_t _cspin=10);
/** /**
* Begin operation of the sensor net library * Begin operation of the MySensors library
* *
* Call this in setup(), before calling any other sensor net library methods. * Call this in setup(), before calling any other sensor net library methods.
* @param radioId The unique id (1-254) for this sensor. Default 255 (auto mode). * @param radioId The unique id (1-254) for this sensor. Default 255 (auto mode).
* @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX * @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
* @param channel Radio channel. Default RF24_PA_MAX * @param channel Radio channel. Default is channel 76
* @param dataRate Radio transmission speed. Default RF24_2MBPS
*/ */
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76); void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
uint8_t getRadioId(); uint8_t getRadioId();
@@ -257,7 +258,7 @@ class Sensor : public RF24
message_s msg; // Buffer for incoming messages. message_s msg; // Buffer for incoming messages.
char convBuffer[20]; char convBuffer[20];
void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel); void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate);
void findRelay(); void findRelay();
boolean send(message_s message, int length); boolean send(message_s message, int length);
boolean sendWrite(uint8_t dest, message_s message, int length); boolean sendWrite(uint8_t dest, message_s message, int length);