Merge branch 'development' into dev-raspberrypi
This commit is contained in:
+9
-6
@@ -441,16 +441,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def MY_RF24_IRQ_PIN
|
* @def MY_RX_MESSAGE_BUFFER_FEATURE
|
||||||
* @brief Disable RF24 interrupt pin usage by default. Override in sketch if needed.
|
* @brief This enabled the receiving buffer feature.
|
||||||
*/
|
*
|
||||||
//#define MY_RF24_IRQ_PIN
|
* 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
|
* @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
|
#ifndef MY_RX_MESSAGE_BUFFER_SIZE
|
||||||
#define MY_RX_MESSAGE_BUFFER_SIZE (20)
|
#define MY_RX_MESSAGE_BUFFER_SIZE (20)
|
||||||
#endif
|
#endif
|
||||||
@@ -758,6 +760,7 @@
|
|||||||
#define MY_DEBUG_VERBOSE_RF24
|
#define MY_DEBUG_VERBOSE_RF24
|
||||||
#define MY_TRANSPORT_SANITY_CHECK
|
#define MY_TRANSPORT_SANITY_CHECK
|
||||||
#define MY_RF24_IRQ_PIN
|
#define MY_RF24_IRQ_PIN
|
||||||
|
#define MY_RX_MESSAGE_BUFFER_FEATURE
|
||||||
#define MY_RX_MESSAGE_BUFFER_SIZE
|
#define MY_RX_MESSAGE_BUFFER_SIZE
|
||||||
#define MY_NODE_LOCK_FEATURE
|
#define MY_NODE_LOCK_FEATURE
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
-17
@@ -285,23 +285,6 @@
|
|||||||
#error Only one forward link driver can be activated
|
#error Only one forward link driver can be activated
|
||||||
#endif
|
#endif
|
||||||
#if defined(MY_RADIO_NRF24)
|
#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)
|
#if defined(MY_RF24_ENABLE_ENCRYPTION)
|
||||||
#include "drivers/AES/AES.cpp"
|
#include "drivers/AES/AES.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -198,22 +198,21 @@ uint16_t hwFreeMem() {
|
|||||||
|
|
||||||
#ifdef MY_DEBUG
|
#ifdef MY_DEBUG
|
||||||
void hwDebugPrint(const char *fmt, ... ) {
|
void hwDebugPrint(const char *fmt, ... ) {
|
||||||
char fmtBuffer[300];
|
char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
// 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);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
#endif
|
#endif
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, fmt );
|
va_start (args, fmt );
|
||||||
va_end (args);
|
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// Truncate message if this is gateway node
|
// Truncate message if this is gateway node
|
||||||
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
|
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
|
||||||
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
|
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
|
||||||
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
|
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
|
||||||
#else
|
#else
|
||||||
vsnprintf_P(fmtBuffer, 299, fmt, args);
|
vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
|
||||||
#endif
|
#endif
|
||||||
va_end (args);
|
va_end (args);
|
||||||
MY_SERIALDEVICE.print(fmtBuffer);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_SERIALDEVICE Serial
|
#define MY_SERIALDEVICE Serial
|
||||||
|
#define MY_DEBUG_BUFFER_SIZE 300
|
||||||
|
|
||||||
#if defined __AVR_ATmega328P__
|
#if defined __AVR_ATmega328P__
|
||||||
#ifndef sleep_bod_disable
|
#ifndef sleep_bod_disable
|
||||||
#define sleep_bod_disable() \
|
#define sleep_bod_disable() \
|
||||||
|
|||||||
@@ -132,22 +132,21 @@ uint16_t hwFreeMem() {
|
|||||||
|
|
||||||
#ifdef MY_DEBUG
|
#ifdef MY_DEBUG
|
||||||
void hwDebugPrint(const char *fmt, ... ) {
|
void hwDebugPrint(const char *fmt, ... ) {
|
||||||
char fmtBuffer[300];
|
char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
// 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);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
#endif
|
#endif
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, fmt );
|
va_start (args, fmt );
|
||||||
va_end (args);
|
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// Truncate message if this is gateway node
|
// Truncate message if this is gateway node
|
||||||
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
|
vsnprintf_P(fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, fmt, args);
|
||||||
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
|
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1] = '\n';
|
||||||
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
|
fmtBuffer[MY_GATEWAY_MAX_SEND_LENGTH] = '\0';
|
||||||
#else
|
#else
|
||||||
vsnprintf_P(fmtBuffer, 299, fmt, args);
|
vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
|
||||||
#endif
|
#endif
|
||||||
va_end (args);
|
va_end (args);
|
||||||
MY_SERIALDEVICE.print(fmtBuffer);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_SERIALDEVICE Serial
|
#define MY_SERIALDEVICE Serial
|
||||||
|
#define MY_DEBUG_BUFFER_SIZE 300
|
||||||
|
|
||||||
#define min(a,b) ((a)<(b)?(a):(b))
|
#define min(a,b) ((a)<(b)?(a):(b))
|
||||||
#define max(a,b) ((a)>(b)?(a):(b))
|
#define max(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -156,22 +156,21 @@ uint16_t hwFreeMem() {
|
|||||||
#ifdef MY_DEBUG
|
#ifdef MY_DEBUG
|
||||||
void hwDebugPrint(const char *fmt, ... ) {
|
void hwDebugPrint(const char *fmt, ... ) {
|
||||||
if (MY_SERIALDEVICE) {
|
if (MY_SERIALDEVICE) {
|
||||||
char fmtBuffer[300];
|
char fmtBuffer[MY_DEBUG_BUFFER_SIZE];
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
// 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);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
#endif
|
#endif
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, fmt );
|
va_start (args, fmt );
|
||||||
va_end (args);
|
|
||||||
#ifdef MY_GATEWAY_FEATURE
|
#ifdef MY_GATEWAY_FEATURE
|
||||||
// Truncate message if this is gateway node
|
// Truncate message if this is gateway node
|
||||||
vsnprintf(fmtBuffer, 60, fmt, args);
|
vsnprintf(fmtBuffer, 60, fmt, args);
|
||||||
fmtBuffer[59] = '\n';
|
fmtBuffer[59] = '\n';
|
||||||
fmtBuffer[60] = '\0';
|
fmtBuffer[60] = '\0';
|
||||||
#else
|
#else
|
||||||
vsnprintf(fmtBuffer, 299, fmt, args);
|
vsnprintf(fmtBuffer, sizeof(fmtBuffer), fmt, args);
|
||||||
#endif
|
#endif
|
||||||
va_end (args);
|
va_end (args);
|
||||||
MY_SERIALDEVICE.print(fmtBuffer);
|
MY_SERIALDEVICE.print(fmtBuffer);
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ void hwWriteConfig(int adr, uint8_t value);
|
|||||||
uint8_t hwReadConfig(int adr);
|
uint8_t hwReadConfig(int adr);
|
||||||
|
|
||||||
#define MY_SERIALDEVICE SerialUSB
|
#define MY_SERIALDEVICE SerialUSB
|
||||||
|
#define MY_DEBUG_BUFFER_SIZE 300
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+3
-2
@@ -210,9 +210,10 @@ MyMessage& MyMessage::setDestination(uint8_t _destination) {
|
|||||||
|
|
||||||
// Set payload
|
// Set payload
|
||||||
MyMessage& MyMessage::set(void* value, uint8_t length) {
|
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);
|
miSetPayloadType(P_CUSTOM);
|
||||||
miSetLength(length);
|
memcpy(data, value, payloadLength);
|
||||||
memcpy(data, value, min(length, (uint8_t)MAX_PAYLOAD));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,12 @@
|
|||||||
|
|
||||||
#include "MyOTAFirmwareUpdate.h"
|
#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);
|
SPIFlash _flash(MY_OTA_FLASH_SS, MY_OTA_FLASH_JDECID);
|
||||||
NodeFirmwareConfig _fc;
|
NodeFirmwareConfig _fc;
|
||||||
bool _fwUpdateOngoing;
|
bool _fwUpdateOngoing;
|
||||||
@@ -26,16 +32,16 @@ unsigned long _fwLastRequestTime;
|
|||||||
uint16_t _fwBlock;
|
uint16_t _fwBlock;
|
||||||
uint8_t _fwRetry;
|
uint8_t _fwRetry;
|
||||||
|
|
||||||
inline void readFirmwareSettings() {
|
void readFirmwareSettings() {
|
||||||
hwReadConfigBlock((void*)&_fc, (void*)EEPROM_FIRMWARE_TYPE_ADDRESS, sizeof(NodeFirmwareConfig));
|
hwReadConfigBlock((void*)&_fc, (void*)EEPROM_FIRMWARE_TYPE_ADDRESS, sizeof(NodeFirmwareConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void firmwareOTAUpdateRequest() {
|
void firmwareOTAUpdateRequest() {
|
||||||
unsigned long enter = hwMillis();
|
unsigned long enter = hwMillis();
|
||||||
if (_fwUpdateOngoing && (enter - _fwLastRequestTime > MY_OTA_RETRY_DELAY)) {
|
if (_fwUpdateOngoing && (enter - _fwLastRequestTime > MY_OTA_RETRY_DELAY)) {
|
||||||
if (!_fwRetry) {
|
if (!_fwRetry) {
|
||||||
setIndication(INDICATION_ERR_FW_TIMEOUT);
|
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.
|
// Give up. We have requested MY_OTA_RETRY times without any packet in return.
|
||||||
_fwUpdateOngoing = false;
|
_fwUpdateOngoing = false;
|
||||||
return;
|
return;
|
||||||
@@ -47,24 +53,24 @@ inline void firmwareOTAUpdateRequest() {
|
|||||||
firmwareRequest.type = _fc.type;
|
firmwareRequest.type = _fc.type;
|
||||||
firmwareRequest.version = _fc.version;
|
firmwareRequest.version = _fc.version;
|
||||||
firmwareRequest.block = (_fwBlock - 1);
|
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)));
|
_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) {
|
if (_msg.type == ST_FIRMWARE_CONFIG_RESPONSE) {
|
||||||
NodeFirmwareConfig *firmwareConfigResponse = (NodeFirmwareConfig *)_msg.data;
|
NodeFirmwareConfig *firmwareConfigResponse = (NodeFirmwareConfig *)_msg.data;
|
||||||
// compare with current node configuration, if they differ, start fw fetch process
|
// compare with current node configuration, if they differ, start fw fetch process
|
||||||
if (memcmp(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig))) {
|
if (memcmp(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig))) {
|
||||||
setIndication(INDICATION_FW_UPDATE_START);
|
setIndication(INDICATION_FW_UPDATE_START);
|
||||||
debug(PSTR("fw update\n"));
|
OTA_DEBUG(PSTR("OTA:FWP:UPDATE\n")); // FW update initiated
|
||||||
// copy new FW config
|
// copy new FW config
|
||||||
memcpy(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig));
|
memcpy(&_fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig));
|
||||||
// Init flash
|
// Init flash
|
||||||
if (!_flash.initialize()) {
|
if (!_flash.initialize()) {
|
||||||
setIndication(INDICATION_ERR_FW_FLASH_INIT);
|
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;
|
_fwUpdateOngoing = false;
|
||||||
} else {
|
} else {
|
||||||
// erase lower 32K -> max flash size for ATMEGA328
|
// erase lower 32K -> max flash size for ATMEGA328
|
||||||
@@ -79,12 +85,12 @@ inline bool firmwareOTAUpdateProcess() {
|
|||||||
}
|
}
|
||||||
return true;
|
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) {
|
} else if (_msg.type == ST_FIRMWARE_RESPONSE) {
|
||||||
if (_fwUpdateOngoing) {
|
if (_fwUpdateOngoing) {
|
||||||
// Save block to flash
|
// Save block to flash
|
||||||
setIndication(INDICATION_FW_UPDATE_RX);
|
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
|
// extract FW block
|
||||||
ReplyFWBlock *firmwareResponse = (ReplyFWBlock *)_msg.data;
|
ReplyFWBlock *firmwareResponse = (ReplyFWBlock *)_msg.data;
|
||||||
// write to flash
|
// write to flash
|
||||||
@@ -94,9 +100,10 @@ inline bool firmwareOTAUpdateProcess() {
|
|||||||
_fwBlock--;
|
_fwBlock--;
|
||||||
if (!_fwBlock) {
|
if (!_fwBlock) {
|
||||||
// We're finished! Do a checksum and reboot.
|
// We're finished! Do a checksum and reboot.
|
||||||
|
OTA_DEBUG(PSTR("OTA:FWP:FW END\n")); // received FW block
|
||||||
_fwUpdateOngoing = false;
|
_fwUpdateOngoing = false;
|
||||||
if (transportIsValidFirmware()) {
|
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)
|
// 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;
|
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),':'};
|
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();
|
hwReboot();
|
||||||
} else {
|
} else {
|
||||||
setIndication(INDICATION_ERR_FW_CHECKSUM);
|
setIndication(INDICATION_ERR_FW_CHECKSUM);
|
||||||
debug(PSTR("fw checksum fail\n"));
|
OTA_DEBUG(PSTR("!OTA:FWP:CRC FAIL\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// reset flags
|
// reset flags
|
||||||
_fwRetry = MY_OTA_RETRY+1;
|
_fwRetry = MY_OTA_RETRY+1;
|
||||||
_fwLastRequestTime = 0;
|
_fwLastRequestTime = 0;
|
||||||
} else {
|
} else {
|
||||||
debug(PSTR("No fw update ongoing\n"));
|
OTA_DEBUG(PSTR("!OTA:FWP:NO UPDATE\n"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void presentBootloaderInformation(){
|
void presentBootloaderInformation(){
|
||||||
RequestFirmwareConfig *reqFWConfig = (RequestFirmwareConfig *)_msgTmp.data;
|
RequestFirmwareConfig *reqFWConfig = (RequestFirmwareConfig *)_msgTmp.data;
|
||||||
mSetLength(_msgTmp, sizeof(RequestFirmwareConfig));
|
mSetLength(_msgTmp, sizeof(RequestFirmwareConfig));
|
||||||
mSetCommand(_msgTmp, C_STREAM);
|
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));
|
_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
|
// do a crc16 on the whole received firmware
|
||||||
inline bool transportIsValidFirmware() {
|
bool transportIsValidFirmware() {
|
||||||
// init crc
|
// init crc
|
||||||
uint16_t crc = ~0;
|
uint16_t crc = ~0;
|
||||||
for (uint16_t i = 0; i < _fc.blocks * FIRMWARE_BLOCK_SIZE; ++i) {
|
for (uint16_t i = 0; i < _fc.blocks * FIRMWARE_BLOCK_SIZE; ++i) {
|
||||||
|
|||||||
+74
-34
@@ -17,57 +17,95 @@
|
|||||||
* version 2 as published by the Free Software Foundation.
|
* 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:
|
||||||
|
* - <b>OTA</b> messages emitted by MyOTAFirmwareUpdate
|
||||||
|
* - SUB SYSTEMS:
|
||||||
|
* - OTA:<b>FRQ</b> from @ref firmwareOTAUpdateRequest()
|
||||||
|
* - OTA:<b>FWP</b> 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
|
#ifndef MyOTAFirmwareUpdate_h
|
||||||
#define MyOTAFirmwareUpdate_h
|
#define MyOTAFirmwareUpdate_h
|
||||||
|
|
||||||
#include "MySensorsCore.h"
|
#include "MySensorsCore.h"
|
||||||
|
|
||||||
// Size of each firmware block
|
#define FIRMWARE_BLOCK_SIZE (16) //!< Size of each firmware block
|
||||||
#define FIRMWARE_BLOCK_SIZE 16
|
#define FIRMWARE_MAX_REQUESTS (5) //!< Number of times a firmware block should be requested before giving up
|
||||||
// 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 FIRMWARE_MAX_REQUESTS 5
|
#define MY_OTA_RETRY_DELAY (500) //!< Number of milliseconds before re-requesting a FW block
|
||||||
// Number of times to request a fw block before giving up
|
#define FIRMWARE_START_OFFSET (10) //!< Start offset for firmware in flash (DualOptiboot wants to keeps a signature first)
|
||||||
#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 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 {
|
typedef struct {
|
||||||
uint16_t type; //!< Type of config
|
uint16_t type; //!< Type of config
|
||||||
uint16_t version; //!< Version of config
|
uint16_t version; //!< Version of config
|
||||||
uint16_t blocks; //!< Number of blocks
|
uint16_t blocks; //!< Number of blocks
|
||||||
uint16_t crc; //!< CRC of block data
|
uint16_t crc; //!< CRC of block data
|
||||||
} __attribute__((packed)) NodeFirmwareConfig;
|
} __attribute__((packed)) NodeFirmwareConfig;
|
||||||
|
|
||||||
/// @brief FW config request structure
|
/**
|
||||||
|
* @brief FW config request structure
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t type; //!< Type of config
|
uint16_t type; //!< Type of config
|
||||||
uint16_t version; //!< Version of config
|
uint16_t version; //!< Version of config
|
||||||
uint16_t blocks; //!< Number of blocks
|
uint16_t blocks; //!< Number of blocks
|
||||||
uint16_t crc; //!< CRC of block data
|
uint16_t crc; //!< CRC of block data
|
||||||
uint16_t BLVersion; //!< Bootloader version
|
uint16_t BLVersion; //!< Bootloader version
|
||||||
} __attribute__((packed)) RequestFirmwareConfig;
|
} __attribute__((packed)) RequestFirmwareConfig;
|
||||||
|
|
||||||
/// @brief FW block request structure
|
/**
|
||||||
|
* @brief FW block request structure
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t type; //!< Type of config
|
uint16_t type; //!< Type of config
|
||||||
uint16_t version; //!< Version of config
|
uint16_t version; //!< Version of config
|
||||||
uint16_t block; //!< Block index
|
uint16_t block; //!< Block index
|
||||||
} __attribute__((packed)) RequestFWBlock;
|
} __attribute__((packed)) RequestFWBlock;
|
||||||
|
|
||||||
/// @brief FW block reply structure
|
/**
|
||||||
|
* @brief FW block reply structure
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t type; //!< Type of config
|
uint16_t type; //!< Type of config
|
||||||
uint16_t version; //!< Version of config
|
uint16_t version; //!< Version of config
|
||||||
uint16_t block; //!< Block index
|
uint16_t block; //!< Block index
|
||||||
uint8_t data[FIRMWARE_BLOCK_SIZE]; //!< Block data
|
uint8_t data[FIRMWARE_BLOCK_SIZE]; //!< Block data
|
||||||
} __attribute__((packed)) ReplyFWBlock;
|
} __attribute__((packed)) ReplyFWBlock;
|
||||||
|
|
||||||
|
|
||||||
@@ -99,3 +137,5 @@ bool transportIsValidFirmware();
|
|||||||
void presentBootloaderInformation();
|
void presentBootloaderInformation();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** @}*/
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
* - MCO:<b>REG</b> from @ref _registerNode()
|
* - MCO:<b>REG</b> from @ref _registerNode()
|
||||||
* - MCO:<b>SND</b> from @ref send()
|
* - MCO:<b>SND</b> from @ref send()
|
||||||
* - MCO:<b>PIM</b> from @ref _processInternalMessages()
|
* - MCO:<b>PIM</b> from @ref _processInternalMessages()
|
||||||
* - MCO:<b>NLK</b> from @ref nodeLock()
|
* - MCO:<b>NLK</b> from nodeLock()
|
||||||
*
|
*
|
||||||
* MySensorsCore debug log messages:
|
* MySensorsCore debug log messages:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -147,6 +147,18 @@
|
|||||||
#else
|
#else
|
||||||
#define TRANSMISSION_FAILURES 5 //!< search for a new parent node after this many transmission failures, lower threshold for non-repeating nodes
|
#define TRANSMISSION_FAILURES 5 //!< search for a new parent node after this many transmission failures, lower threshold for non-repeating nodes
|
||||||
#endif
|
#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 TIMEOUT_FAILURE_STATE 10000 //!< duration failure state
|
||||||
#define STATE_TIMEOUT 2000 //!< general state timeout
|
#define STATE_TIMEOUT 2000 //!< general state timeout
|
||||||
#define STATE_RETRIES 3 //!< retries before switching to FAILURE
|
#define STATE_RETRIES 3 //!< retries before switching to FAILURE
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "drivers/AES/AES.h"
|
#include "drivers/AES/AES.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
typedef struct _transportQueuedMessage
|
typedef struct _transportQueuedMessage
|
||||||
{
|
{
|
||||||
uint8_t m_len; // Length of the data
|
uint8_t m_len; // Length of the data
|
||||||
@@ -82,7 +82,7 @@ bool transportInit() {
|
|||||||
memset(_psk, 0, 16);
|
memset(_psk, 0, 16);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
RF24_registerReceiveCallback( transportRxCallback );
|
RF24_registerReceiveCallback( transportRxCallback );
|
||||||
#endif
|
#endif
|
||||||
return RF24_initialize();
|
return RF24_initialize();
|
||||||
@@ -115,7 +115,7 @@ bool transportSend(uint8_t recipient, const void* data, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool transportAvailable() {
|
bool transportAvailable() {
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
(void)RF24_isDataAvailable; // Prevent 'defined but not used' warning
|
(void)RF24_isDataAvailable; // Prevent 'defined but not used' warning
|
||||||
return !transportRxQueue.empty();
|
return !transportRxQueue.empty();
|
||||||
#else
|
#else
|
||||||
@@ -129,10 +129,9 @@ bool transportSanityCheck() {
|
|||||||
|
|
||||||
uint8_t transportReceive(void* data) {
|
uint8_t transportReceive(void* data) {
|
||||||
uint8_t len = 0;
|
uint8_t len = 0;
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
transportQueuedMessage* msg = transportRxQueue.getBack();
|
transportQueuedMessage* msg = transportRxQueue.getBack();
|
||||||
if (msg)
|
if (msg) {
|
||||||
{
|
|
||||||
len = msg->m_len;
|
len = msg->m_len;
|
||||||
(void)memcpy(data, msg->m_data, len);
|
(void)memcpy(data, msg->m_data, len);
|
||||||
(void)transportRxQueue.popBack();
|
(void)transportRxQueue.popBack();
|
||||||
|
|||||||
+22
-24
@@ -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_BASE_ADDR[MY_RF24_ADDR_WIDTH] = { MY_RF24_BASE_RADIO_ID };
|
||||||
LOCAL uint8_t MY_RF24_NODE_ADDRESS = AUTO;
|
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;
|
LOCAL RF24_receiveCallbackType RF24_receiveCallback = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ LOCAL uint8_t RF24_spiByteTransfer(uint8_t cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOCAL uint8_t RF24_RAW_readByteRegister(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);
|
RF24_DEBUG(PSTR("RF24:read register, reg=%d, value=%d\n"), cmd & (R_REGISTER ^ 0xFF), value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ LOCAL uint8_t RF24_getStatus(void) {
|
|||||||
return RF24_spiByteTransfer( NOP );
|
return RF24_spiByteTransfer( NOP );
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCAL uint8_t RF24_getFifoStatus(void) {
|
LOCAL uint8_t RF24_getFIFOStatus(void) {
|
||||||
return RF24_readByteRegister(FIFO_STATUS);
|
return RF24_readByteRegister(FIFO_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +138,10 @@ LOCAL void RF24_setPipeLSB(uint8_t pipe, uint8_t LSB) {
|
|||||||
RF24_writeByteRegister(pipe, LSB);
|
RF24_writeByteRegister(pipe, LSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL uint8_t RF24_getObserveTX(void) {
|
||||||
|
return RF24_readByteRegister(OBSERVE_TX);
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL void RF24_setStatus(uint8_t status) {
|
LOCAL void RF24_setStatus(uint8_t status) {
|
||||||
RF24_writeByteRegister(RF24_STATUS, 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
|
// flush TX FIFO
|
||||||
RF24_flushTX();
|
RF24_flushTX();
|
||||||
// this command is affected in clones (e.g. Si24R1): flipped NoACK bit when using W_TX_PAYLOAD_NO_ACK / W_TX_PAYLOAD
|
// 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 );
|
// AutoACK is disabled on the broadcasting pipe - NO_ACK prevents resending
|
||||||
// we are safe by disabling AutoACK on the broadcasting pipe
|
RF24_spiMultiByteTransfer(recipient == BROADCAST_ADDRESS ? W_TX_PAYLOAD_NO_ACK : W_TX_PAYLOAD, (uint8_t*)buf, len, false );
|
||||||
RF24_spiMultiByteTransfer( W_TX_PAYLOAD, (uint8_t*)buf, len, false );
|
|
||||||
// go, TX starts after ~10us
|
// go, TX starts after ~10us
|
||||||
RF24_ce(HIGH);
|
RF24_ce(HIGH);
|
||||||
// timeout counter to detect HW issues
|
// 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_DEBUG(PSTR("RF24:MAX_RT\n"));
|
||||||
RF24_flushTX();
|
RF24_flushTX();
|
||||||
}
|
}
|
||||||
|
|
||||||
RF24_startListening();
|
RF24_startListening();
|
||||||
// true if message sent and not timeout
|
// true if message sent
|
||||||
return (status & _BV(TX_DS) && timeout);
|
return ( status & _BV(TX_DS) );
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCAL uint8_t RF24_getDynamicPayloadSize(void) {
|
LOCAL uint8_t RF24_getDynamicPayloadSize(void) {
|
||||||
@@ -224,15 +226,13 @@ LOCAL uint8_t RF24_getDynamicPayloadSize(void) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOCAL bool RF24_isDataAvailable() {
|
LOCAL bool RF24_isDataAvailable() {
|
||||||
uint8_t status = RF24_getStatus();
|
return ( !(RF24_getFIFOStatus() & _BV(0)) );
|
||||||
return (((status >> RX_P_NO) & 0b0111) <= 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOCAL uint8_t RF24_readMessage( void* buf) {
|
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_DEBUG(PSTR("RF24:read message, len=%d\n"), len);
|
||||||
RF24_spiMultiByteTransfer( R_RX_PAYLOAD , (uint8_t*)buf, len, true );
|
RF24_spiMultiByteTransfer( R_RX_PAYLOAD , (uint8_t*)buf, len, true );
|
||||||
// clear RX interrupt
|
// clear RX interrupt
|
||||||
@@ -256,12 +256,10 @@ LOCAL uint8_t RF24_getNodeID(void) {
|
|||||||
|
|
||||||
LOCAL bool RF24_sanityCheck(void) {
|
LOCAL bool RF24_sanityCheck(void) {
|
||||||
// detect HW defect, configuration errors or interrupted SPI line, CE disconnect cannot be detected
|
// detect HW defect, configuration errors or interrupted SPI line, CE disconnect cannot be detected
|
||||||
bool status = RF24_readByteRegister(RF_SETUP) == MY_RF24_RF_SETUP;
|
return (RF24_readByteRegister(RF_SETUP) == MY_RF24_RF_SETUP) & (RF24_readByteRegister(RF_CH) == MY_RF24_CHANNEL);
|
||||||
status &= RF24_readByteRegister(RF_CH) == MY_RF24_CHANNEL;
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
LOCAL void RF24_irqHandler( void )
|
LOCAL void RF24_irqHandler( void )
|
||||||
{
|
{
|
||||||
if (RF24_receiveCallback)
|
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
|
// Start checking if RX-FIFO is not empty, as we might end up here from an interrupt
|
||||||
// for a message we've already read.
|
// 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 !
|
RF24_receiveCallback(); // Must call RF24_readMessage(), which will clear RX_DR IRQ !
|
||||||
}
|
}
|
||||||
// Restore our interrupt handler.
|
// 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 {
|
MY_CRITICAL_SECTION {
|
||||||
RF24_receiveCallback = cb;
|
RF24_receiveCallback = cb;
|
||||||
}
|
}
|
||||||
@@ -304,25 +301,26 @@ LOCAL void RF24_registerReceiveCallback( RF24_receiveCallbackType cb )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOCAL bool RF24_initialize(void) {
|
LOCAL bool RF24_initialize(void) {
|
||||||
|
// prevent warning
|
||||||
|
(void)RF24_getObserveTX;
|
||||||
|
|
||||||
// Initialize pins
|
// Initialize pins
|
||||||
pinMode(MY_RF24_CE_PIN,OUTPUT);
|
pinMode(MY_RF24_CE_PIN,OUTPUT);
|
||||||
pinMode(MY_RF24_CS_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);
|
pinMode(MY_RF24_IRQ_PIN,INPUT);
|
||||||
#endif
|
#endif
|
||||||
// Initialize SPI
|
// Initialize SPI
|
||||||
_SPI.begin();
|
_SPI.begin();
|
||||||
RF24_ce(LOW);
|
RF24_ce(LOW);
|
||||||
RF24_csn(HIGH);
|
RF24_csn(HIGH);
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
// assure SPI can be used from interrupt context
|
// assure SPI can be used from interrupt context
|
||||||
// Note: ESP8266 & SoftSPI currently do not support interrupt usage for SPI,
|
// Note: ESP8266 & SoftSPI currently do not support interrupt usage for SPI,
|
||||||
// therefore it is unsafe to use MY_RF24_IRQ_PIN with ESP8266/SoftSPI!
|
// therefore it is unsafe to use MY_RF24_IRQ_PIN with ESP8266/SoftSPI!
|
||||||
_SPI.usingInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN));
|
_SPI.usingInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN));
|
||||||
// attach interrupt
|
// attach interrupt
|
||||||
attachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN), RF24_irqHandler, FALLING);
|
attachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN), RF24_irqHandler, FALLING);
|
||||||
#else
|
|
||||||
(void)RF24_getFifoStatus; // prevent 'defined but not used' warning
|
|
||||||
#endif
|
#endif
|
||||||
// CRC and power up
|
// CRC and power up
|
||||||
RF24_setRFConfiguration(MY_RF24_CONFIGURATION | _BV(PWR_UP) ) ;
|
RF24_setRFConfiguration(MY_RF24_CONFIGURATION | _BV(PWR_UP) ) ;
|
||||||
|
|||||||
+28
-7
@@ -34,13 +34,10 @@
|
|||||||
#define MY_RF24_SPI_DATA_MODE SPI_MODE0
|
#define MY_RF24_SPI_DATA_MODE SPI_MODE0
|
||||||
|
|
||||||
#if defined (ARDUINO) && !defined (__arm__) && !defined (_SPI)
|
#if defined (ARDUINO) && !defined (__arm__) && !defined (_SPI)
|
||||||
|
#include <SPI.h>
|
||||||
#if defined(MY_SOFTSPI)
|
#if defined(MY_SOFTSPI)
|
||||||
SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
|
SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
|
||||||
#elif defined(ARDUINO_ARCH_SAMD)
|
|
||||||
#include <SPI.h>
|
|
||||||
#define _SPI SPI1
|
|
||||||
#else
|
#else
|
||||||
#include <SPI.h>
|
|
||||||
#define _SPI SPI
|
#define _SPI SPI
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@@ -61,8 +58,31 @@
|
|||||||
#endif
|
#endif
|
||||||
#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
|
// 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))
|
#define MY_RF24_CONFIGURATION (uint8_t) ((RF24_CRC_16 << 2) | (1 << MASK_TX_DS) | (1 << MASK_MAX_RT))
|
||||||
#else
|
#else
|
||||||
#define MY_RF24_CONFIGURATION (uint8_t) (RF24_CRC_16 << 2)
|
#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_flushRX(void);
|
||||||
LOCAL void RF24_flushTX(void);
|
LOCAL void RF24_flushTX(void);
|
||||||
LOCAL uint8_t RF24_getStatus(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_openWritingPipe(uint8_t recipient);
|
||||||
LOCAL void RF24_startListening(void);
|
LOCAL void RF24_startListening(void);
|
||||||
LOCAL void RF24_stopListening(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_setRFConfiguration(uint8_t configuration);
|
||||||
LOCAL void RF24_setPipeAddress(uint8_t pipe, uint8_t* address, uint8_t width);
|
LOCAL void RF24_setPipeAddress(uint8_t pipe, uint8_t* address, uint8_t width);
|
||||||
LOCAL void RF24_setPipeLSB(uint8_t pipe, uint8_t LSB);
|
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_setStatus(uint8_t status);
|
||||||
LOCAL void RF24_enableFeatures(void);
|
LOCAL void RF24_enableFeatures(void);
|
||||||
|
|
||||||
#ifdef MY_RF24_IRQ_PIN
|
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||||
typedef void (*RF24_receiveCallbackType)(void);
|
typedef void (*RF24_receiveCallbackType)(void);
|
||||||
/**
|
/**
|
||||||
* Register a callback, which will be called (from interrupt context) for every message received.
|
* Register a callback, which will be called (from interrupt context) for every message received.
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_MQ 0
|
#define CHILD_ID_MQ 0
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define SKETCH_NAME "Binary Sensor"
|
#define SKETCH_NAME "Binary Sensor"
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_AIQ 0
|
#define CHILD_ID_AIQ 0
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
// load core modules only
|
// load core modules only
|
||||||
#define MY_CORE_ONLY
|
#define MY_CORE_ONLY
|
||||||
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define SN "DimmableLED"
|
#define SN "DimmableLED"
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_LIGHT 1
|
#define CHILD_ID_LIGHT 1
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_DUST 0
|
#define CHILD_ID_DUST 0
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_DUST_PM10 0
|
#define CHILD_ID_DUST_PM10 0
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
||||||
|
|||||||
@@ -65,8 +65,6 @@
|
|||||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
// Enable debug prints to serial monitor
|
// Enable debug prints to serial monitor
|
||||||
#define MY_DEBUG
|
#define MY_DEBUG
|
||||||
|
|||||||
@@ -57,8 +57,6 @@
|
|||||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
// Enable debug prints to serial monitor
|
// Enable debug prints to serial monitor
|
||||||
#define MY_DEBUG
|
#define MY_DEBUG
|
||||||
|
|||||||
@@ -66,8 +66,6 @@
|
|||||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
// Enable debug prints to serial monitor
|
// Enable debug prints to serial monitor
|
||||||
|
|||||||
@@ -82,7 +82,6 @@
|
|||||||
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
|
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
|
||||||
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
|
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@
|
|||||||
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
|
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
|
||||||
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
|
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|||||||
@@ -109,7 +109,6 @@
|
|||||||
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
|
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
|
||||||
//#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
|
//#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
#if defined(MY_USE_UDP)
|
#if defined(MY_USE_UDP)
|
||||||
#include <EthernetUdp.h>
|
#include <EthernetUdp.h>
|
||||||
|
|||||||
@@ -57,7 +57,6 @@
|
|||||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
// Enable debug prints to serial monitor
|
// Enable debug prints to serial monitor
|
||||||
#define MY_DEBUG
|
#define MY_DEBUG
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define CHILD_ID_LIGHT 0
|
#define CHILD_ID_LIGHT 0
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#define MY_NODE_ID 254
|
#define MY_NODE_ID 254
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define RADIO_ERROR_LED_PIN 4 // Error led pin
|
#define RADIO_ERROR_LED_PIN 4 // Error led pin
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
// Set RS485 baud rate to use
|
// Set RS485 baud rate to use
|
||||||
#define MY_RS485_BAUD_RATE 9600
|
#define MY_RS485_BAUD_RATE 9600
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
|
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
#include "MYSLog.h"
|
#include "MYSLog.h"
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
// Enable repeater functionality for this node
|
// Enable repeater functionality for this node
|
||||||
#define MY_REPEATER_FEATURE
|
#define MY_REPEATER_FEATURE
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
|
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
// Enabled repeater feature for this node
|
// Enabled repeater feature for this node
|
||||||
#define MY_REPEATER_FEATURE
|
#define MY_REPEATER_FEATURE
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|||||||
@@ -58,7 +58,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@
|
|||||||
// SETTINGS FOR MY_SIGNING_ATSHA204
|
// SETTINGS FOR MY_SIGNING_ATSHA204
|
||||||
#define MY_SIGNING_ATSHA204_PIN 17 //!< A3 - pin where ATSHA204 is attached
|
#define MY_SIGNING_ATSHA204_PIN 17 //!< A3 - pin where ATSHA204 is attached
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,6 @@
|
|||||||
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
|
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
|
||||||
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
|
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
#include <drivers/ATSHA204/ATSHA204.cpp>
|
#include <drivers/ATSHA204/ATSHA204.cpp>
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <math.h> // Conversion equation from resistance to %
|
#include <math.h> // Conversion equation from resistance to %
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
// Setting up format for reading 3 soil sensors
|
// Setting up format for reading 3 soil sensors
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define UV_SENSOR_ANALOG_PIN 0
|
#define UV_SENSOR_ANALOG_PIN 0
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#define MY_RADIO_NRF24
|
#define MY_RADIO_NRF24
|
||||||
//#define MY_RADIO_RFM69
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!)
|
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!)
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ MY_RF24_SPI_MAX_SPEED LITERAL1
|
|||||||
MY_RF24_CE_PIN LITERAL1
|
MY_RF24_CE_PIN LITERAL1
|
||||||
MY_RF24_CS_PIN LITERAL1
|
MY_RF24_CS_PIN LITERAL1
|
||||||
MY_RF24_IRQ_PIN LITERAL1
|
MY_RF24_IRQ_PIN LITERAL1
|
||||||
|
MY_RX_MESSAGE_BUFFER_FEATURE LITERAL1
|
||||||
MY_RF24_PA_LEVEL LITERAL1
|
MY_RF24_PA_LEVEL LITERAL1
|
||||||
MY_RF24_CHANNEL LITERAL1
|
MY_RF24_CHANNEL LITERAL1
|
||||||
MY_RF24_DATARATE LITERAL1
|
MY_RF24_DATARATE LITERAL1
|
||||||
|
|||||||
-1
@@ -34,5 +34,4 @@
|
|||||||
#define MY_SIGNING_ATSHA204_PIN 17
|
#define MY_SIGNING_ATSHA204_PIN 17
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -34,5 +34,4 @@
|
|||||||
#define MY_SIGNING_ATSHA204_PIN 17
|
#define MY_SIGNING_ATSHA204_PIN 17
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -35,5 +35,4 @@
|
|||||||
#endif
|
#endif
|
||||||
#define MY_NODE_LOCK_FEATURE
|
#define MY_NODE_LOCK_FEATURE
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -35,5 +35,4 @@
|
|||||||
#endif
|
#endif
|
||||||
#define MY_RF24_ENABLE_ENCRYPTION
|
#define MY_RF24_ENABLE_ENCRYPTION
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -35,5 +35,4 @@
|
|||||||
#endif
|
#endif
|
||||||
#define MY_RFM69_ENABLE_ENCRYPTION
|
#define MY_RFM69_ENABLE_ENCRYPTION
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -34,5 +34,4 @@
|
|||||||
#define MY_SIGNING_ATSHA204_PIN 17
|
#define MY_SIGNING_ATSHA204_PIN 17
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
-1
@@ -34,5 +34,4 @@
|
|||||||
#define MY_SIGNING_ATSHA204_PIN 17
|
#define MY_SIGNING_ATSHA204_PIN 17
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user