Added the forgotten dataRate to begin() default speed is 2MBPS
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Sensor::Sensor(uint8_t _cepin, uint8_t _cspin) : RF24(_cepin, _cspin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Sensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel) {
|
void Sensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate) {
|
||||||
failedTransmissions = 0;
|
failedTransmissions = 0;
|
||||||
|
|
||||||
// Start up the radio library
|
// Start up the radio library
|
||||||
@@ -27,7 +27,7 @@ void Sensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel) {
|
|||||||
RF24::setRetries(15, 15);
|
RF24::setRetries(15, 15);
|
||||||
RF24::setPALevel(paLevel);
|
RF24::setPALevel(paLevel);
|
||||||
RF24::setChannel(channel);
|
RF24::setChannel(channel);
|
||||||
RF24::setDataRate(RF24_2MBPS);
|
RF24::setDataRate(dataRate);
|
||||||
RF24::setCRCLength(RF24_CRC_16);
|
RF24::setCRCLength(RF24_CRC_16);
|
||||||
|
|
||||||
// All repeater nodes and gateway listen to broadcast pipe (for PING messages)
|
// All repeater nodes and gateway listen to broadcast pipe (for PING messages)
|
||||||
@@ -36,14 +36,14 @@ void Sensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sensor::begin(uint8_t _radioId, rf24_pa_dbm_e paLevel, uint8_t channel) {
|
void Sensor::begin(uint8_t _radioId, rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate) {
|
||||||
Serial.begin(BAUD_RATE);
|
Serial.begin(BAUD_RATE);
|
||||||
|
|
||||||
radioId = _radioId;
|
radioId = _radioId;
|
||||||
|
|
||||||
debug(PSTR("Started %s.\n"), isRelay?"relay":"sensor");
|
debug(PSTR("Started %s.\n"), isRelay?"relay":"sensor");
|
||||||
|
|
||||||
setupRadio(paLevel, channel);
|
setupRadio(paLevel, channel, dataRate);
|
||||||
|
|
||||||
// Fetch relay from EEPROM
|
// Fetch relay from EEPROM
|
||||||
relayId = EEPROM.read(EEPROM_RELAY_ID_ADDRESS);
|
relayId = EEPROM.read(EEPROM_RELAY_ID_ADDRESS);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user