Fix logging of error if initialization of the radio fails
Signed-off-by: Tomas Hozza <thozza@gmail.com>
This commit is contained in:
@@ -101,7 +101,9 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
||||
isGateway = _nodeId == GATEWAY_ADDRESS;
|
||||
|
||||
// Setup radio
|
||||
radio.init();
|
||||
if (!radio.init()) {
|
||||
debug(PSTR("radio initialization failed!"));
|
||||
}
|
||||
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
// Read out the signing requirements from EEPROM
|
||||
|
||||
@@ -22,12 +22,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define debug(x,...) debugPrint(x, ##__VA_ARGS__)
|
||||
#else
|
||||
#define debug(x,...)
|
||||
#endif
|
||||
|
||||
#define AUTO 0xFF // 0-254. Id 255 is reserved for auto initialization of nodeId.
|
||||
#define NODE_SENSOR_ID 0xFF // Node child id is always created for when a node
|
||||
|
||||
@@ -45,7 +39,7 @@ public:
|
||||
// init()
|
||||
// different parameters would be needed depending on radio module (e.g. channel, power, crc, etc.)
|
||||
// keeping these parameters as #define's in MyConfig to streamline the driver interface
|
||||
virtual void init() = 0;
|
||||
virtual bool init() = 0;
|
||||
// setAddress(address)
|
||||
// set the node address and start listening to that address (and the broadcast address)
|
||||
virtual void setAddress(uint8_t address) = 0;
|
||||
|
||||
@@ -28,13 +28,12 @@ MyTransportNRF24::MyTransportNRF24(uint8_t ce, uint8_t cs, uint8_t paLevel)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTransportNRF24::init() {
|
||||
bool MyTransportNRF24::init() {
|
||||
// Start up the radio library
|
||||
rf24.begin();
|
||||
|
||||
if (!rf24.isPVariant()) {
|
||||
debug(PSTR("check wires\n"));
|
||||
while(1);
|
||||
return false;
|
||||
}
|
||||
rf24.setAutoAck(1);
|
||||
rf24.setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
|
||||
@@ -48,6 +47,7 @@ void MyTransportNRF24::init() {
|
||||
|
||||
// All nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages)
|
||||
rf24.openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyTransportNRF24::setAddress(uint8_t address) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class MyTransportNRF24 : public MyTransport
|
||||
{
|
||||
public:
|
||||
MyTransportNRF24(uint8_t ce=RF24_CE_PIN, uint8_t cs=RF24_CS_PIN, uint8_t paLevel=RF24_PA_LEVEL);
|
||||
void init();
|
||||
bool init();
|
||||
void setAddress(uint8_t address);
|
||||
uint8_t getAddress();
|
||||
bool send(uint8_t to, const void* data, uint8_t len);
|
||||
|
||||
@@ -29,13 +29,13 @@ MyTransportRFM69::MyTransportRFM69(uint8_t freqBand, uint8_t networkId, uint8_t
|
||||
{
|
||||
}
|
||||
|
||||
void MyTransportRFM69::init() {
|
||||
bool MyTransportRFM69::init() {
|
||||
// Start up the radio library (_address will be set later by the MySensors library)
|
||||
radio.initialize(_freqBand, _address, _networkId);
|
||||
#ifdef RFM69_ENABLE_ENCRYPTION
|
||||
radio.encrypt(ENCRYPTKEY);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyTransportRFM69::setAddress(uint8_t address) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class MyTransportRFM69 : public MyTransport
|
||||
{
|
||||
public:
|
||||
MyTransportRFM69(uint8_t freqBand=RFM69_FREQUENCY, uint8_t networkId=RFM69_NETWORKID, uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, uint8_t interruptNum=RF69_IRQ_NUM);
|
||||
void init();
|
||||
bool init();
|
||||
void setAddress(uint8_t address);
|
||||
uint8_t getAddress();
|
||||
bool send(uint8_t to, const void* data, uint8_t len);
|
||||
|
||||
Reference in New Issue
Block a user