diff --git a/MyConfig.h b/MyConfig.h
index 5d4cec8..10444f8 100644
--- a/MyConfig.h
+++ b/MyConfig.h
@@ -441,16 +441,18 @@
#endif
/**
- * @def MY_RF24_IRQ_PIN
- * @brief Disable RF24 interrupt pin usage by default. Override in sketch if needed.
- */
-//#define MY_RF24_IRQ_PIN
+* @def MY_RX_MESSAGE_BUFFER_FEATURE
+* @brief This enabled the receiving buffer feature.
+*
+* This feature is currently not supported for RFM69 and RS485, for RF24 MY_RF24_IRQ_PIN has to be defined.
+*/
+//#define MY_RX_MESSAGE_BUFFER_FEATURE
/**
* @def MY_RX_MESSAGE_BUFFER_SIZE
- * @brief Declare the amount of incoming messages that can be buffered. Requires MY_RADIO_NRF24 and MY_RF24_IRQ_PIN. Override in sketch if needed.
+ * @brief Declare the amount of incoming messages that can be buffered.
*/
-#ifdef MY_RF24_IRQ_PIN
+#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
#ifndef MY_RX_MESSAGE_BUFFER_SIZE
#define MY_RX_MESSAGE_BUFFER_SIZE (20)
#endif
@@ -758,6 +760,7 @@
#define MY_DEBUG_VERBOSE_RF24
#define MY_TRANSPORT_SANITY_CHECK
#define MY_RF24_IRQ_PIN
+#define MY_RX_MESSAGE_BUFFER_FEATURE
#define MY_RX_MESSAGE_BUFFER_SIZE
#define MY_NODE_LOCK_FEATURE
#endif
diff --git a/MySensors.h b/MySensors.h
index b2f6890..81b514b 100644
--- a/MySensors.h
+++ b/MySensors.h
@@ -285,23 +285,6 @@
#error Only one forward link driver can be activated
#endif
#if defined(MY_RADIO_NRF24)
- #ifdef MY_RF24_IRQ_PIN
- // SoftSPI does not support usingInterrupt()
- #ifdef MY_SOFTSPI
- #error RF24 IRQ usage cannot be used with Soft SPI
- #endif
- // ESP8266 does not support usingInterrupt()
- #ifdef ESP8266
- #error RF24 IRQ usage cannot be used with ESP8266
- #endif
- #ifndef SPI_HAS_TRANSACTION
- #error RF24 IRQ usage requires transactional SPI support
- #endif
- #else
- #ifdef MY_RX_MESSAGE_BUFFER_SIZE
- #error Receive message buffering requires RF24 IRQ usage
- #endif
- #endif
#if defined(MY_RF24_ENABLE_ENCRYPTION)
#include "drivers/AES/AES.cpp"
#endif
diff --git a/core/MyHwATMega328.cpp b/core/MyHwATMega328.cpp
index 349e775..100d7ed 100644
--- a/core/MyHwATMega328.cpp
+++ b/core/MyHwATMega328.cpp
@@ -198,22 +198,21 @@ uint16_t hwFreeMem() {
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
- char fmtBuffer[300];
+ char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
- snprintf_P(fmtBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
+ snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
MY_SERIALDEVICE.print(fmtBuffer);
#endif
va_list args;
va_start (args, fmt );
- va_end (args);
#ifdef MY_GATEWAY_FEATURE
// Truncate message if this is gateway node
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
#else
- vsnprintf_P(fmtBuffer, 299, fmt, args);
+ vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
#endif
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
diff --git a/core/MyHwATMega328.h b/core/MyHwATMega328.h
index c486239..3924fff 100644
--- a/core/MyHwATMega328.h
+++ b/core/MyHwATMega328.h
@@ -35,6 +35,8 @@
#endif
#define MY_SERIALDEVICE Serial
+#define MY_DEBUG_BUFFER_SIZE 300
+
#if defined __AVR_ATmega328P__
#ifndef sleep_bod_disable
#define sleep_bod_disable() \
diff --git a/core/MyHwESP8266.cpp b/core/MyHwESP8266.cpp
index 1e50156..3c10105 100644
--- a/core/MyHwESP8266.cpp
+++ b/core/MyHwESP8266.cpp
@@ -132,22 +132,21 @@ uint16_t hwFreeMem() {
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
- char fmtBuffer[300];
+ char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
- snprintf_P(fmtBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
+ snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
MY_SERIALDEVICE.print(fmtBuffer);
#endif
va_list args;
va_start (args, fmt );
- va_end (args);
#ifdef MY_GATEWAY_FEATURE
// Truncate message if this is gateway node
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
#else
- vsnprintf_P(fmtBuffer, 299, fmt, args);
+ vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
#endif
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
diff --git a/core/MyHwESP8266.h b/core/MyHwESP8266.h
index 2c5a942..f44a669 100644
--- a/core/MyHwESP8266.h
+++ b/core/MyHwESP8266.h
@@ -26,6 +26,8 @@
#endif
#define MY_SERIALDEVICE Serial
+#define MY_DEBUG_BUFFER_SIZE 300
+
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
diff --git a/core/MyHwSAMD.cpp b/core/MyHwSAMD.cpp
index 264da9c..2d85501 100644
--- a/core/MyHwSAMD.cpp
+++ b/core/MyHwSAMD.cpp
@@ -156,22 +156,21 @@ uint16_t hwFreeMem() {
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
if (MY_SERIALDEVICE) {
- char fmtBuffer[300];
+ char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
- snprintf(fmtBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
+ snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
MY_SERIALDEVICE.print(fmtBuffer);
#endif
va_list args;
va_start (args, fmt );
- va_end (args);
#ifdef MY_GATEWAY_FEATURE
// Truncate message if this is gateway node
vsnprintf(fmtBuffer, 60, fmt, args);
fmtBuffer[59] = '\n';
fmtBuffer[60] = '\0';
#else
- vsnprintf(fmtBuffer, 299, fmt, args);
+ vsnprintf(fmtBuffer, sizeof(fmtBuffer), fmt, args);
#endif
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
diff --git a/core/MyHwSAMD.h b/core/MyHwSAMD.h
index dcb783c..dce2dba 100644
--- a/core/MyHwSAMD.h
+++ b/core/MyHwSAMD.h
@@ -50,6 +50,7 @@ void hwWriteConfig(int adr, uint8_t value);
uint8_t hwReadConfig(int adr);
#define MY_SERIALDEVICE SerialUSB
+#define MY_DEBUG_BUFFER_SIZE 300
/*
diff --git a/core/MyMessage.cpp b/core/MyMessage.cpp
index d95977e..d289109 100644
--- a/core/MyMessage.cpp
+++ b/core/MyMessage.cpp
@@ -210,9 +210,10 @@ MyMessage& MyMessage::setDestination(uint8_t _destination) {
// Set payload
MyMessage& MyMessage::set(void* value, uint8_t length) {
+ uint8_t payloadLength = value == NULL ? 0 : min(length, (uint8_t)MAX_PAYLOAD);
+ miSetLength(payloadLength);
miSetPayloadType(P_CUSTOM);
- miSetLength(length);
- memcpy(data, value, min(length, (uint8_t)MAX_PAYLOAD));
+ memcpy(data, value, payloadLength);
return *this;
}
diff --git a/core/MyOTAFirmwareUpdate.cpp b/core/MyOTAFirmwareUpdate.cpp
index 73f7488..e30cf97 100644
--- a/core/MyOTAFirmwareUpdate.cpp
+++ b/core/MyOTAFirmwareUpdate.cpp
@@ -19,6 +19,12 @@
#include "MyOTAFirmwareUpdate.h"
+// global variables
+extern MyMessage _msg;
+extern MyMessage _msgTmp;
+extern NodeConfig _nc;
+
+// local variables
SPIFlash _flash(MY_OTA_FLASH_SS, MY_OTA_FLASH_JDECID);
NodeFirmwareConfig _fc;
bool _fwUpdateOngoing;
@@ -26,16 +32,16 @@ unsigned long _fwLastRequestTime;
uint16_t _fwBlock;
uint8_t _fwRetry;
-inline void readFirmwareSettings() {
+void readFirmwareSettings() {
hwReadConfigBlock((void*)&_fc, (void*)EEPROM_FIRMWARE_TYPE_ADDRESS, sizeof(NodeFirmwareConfig));
}
-inline void firmwareOTAUpdateRequest() {
+void firmwareOTAUpdateRequest() {
unsigned long enter = hwMillis();
if (_fwUpdateOngoing && (enter - _fwLastRequestTime > MY_OTA_RETRY_DELAY)) {
if (!_fwRetry) {
setIndication(INDICATION_ERR_FW_TIMEOUT);
- debug(PSTR("fw upd fail\n"));
+ OTA_DEBUG(PSTR("!OTA:FRQ:FW UPD FAIL\n")); // fw update failed
// Give up. We have requested MY_OTA_RETRY times without any packet in return.
_fwUpdateOngoing = false;
return;
@@ -47,24 +53,24 @@ inline void firmwareOTAUpdateRequest() {
firmwareRequest.type = _fc.type;
firmwareRequest.version = _fc.version;
firmwareRequest.block = (_fwBlock - 1);
- debug(PSTR("req FW: T=%02X, V=%02X, B=%04X\n"),_fc.type,_fc.version,_fwBlock - 1);
+ OTA_DEBUG(PSTR("OTA:FRQ:FW REQ,T=%04X,V=%04X,B=%04X\n"),_fc.type,_fc.version,_fwBlock - 1); // request FW update block
_sendRoute(build(_msgTmp, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_STREAM, ST_FIRMWARE_REQUEST, false).set(&firmwareRequest,sizeof(RequestFWBlock)));
}
}
-inline bool firmwareOTAUpdateProcess() {
+bool firmwareOTAUpdateProcess() {
if (_msg.type == ST_FIRMWARE_CONFIG_RESPONSE) {
NodeFirmwareConfig *firmwareConfigResponse = (NodeFirmwareConfig *)_msg.data;
// compare with current node configuration, if they differ, start fw fetch process
if (memcmp(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig))) {
setIndication(INDICATION_FW_UPDATE_START);
- debug(PSTR("fw update\n"));
+ OTA_DEBUG(PSTR("OTA:FWP:UPDATE\n")); // FW update initiated
// copy new FW config
memcpy(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig));
// Init flash
if (!_flash.initialize()) {
setIndication(INDICATION_ERR_FW_FLASH_INIT);
- debug(PSTR("flash init fail\n"));
+ OTA_DEBUG(PSTR("!OTA:FWP:FLASH INIT FAIL\n")); // failed to initialise flash
_fwUpdateOngoing = false;
} else {
// erase lower 32K -> max flash size for ATMEGA328
@@ -79,12 +85,12 @@ inline bool firmwareOTAUpdateProcess() {
}
return true;
}
- debug(PSTR("fw update skipped\n"));
+ OTA_DEBUG(PSTR("OTA:FWP:UPDATE SKIPPED\n")); // FW update skipped, no newer version available
} else if (_msg.type == ST_FIRMWARE_RESPONSE) {
if (_fwUpdateOngoing) {
// Save block to flash
setIndication(INDICATION_FW_UPDATE_RX);
- debug(PSTR("fw block %d\n"), _fwBlock);
+ OTA_DEBUG(PSTR("OTA:FWP:RECV B=%04X\n"), _fwBlock); // received FW block
// extract FW block
ReplyFWBlock *firmwareResponse = (ReplyFWBlock *)_msg.data;
// write to flash
@@ -94,9 +100,10 @@ inline bool firmwareOTAUpdateProcess() {
_fwBlock--;
if (!_fwBlock) {
// We're finished! Do a checksum and reboot.
+ OTA_DEBUG(PSTR("OTA:FWP:FW END\n")); // received FW block
_fwUpdateOngoing = false;
if (transportIsValidFirmware()) {
- debug(PSTR("fw checksum ok\n"));
+ OTA_DEBUG(PSTR("OTA:FWP:CRC OK\n")); // FW checksum ok
// All seems ok, write size and signature to flash (DualOptiboot will pick this up and flash it)
uint16_t fwsize = FIRMWARE_BLOCK_SIZE * _fc.blocks;
uint8_t OTAbuffer[10] = {'F','L','X','I','M','G',':',(uint8_t)(fwsize >> 8),(uint8_t)(fwsize & 0xff),':'};
@@ -106,21 +113,21 @@ inline bool firmwareOTAUpdateProcess() {
hwReboot();
} else {
setIndication(INDICATION_ERR_FW_CHECKSUM);
- debug(PSTR("fw checksum fail\n"));
+ OTA_DEBUG(PSTR("!OTA:FWP:CRC FAIL\n"));
}
}
// reset flags
_fwRetry = MY_OTA_RETRY+1;
_fwLastRequestTime = 0;
} else {
- debug(PSTR("No fw update ongoing\n"));
+ OTA_DEBUG(PSTR("!OTA:FWP:NO UPDATE\n"));
}
return true;
}
return false;
}
-inline void presentBootloaderInformation(){
+void presentBootloaderInformation(){
RequestFirmwareConfig *reqFWConfig = (RequestFirmwareConfig *)_msgTmp.data;
mSetLength(_msgTmp, sizeof(RequestFirmwareConfig));
mSetCommand(_msgTmp, C_STREAM);
@@ -133,7 +140,7 @@ inline void presentBootloaderInformation(){
_sendRoute(build(_msgTmp, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_STREAM, ST_FIRMWARE_CONFIG_REQUEST, false));
}
// do a crc16 on the whole received firmware
-inline bool transportIsValidFirmware() {
+bool transportIsValidFirmware() {
// init crc
uint16_t crc = ~0;
for (uint16_t i = 0; i < _fc.blocks * FIRMWARE_BLOCK_SIZE; ++i) {
diff --git a/core/MyOTAFirmwareUpdate.h b/core/MyOTAFirmwareUpdate.h
index 3c3921d..7153eac 100644
--- a/core/MyOTAFirmwareUpdate.h
+++ b/core/MyOTAFirmwareUpdate.h
@@ -17,57 +17,95 @@
* version 2 as published by the Free Software Foundation.
*/
+ /**
+ * @file MyOTAFirmwareUpdate.h
+ *
+ * @defgroup MyOTAFirmwaregrp MyOTAFirmwareUpdate
+ * @ingroup internals
+ * @{
+ *
+ * MyOTAFirmwareUpdate-related log messages, format: [!]SYSTEM:[SUB SYSTEM:]MESSAGE
+ * - [!] Exclamation mark is prepended in case of error or warning
+ * - SYSTEM:
+ * - OTA messages emitted by MyOTAFirmwareUpdate
+ * - SUB SYSTEMS:
+ * - OTA:FRQ from @ref firmwareOTAUpdateRequest()
+ * - OTA:FWP from @ref firmwareOTAUpdateProcess()
+ *
+ * MyOTAFirmwareUpdate debug log messages:
+ *
+ * |E| SYS | SUB | Message | Comment
+ * |-|------|-------|-------------------------------------------|----------------------------------------------------------------------------
+ * | | OTA | FWP | UPDATE | FW update initiated
+ * |!| OTA | FWP | FLASH INIT FAIL | Failed to initialise flash
+ * | | OTA | FWP | UPDATE SKIPPED | FW update skipped, no newer version available
+ * | | OTA | FWP | RECV B=%04X | Received FW block (B)
+ * | | OTA | FWP | FW END | FW received, proceed to CRC verification
+ * | | OTA | FWP | CRC OK | FW CRC verification OK
+ * |!| OTA | FWP | CRC FAIL | FW CRC verification failed
+ * | | OTA | FRQ | FW REQ,T=%04X,V=%04X,B=%04X | Request FW update, FW type (T), version (V), block (B)
+ * |!| OTA | FRQ | FW UPD FAIL | FW update failed
+ *
+ *
+ * @brief API declaration for MyOTAFirmwareUpdate
+ */
+
+
#ifndef MyOTAFirmwareUpdate_h
#define MyOTAFirmwareUpdate_h
#include "MySensorsCore.h"
-// Size of each firmware block
-#define FIRMWARE_BLOCK_SIZE 16
-// Number of times a firmware block should be requested before giving up
-#define FIRMWARE_MAX_REQUESTS 5
-// Number of times to request a fw block before giving up
-#define MY_OTA_RETRY 5
-// Number of millisecons before re-request a fw block
-#define MY_OTA_RETRY_DELAY 500
-// Start offset for firmware in flash (DualOptiboot wants to keeps a signature first)
-#define FIRMWARE_START_OFFSET 10
-// Bootloader version
-#define MY_OTA_BOOTLOADER_MAJOR_VERSION 3
-#define MY_OTA_BOOTLOADER_MINOR_VERSION 0
-#define MY_OTA_BOOTLOADER_VERSION (MY_OTA_BOOTLOADER_MINOR_VERSION * 256 + MY_OTA_BOOTLOADER_MAJOR_VERSION)
+#define FIRMWARE_BLOCK_SIZE (16) //!< Size of each firmware block
+#define FIRMWARE_MAX_REQUESTS (5) //!< Number of times a firmware block should be requested before giving up
+#define MY_OTA_RETRY (5) //!< Number of times to request a fw block before giving up
+#define MY_OTA_RETRY_DELAY (500) //!< Number of milliseconds before re-requesting a FW block
+#define FIRMWARE_START_OFFSET (10) //!< Start offset for firmware in flash (DualOptiboot wants to keeps a signature first)
+#define MY_OTA_BOOTLOADER_MAJOR_VERSION (3) //!< Bootloader version major
+#define MY_OTA_BOOTLOADER_MINOR_VERSION (0) //!< Bootloader version minor
+#define MY_OTA_BOOTLOADER_VERSION (MY_OTA_BOOTLOADER_MINOR_VERSION * 256 + MY_OTA_BOOTLOADER_MAJOR_VERSION) //!< Bootloader version
-/// @brief FW config structure, stored in eeprom
+#define OTA_DEBUG(x,...) debug(x, ##__VA_ARGS__) //!< debug
+
+/**
+* @brief FW config structure, stored in eeprom
+*/
typedef struct {
- uint16_t type; //!< Type of config
- uint16_t version; //!< Version of config
- uint16_t blocks; //!< Number of blocks
- uint16_t crc; //!< CRC of block data
+ uint16_t type; //!< Type of config
+ uint16_t version; //!< Version of config
+ uint16_t blocks; //!< Number of blocks
+ uint16_t crc; //!< CRC of block data
} __attribute__((packed)) NodeFirmwareConfig;
-/// @brief FW config request structure
+/**
+* @brief FW config request structure
+*/
typedef struct {
- uint16_t type; //!< Type of config
- uint16_t version; //!< Version of config
- uint16_t blocks; //!< Number of blocks
- uint16_t crc; //!< CRC of block data
- uint16_t BLVersion; //!< Bootloader version
+ uint16_t type; //!< Type of config
+ uint16_t version; //!< Version of config
+ uint16_t blocks; //!< Number of blocks
+ uint16_t crc; //!< CRC of block data
+ uint16_t BLVersion; //!< Bootloader version
} __attribute__((packed)) RequestFirmwareConfig;
-/// @brief FW block request structure
+/**
+* @brief FW block request structure
+*/
typedef struct {
- uint16_t type; //!< Type of config
- uint16_t version; //!< Version of config
- uint16_t block; //!< Block index
+ uint16_t type; //!< Type of config
+ uint16_t version; //!< Version of config
+ uint16_t block; //!< Block index
} __attribute__((packed)) RequestFWBlock;
-/// @brief FW block reply structure
+/**
+* @brief FW block reply structure
+*/
typedef struct {
- uint16_t type; //!< Type of config
- uint16_t version; //!< Version of config
- uint16_t block; //!< Block index
- uint8_t data[FIRMWARE_BLOCK_SIZE]; //!< Block data
+ uint16_t type; //!< Type of config
+ uint16_t version; //!< Version of config
+ uint16_t block; //!< Block index
+ uint8_t data[FIRMWARE_BLOCK_SIZE]; //!< Block data
} __attribute__((packed)) ReplyFWBlock;
@@ -98,4 +136,6 @@ bool transportIsValidFirmware();
*/
void presentBootloaderInformation();
-#endif
\ No newline at end of file
+#endif
+
+/** @}*/
\ No newline at end of file
diff --git a/core/MySensorsCore.h b/core/MySensorsCore.h
index 5676840..d9dafa6 100644
--- a/core/MySensorsCore.h
+++ b/core/MySensorsCore.h
@@ -33,7 +33,7 @@
* - MCO:REG from @ref _registerNode()
* - MCO:SND from @ref send()
* - MCO:PIM from @ref _processInternalMessages()
- * - MCO:NLK from @ref nodeLock()
+ * - MCO:NLK from nodeLock()
*
* MySensorsCore debug log messages:
*
diff --git a/core/MyTransport.h b/core/MyTransport.h
index 0b5a5c7..2267bee 100644
--- a/core/MyTransport.h
+++ b/core/MyTransport.h
@@ -147,6 +147,18 @@
#else
#define TRANSMISSION_FAILURES 5 //!< search for a new parent node after this many transmission failures, lower threshold for non-repeating nodes
#endif
+
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
+ #if defined(MY_RADIO_RFM69)
+ #error Receive message buffering not supported for RFM69!
+ #endif
+ #if defined(MY_RS485)
+ #error Receive message buffering not supported for RS485!
+ #endif
+#elif !defined(MY_RX_MESSAGE_BUFFER_FEATURE) && defined(MY_RX_MESSAGE_BUFFER_SIZE)
+ #error Receive message buffering requires message buffering feature enabled!
+#endif
+
#define TIMEOUT_FAILURE_STATE 10000 //!< duration failure state
#define STATE_TIMEOUT 2000 //!< general state timeout
#define STATE_RETRIES 3 //!< retries before switching to FAILURE
diff --git a/core/MyTransportNRF24.cpp b/core/MyTransportNRF24.cpp
index fa72736..6dce160 100644
--- a/core/MyTransportNRF24.cpp
+++ b/core/MyTransportNRF24.cpp
@@ -32,7 +32,7 @@
#include "drivers/AES/AES.h"
#endif
-#ifdef MY_RF24_IRQ_PIN
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
typedef struct _transportQueuedMessage
{
uint8_t m_len; // Length of the data
@@ -82,7 +82,7 @@ bool transportInit() {
memset(_psk, 0, 16);
#endif
- #ifdef MY_RF24_IRQ_PIN
+ #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
RF24_registerReceiveCallback( transportRxCallback );
#endif
return RF24_initialize();
@@ -115,7 +115,7 @@ bool transportSend(uint8_t recipient, const void* data, uint8_t len) {
}
bool transportAvailable() {
- #ifdef MY_RF24_IRQ_PIN
+ #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
(void)RF24_isDataAvailable; // Prevent 'defined but not used' warning
return !transportRxQueue.empty();
#else
@@ -129,10 +129,9 @@ bool transportSanityCheck() {
uint8_t transportReceive(void* data) {
uint8_t len = 0;
- #ifdef MY_RF24_IRQ_PIN
+ #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
transportQueuedMessage* msg = transportRxQueue.getBack();
- if (msg)
- {
+ if (msg) {
len = msg->m_len;
(void)memcpy(data, msg->m_data, len);
(void)transportRxQueue.popBack();
diff --git a/drivers/RF24/RF24.cpp b/drivers/RF24/RF24.cpp
index d263c1f..bd84c56 100644
--- a/drivers/RF24/RF24.cpp
+++ b/drivers/RF24/RF24.cpp
@@ -25,7 +25,7 @@
LOCAL uint8_t MY_RF24_BASE_ADDR[MY_RF24_ADDR_WIDTH] = { MY_RF24_BASE_RADIO_ID };
LOCAL uint8_t MY_RF24_NODE_ADDRESS = AUTO;
-#ifdef MY_RF24_IRQ_PIN
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
LOCAL RF24_receiveCallbackType RF24_receiveCallback = NULL;
#endif
@@ -66,7 +66,7 @@ LOCAL uint8_t RF24_spiByteTransfer(uint8_t cmd) {
}
LOCAL uint8_t RF24_RAW_readByteRegister(uint8_t cmd) {
- uint8_t value = RF24_spiMultiByteTransfer( cmd, NULL, 1, true);
+ const uint8_t value = RF24_spiMultiByteTransfer( cmd, NULL, 1, true);
RF24_DEBUG(PSTR("RF24:read register, reg=%d, value=%d\n"), cmd & (R_REGISTER ^ 0xFF), value);
return value;
}
@@ -90,7 +90,7 @@ LOCAL uint8_t RF24_getStatus(void) {
return RF24_spiByteTransfer( NOP );
}
-LOCAL uint8_t RF24_getFifoStatus(void) {
+LOCAL uint8_t RF24_getFIFOStatus(void) {
return RF24_readByteRegister(FIFO_STATUS);
}
@@ -138,6 +138,10 @@ LOCAL void RF24_setPipeLSB(uint8_t pipe, uint8_t LSB) {
RF24_writeByteRegister(pipe, LSB);
}
+LOCAL uint8_t RF24_getObserveTX(void) {
+ return RF24_readByteRegister(OBSERVE_TX);
+}
+
LOCAL void RF24_setStatus(uint8_t status) {
RF24_writeByteRegister(RF24_STATUS, status);
}
@@ -187,9 +191,8 @@ LOCAL bool RF24_sendMessage( uint8_t recipient, const void* buf, uint8_t len ) {
// flush TX FIFO
RF24_flushTX();
// this command is affected in clones (e.g. Si24R1): flipped NoACK bit when using W_TX_PAYLOAD_NO_ACK / W_TX_PAYLOAD
- // RF24_spiMultiByteTransfer( recipient==BROADCAST_ADDRESS ? W_TX_PAYLOAD_NO_ACK : W_TX_PAYLOAD, (uint8_t*)buf, len, false );
- // we are safe by disabling AutoACK on the broadcasting pipe
- RF24_spiMultiByteTransfer( W_TX_PAYLOAD, (uint8_t*)buf, len, false );
+ // AutoACK is disabled on the broadcasting pipe - NO_ACK prevents resending
+ RF24_spiMultiByteTransfer(recipient == BROADCAST_ADDRESS ? W_TX_PAYLOAD_NO_ACK : W_TX_PAYLOAD, (uint8_t*)buf, len, false );
// go, TX starts after ~10us
RF24_ce(HIGH);
// timeout counter to detect HW issues
@@ -207,10 +210,9 @@ LOCAL bool RF24_sendMessage( uint8_t recipient, const void* buf, uint8_t len ) {
RF24_DEBUG(PSTR("RF24:MAX_RT\n"));
RF24_flushTX();
}
-
RF24_startListening();
- // true if message sent and not timeout
- return (status & _BV(TX_DS) && timeout);
+ // true if message sent
+ return ( status & _BV(TX_DS) );
}
LOCAL uint8_t RF24_getDynamicPayloadSize(void) {
@@ -224,15 +226,13 @@ LOCAL uint8_t RF24_getDynamicPayloadSize(void) {
return result;
}
-
LOCAL bool RF24_isDataAvailable() {
- uint8_t status = RF24_getStatus();
- return (((status >> RX_P_NO) & 0b0111) <= 5);
+ return ( !(RF24_getFIFOStatus() & _BV(0)) );
}
LOCAL uint8_t RF24_readMessage( void* buf) {
- uint8_t len = RF24_getDynamicPayloadSize();
+ const uint8_t len = RF24_getDynamicPayloadSize();
RF24_DEBUG(PSTR("RF24:read message, len=%d\n"), len);
RF24_spiMultiByteTransfer( R_RX_PAYLOAD , (uint8_t*)buf, len, true );
// clear RX interrupt
@@ -256,12 +256,10 @@ LOCAL uint8_t RF24_getNodeID(void) {
LOCAL bool RF24_sanityCheck(void) {
// detect HW defect, configuration errors or interrupted SPI line, CE disconnect cannot be detected
- bool status = RF24_readByteRegister(RF_SETUP) == MY_RF24_RF_SETUP;
- status &= RF24_readByteRegister(RF_CH) == MY_RF24_CHANNEL;
- return status;
+ return (RF24_readByteRegister(RF_SETUP) == MY_RF24_RF_SETUP) & (RF24_readByteRegister(RF_CH) == MY_RF24_CHANNEL);
}
-#ifdef MY_RF24_IRQ_PIN
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
LOCAL void RF24_irqHandler( void )
{
if (RF24_receiveCallback)
@@ -281,7 +279,7 @@ LOCAL void RF24_irqHandler( void )
// Start checking if RX-FIFO is not empty, as we might end up here from an interrupt
// for a message we've already read.
- while (!(RF24_getFifoStatus() & _BV(0))) {
+ while (RF24_isDataAvailable()) {
RF24_receiveCallback(); // Must call RF24_readMessage(), which will clear RX_DR IRQ !
}
// Restore our interrupt handler.
@@ -295,8 +293,7 @@ LOCAL void RF24_irqHandler( void )
}
}
-LOCAL void RF24_registerReceiveCallback( RF24_receiveCallbackType cb )
-{
+LOCAL void RF24_registerReceiveCallback( RF24_receiveCallbackType cb ) {
MY_CRITICAL_SECTION {
RF24_receiveCallback = cb;
}
@@ -304,25 +301,26 @@ LOCAL void RF24_registerReceiveCallback( RF24_receiveCallbackType cb )
#endif
LOCAL bool RF24_initialize(void) {
+ // prevent warning
+ (void)RF24_getObserveTX;
+
// Initialize pins
pinMode(MY_RF24_CE_PIN,OUTPUT);
pinMode(MY_RF24_CS_PIN,OUTPUT);
- #ifdef MY_RF24_IRQ_PIN
+ #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
pinMode(MY_RF24_IRQ_PIN,INPUT);
#endif
// Initialize SPI
_SPI.begin();
RF24_ce(LOW);
RF24_csn(HIGH);
- #ifdef MY_RF24_IRQ_PIN
+ #if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
// assure SPI can be used from interrupt context
// Note: ESP8266 & SoftSPI currently do not support interrupt usage for SPI,
// therefore it is unsafe to use MY_RF24_IRQ_PIN with ESP8266/SoftSPI!
_SPI.usingInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN));
// attach interrupt
attachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN), RF24_irqHandler, FALLING);
- #else
- (void)RF24_getFifoStatus; // prevent 'defined but not used' warning
#endif
// CRC and power up
RF24_setRFConfiguration(MY_RF24_CONFIGURATION | _BV(PWR_UP) ) ;
diff --git a/drivers/RF24/RF24.h b/drivers/RF24/RF24.h
index 765a434..d1e8f57 100644
--- a/drivers/RF24/RF24.h
+++ b/drivers/RF24/RF24.h
@@ -34,13 +34,10 @@
#define MY_RF24_SPI_DATA_MODE SPI_MODE0
#if defined (ARDUINO) && !defined (__arm__) && !defined (_SPI)
+ #include
#if defined(MY_SOFTSPI)
SoftSPI _SPI;
- #elif defined(ARDUINO_ARCH_SAMD)
- #include
- #define _SPI SPI1
#else
- #include
#define _SPI SPI
#endif
#else
@@ -61,8 +58,31 @@
#endif
#endif
+// verify RF24 IRQ defs
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
+ #if !defined(MY_RF24_IRQ_PIN)
+ #error Message buffering feature requires MY_RF24_IRQ_PIN to be defined!
+ #endif
+ // SoftSPI does not support usingInterrupt()
+ #ifdef MY_SOFTSPI
+ #error RF24 IRQ usage cannot be used with Soft SPI
+ #endif
+ // ESP8266 does not support usingInterrupt()
+ #ifdef ARDUINO_ARCH_ESP8266
+ #error RF24 IRQ usage cannot be used with ESP8266
+ #endif
+ #ifndef SPI_HAS_TRANSACTION
+ #error RF24 IRQ usage requires transactional SPI support
+ #endif
+#else
+ #ifdef MY_RX_MESSAGE_BUFFER_SIZE
+ #error Receive message buffering requires RF24 IRQ usage
+ #endif
+#endif
+
+
// RF24 settings
-#ifdef MY_RF24_IRQ_PIN
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
#define MY_RF24_CONFIGURATION (uint8_t) ((RF24_CRC_16 << 2) | (1 << MASK_TX_DS) | (1 << MASK_MAX_RT))
#else
#define MY_RF24_CONFIGURATION (uint8_t) (RF24_CRC_16 << 2)
@@ -226,7 +246,7 @@ LOCAL uint8_t RF24_RAW_writeByteRegister(uint8_t cmd, uint8_t value);
LOCAL void RF24_flushRX(void);
LOCAL void RF24_flushTX(void);
LOCAL uint8_t RF24_getStatus(void);
-LOCAL uint8_t RF24_getFifoStatus(void);
+LOCAL uint8_t RF24_getFIFOStatus(void);
LOCAL void RF24_openWritingPipe(uint8_t recipient);
LOCAL void RF24_startListening(void);
LOCAL void RF24_stopListening(void);
@@ -250,10 +270,11 @@ LOCAL void RF24_setDynamicPayload(uint8_t pipe);
LOCAL void RF24_setRFConfiguration(uint8_t configuration);
LOCAL void RF24_setPipeAddress(uint8_t pipe, uint8_t* address, uint8_t width);
LOCAL void RF24_setPipeLSB(uint8_t pipe, uint8_t LSB);
+LOCAL uint8_t RF24_getObserveTX(void);
LOCAL void RF24_setStatus(uint8_t status);
LOCAL void RF24_enableFeatures(void);
-#ifdef MY_RF24_IRQ_PIN
+#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
typedef void (*RF24_receiveCallbackType)(void);
/**
* Register a callback, which will be called (from interrupt context) for every message received.
diff --git a/examples/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor.ino
index f2bc01b..07827aa 100644
--- a/examples/AirQualitySensor/AirQualitySensor.ino
+++ b/examples/AirQualitySensor/AirQualitySensor.ino
@@ -41,7 +41,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_MQ 0
diff --git a/examples/BatteryPoweredSensor/BatteryPoweredSensor.ino b/examples/BatteryPoweredSensor/BatteryPoweredSensor.ino
index a3e3ed1..9a5b74f 100644
--- a/examples/BatteryPoweredSensor/BatteryPoweredSensor.ino
+++ b/examples/BatteryPoweredSensor/BatteryPoweredSensor.ino
@@ -35,7 +35,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
diff --git a/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino b/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino
index 3c6c08f..f4d44e7 100644
--- a/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino
+++ b/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino
@@ -37,7 +37,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define SKETCH_NAME "Binary Sensor"
diff --git a/examples/CO2Sensor/CO2Sensor.ino b/examples/CO2Sensor/CO2Sensor.ino
index cd6e7fc..3ba3737 100644
--- a/examples/CO2Sensor/CO2Sensor.ino
+++ b/examples/CO2Sensor/CO2Sensor.ino
@@ -45,7 +45,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_AIQ 0
diff --git a/examples/ClearEepromConfig/ClearEepromConfig.ino b/examples/ClearEepromConfig/ClearEepromConfig.ino
index f2a7e79..e885917 100644
--- a/examples/ClearEepromConfig/ClearEepromConfig.ino
+++ b/examples/ClearEepromConfig/ClearEepromConfig.ino
@@ -26,7 +26,6 @@
// load core modules only
#define MY_CORE_ONLY
-#include
#include
void setup()
diff --git a/examples/DimmableLEDActuator/DimmableLEDActuator.ino b/examples/DimmableLEDActuator/DimmableLEDActuator.ino
index aa04a93..332aba7 100644
--- a/examples/DimmableLEDActuator/DimmableLEDActuator.ino
+++ b/examples/DimmableLEDActuator/DimmableLEDActuator.ino
@@ -42,7 +42,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define SN "DimmableLED"
diff --git a/examples/DimmableLight/DimmableLight.ino b/examples/DimmableLight/DimmableLight.ino
index e834daf..12bac2d 100644
--- a/examples/DimmableLight/DimmableLight.ino
+++ b/examples/DimmableLight/DimmableLight.ino
@@ -36,7 +36,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_LIGHT 1
diff --git a/examples/DustSensor/DustSensor.ino b/examples/DustSensor/DustSensor.ino
index 8b4cedd..e6ea3b2 100644
--- a/examples/DustSensor/DustSensor.ino
+++ b/examples/DustSensor/DustSensor.ino
@@ -45,7 +45,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_DUST 0
diff --git a/examples/DustSensorDSM/DustSensorDSM.ino b/examples/DustSensorDSM/DustSensorDSM.ino
index e27a37a..6657110 100644
--- a/examples/DustSensorDSM/DustSensorDSM.ino
+++ b/examples/DustSensorDSM/DustSensorDSM.ino
@@ -37,7 +37,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_DUST_PM10 0
diff --git a/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino b/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino
index 9188730..041f0b2 100644
--- a/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino
+++ b/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino
@@ -41,7 +41,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
diff --git a/examples/GatewayESP8266/GatewayESP8266.ino b/examples/GatewayESP8266/GatewayESP8266.ino
index 2408bea..6582a70 100644
--- a/examples/GatewayESP8266/GatewayESP8266.ino
+++ b/examples/GatewayESP8266/GatewayESP8266.ino
@@ -65,8 +65,6 @@
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
*/
-#include
-#include
// Enable debug prints to serial monitor
#define MY_DEBUG
diff --git a/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino b/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino
index 164aa12..7a73594 100644
--- a/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino
+++ b/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino
@@ -57,8 +57,6 @@
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
*/
-#include
-#include
// Enable debug prints to serial monitor
#define MY_DEBUG
diff --git a/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino b/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino
index f89ccf8..4e7870c 100644
--- a/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino
+++ b/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino
@@ -66,8 +66,6 @@
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
*/
-#include
-#include
#include
// Enable debug prints to serial monitor
diff --git a/examples/GatewaySerial/GatewaySerial.ino b/examples/GatewaySerial/GatewaySerial.ino
index 4d72270..3c0b6be 100644
--- a/examples/GatewaySerial/GatewaySerial.ino
+++ b/examples/GatewaySerial/GatewaySerial.ino
@@ -82,7 +82,6 @@
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
-#include
#include
void setup() {
diff --git a/examples/GatewaySerialRS485/GatewaySerialRS485.ino b/examples/GatewaySerialRS485/GatewaySerialRS485.ino
index 3c3ca92..aabd1bc 100644
--- a/examples/GatewaySerialRS485/GatewaySerialRS485.ino
+++ b/examples/GatewaySerialRS485/GatewaySerialRS485.ino
@@ -82,7 +82,6 @@
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
-#include
#include
void setup() {
diff --git a/examples/GatewayW5100/GatewayW5100.ino b/examples/GatewayW5100/GatewayW5100.ino
index 5e7ca3f..2074842 100644
--- a/examples/GatewayW5100/GatewayW5100.ino
+++ b/examples/GatewayW5100/GatewayW5100.ino
@@ -109,7 +109,6 @@
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
-#include
#if defined(MY_USE_UDP)
#include
diff --git a/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino b/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino
index 8798c3a..bbcaa96 100644
--- a/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino
+++ b/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino
@@ -57,7 +57,6 @@
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
*/
-#include
// Enable debug prints to serial monitor
#define MY_DEBUG
diff --git a/examples/LightSensor/LightSensor.ino b/examples/LightSensor/LightSensor.ino
index 193130d..baa8280 100644
--- a/examples/LightSensor/LightSensor.ino
+++ b/examples/LightSensor/LightSensor.ino
@@ -33,7 +33,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define CHILD_ID_LIGHT 0
diff --git a/examples/MockMySensors/MockMySensors.ino b/examples/MockMySensors/MockMySensors.ino
index 6de46a0..7b801c9 100644
--- a/examples/MockMySensors/MockMySensors.ino
+++ b/examples/MockMySensors/MockMySensors.ino
@@ -15,7 +15,6 @@
#define MY_NODE_ID 254
-#include
#include
#define RADIO_ERROR_LED_PIN 4 // Error led pin
diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino
index d082c4d..17bdc48 100644
--- a/examples/MotionSensor/MotionSensor.ino
+++ b/examples/MotionSensor/MotionSensor.ino
@@ -34,7 +34,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
diff --git a/examples/MotionSensorRS485/MotionSensorRS485.ino b/examples/MotionSensorRS485/MotionSensorRS485.ino
index 5af08fb..7af76d2 100644
--- a/examples/MotionSensorRS485/MotionSensorRS485.ino
+++ b/examples/MotionSensorRS485/MotionSensorRS485.ino
@@ -53,7 +53,6 @@
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
-#include
#include
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
diff --git a/examples/PHSensor/PHSensor.ino b/examples/PHSensor/PHSensor.ino
index 713f1c6..4eb7b8f 100644
--- a/examples/PHSensor/PHSensor.ino
+++ b/examples/PHSensor/PHSensor.ino
@@ -29,7 +29,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
diff --git a/examples/PingPongSensor/PingPongSensor.ino b/examples/PingPongSensor/PingPongSensor.ino
index 4a98b31..67249de 100644
--- a/examples/PingPongSensor/PingPongSensor.ino
+++ b/examples/PingPongSensor/PingPongSensor.ino
@@ -15,7 +15,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#include "MYSLog.h"
diff --git a/examples/RelayActuator/RelayActuator.ino b/examples/RelayActuator/RelayActuator.ino
index dd26414..7f82c71 100644
--- a/examples/RelayActuator/RelayActuator.ino
+++ b/examples/RelayActuator/RelayActuator.ino
@@ -37,7 +37,6 @@
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
-#include
#include
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
diff --git a/examples/RepeaterNode/RepeaterNode.ino b/examples/RepeaterNode/RepeaterNode.ino
index fae8609..90791f6 100644
--- a/examples/RepeaterNode/RepeaterNode.ino
+++ b/examples/RepeaterNode/RepeaterNode.ino
@@ -38,7 +38,6 @@
// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
-#include
#include
void setup() {
diff --git a/examples/SecretKnockSensor/SecretKnockSensor.ino b/examples/SecretKnockSensor/SecretKnockSensor.ino
index 34349d4..7859d2e 100644
--- a/examples/SecretKnockSensor/SecretKnockSensor.ino
+++ b/examples/SecretKnockSensor/SecretKnockSensor.ino
@@ -58,7 +58,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
diff --git a/examples/SecureActuator/SecureActuator.ino b/examples/SecureActuator/SecureActuator.ino
index 80f34ea..b3a67f9 100644
--- a/examples/SecureActuator/SecureActuator.ino
+++ b/examples/SecureActuator/SecureActuator.ino
@@ -65,7 +65,6 @@
// SETTINGS FOR MY_SIGNING_ATSHA204
#define MY_SIGNING_ATSHA204_PIN 17 //!< A3 - pin where ATSHA204 is attached
-#include
#include
diff --git a/examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino b/examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino
index 11fb45c..f8443da 100644
--- a/examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino
+++ b/examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino
@@ -82,7 +82,6 @@
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
-#include
#include
#include
#include
diff --git a/examples/SoilMoistSensor/SoilMoistSensor.ino b/examples/SoilMoistSensor/SoilMoistSensor.ino
index 9d51e0d..0d45d08 100644
--- a/examples/SoilMoistSensor/SoilMoistSensor.ino
+++ b/examples/SoilMoistSensor/SoilMoistSensor.ino
@@ -68,7 +68,6 @@
//#define MY_RADIO_RFM69
#include // Conversion equation from resistance to %
-#include
#include
// Setting up format for reading 3 soil sensors
diff --git a/examples/UVSensor/UVSensor.ino b/examples/UVSensor/UVSensor.ino
index 2b70dee..e22451d 100644
--- a/examples/UVSensor/UVSensor.ino
+++ b/examples/UVSensor/UVSensor.ino
@@ -43,7 +43,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define UV_SENSOR_ANALOG_PIN 0
diff --git a/examples/VibrationSensor/VibrationSensor.ino b/examples/VibrationSensor/VibrationSensor.ino
index f060982..eaefa59 100644
--- a/examples/VibrationSensor/VibrationSensor.ino
+++ b/examples/VibrationSensor/VibrationSensor.ino
@@ -39,7 +39,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#include
diff --git a/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino b/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
index b7ce981..2a07105 100644
--- a/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
+++ b/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
@@ -41,7 +41,6 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
-#include
#include
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!)
diff --git a/keywords.txt b/keywords.txt
index c38e03f..77a2540 100644
--- a/keywords.txt
+++ b/keywords.txt
@@ -74,6 +74,7 @@ MY_RF24_SPI_MAX_SPEED LITERAL1
MY_RF24_CE_PIN LITERAL1
MY_RF24_CS_PIN LITERAL1
MY_RF24_IRQ_PIN LITERAL1
+MY_RX_MESSAGE_BUFFER_FEATURE LITERAL1
MY_RF24_PA_LEVEL LITERAL1
MY_RF24_CHANNEL LITERAL1
MY_RF24_DATARATE LITERAL1
diff --git a/tests/Arduino/sketches/hard_signing_no_whitelisting_full_debug/hard_signing_no_whitelisting_full_debug.ino b/tests/Arduino/sketches/hard_signing_no_whitelisting_full_debug/hard_signing_no_whitelisting_full_debug.ino
index 39b766d..dea5111 100644
--- a/tests/Arduino/sketches/hard_signing_no_whitelisting_full_debug/hard_signing_no_whitelisting_full_debug.ino
+++ b/tests/Arduino/sketches/hard_signing_no_whitelisting_full_debug/hard_signing_no_whitelisting_full_debug.ino
@@ -34,5 +34,4 @@
#define MY_SIGNING_ATSHA204_PIN 17
#endif
-#include
#include
diff --git a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug/hard_signing_whitelisting_full_debug.ino b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug/hard_signing_whitelisting_full_debug.ino
index d398e5c..23f0d9b 100644
--- a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug/hard_signing_whitelisting_full_debug.ino
+++ b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug/hard_signing_whitelisting_full_debug.ino
@@ -34,5 +34,4 @@
#define MY_SIGNING_ATSHA204_PIN 17
#endif
-#include
#include
diff --git a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nodelock/hard_signing_whitelisting_full_debug_nodelock.ino b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nodelock/hard_signing_whitelisting_full_debug_nodelock.ino
index c6e4de6..43ff5e9 100644
--- a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nodelock/hard_signing_whitelisting_full_debug_nodelock.ino
+++ b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nodelock/hard_signing_whitelisting_full_debug_nodelock.ino
@@ -35,5 +35,4 @@
#endif
#define MY_NODE_LOCK_FEATURE
-#include
#include
diff --git a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nrf24_rsa/hard_signing_whitelisting_full_debug_nrf24_rsa.ino b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nrf24_rsa/hard_signing_whitelisting_full_debug_nrf24_rsa.ino
index c5027bd..d1263b7 100644
--- a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nrf24_rsa/hard_signing_whitelisting_full_debug_nrf24_rsa.ino
+++ b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_nrf24_rsa/hard_signing_whitelisting_full_debug_nrf24_rsa.ino
@@ -35,5 +35,4 @@
#endif
#define MY_RF24_ENABLE_ENCRYPTION
-#include
#include
diff --git a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_rfm69_rsa/hard_signing_whitelisting_full_debug_rfm69_rsa.ino b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_rfm69_rsa/hard_signing_whitelisting_full_debug_rfm69_rsa.ino
index 3ddcb53..489f926 100644
--- a/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_rfm69_rsa/hard_signing_whitelisting_full_debug_rfm69_rsa.ino
+++ b/tests/Arduino/sketches/hard_signing_whitelisting_full_debug_rfm69_rsa/hard_signing_whitelisting_full_debug_rfm69_rsa.ino
@@ -35,5 +35,4 @@
#endif
#define MY_RFM69_ENABLE_ENCRYPTION
-#include
#include
diff --git a/tests/Arduino/sketches/soft_signing_no_whitelisting_full_debug/soft_signing_no_whitelisting_full_debug.ino b/tests/Arduino/sketches/soft_signing_no_whitelisting_full_debug/soft_signing_no_whitelisting_full_debug.ino
index 099a569..f922d57 100644
--- a/tests/Arduino/sketches/soft_signing_no_whitelisting_full_debug/soft_signing_no_whitelisting_full_debug.ino
+++ b/tests/Arduino/sketches/soft_signing_no_whitelisting_full_debug/soft_signing_no_whitelisting_full_debug.ino
@@ -34,5 +34,4 @@
#define MY_SIGNING_ATSHA204_PIN 17
#endif
-#include
#include
diff --git a/tests/Arduino/sketches/soft_signing_whitelisting_full_debug/soft_signing_whitelisting_full_debug.ino b/tests/Arduino/sketches/soft_signing_whitelisting_full_debug/soft_signing_whitelisting_full_debug.ino
index 707b2fd..3790fc6 100644
--- a/tests/Arduino/sketches/soft_signing_whitelisting_full_debug/soft_signing_whitelisting_full_debug.ino
+++ b/tests/Arduino/sketches/soft_signing_whitelisting_full_debug/soft_signing_whitelisting_full_debug.ino
@@ -34,5 +34,4 @@
#define MY_SIGNING_ATSHA204_PIN 17
#endif
-#include
#include