WIP
This commit is contained in:
@@ -19,9 +19,16 @@
|
||||
// Note: You can still have OTA FW updates without external flash but it
|
||||
// requires the MYSBootloader and disabled MY_OTA_FIRMWARE_FEATURE
|
||||
#define MY_OTA_FIRMWARE_FEATURE
|
||||
|
||||
// Slave select pin for external flash
|
||||
#define MY_OTA_FLASH_SS 8
|
||||
// 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
|
||||
// Bootloader version
|
||||
#define MY_OTA_BOOTLOADER_MAJOR_VERSION 2
|
||||
#define MY_OTA_BOOTLOADER_MINOR_VERSION 0
|
||||
#define MY_OTA_BOOTLOADER_VERSION (MY_OTA_BOOTLOADER_MINOR_VERSION * 256 + MY_OTA_BOOTLOADER_MAJOR_VERSION)
|
||||
|
||||
|
||||
/**********************************
|
||||
|
||||
@@ -57,7 +57,7 @@ MySensor::MySensor(MyTransport &_radio, MyHw &_hw
|
||||
|
||||
#ifdef MY_OTA_FRIMWARE_FEATURE
|
||||
// do a crc16 on the whole received firmware
|
||||
static uint8_t MySensor::isValidFirmware() {
|
||||
bool MySensor::isValidFirmware() {
|
||||
void* ptr = 0;
|
||||
uint16_t crc = ~0;
|
||||
int j;
|
||||
@@ -188,6 +188,33 @@ void MySensor::setupNode() {
|
||||
|
||||
// Wait configuration reply.
|
||||
wait(2000);
|
||||
|
||||
#ifdef MY_OTA_FRIMWARE_FEATURE
|
||||
RequestFirmwareConfig *reqFWConfig = (RequestFirmwareConfig *)msg.data;
|
||||
mSetLength(msg, sizeof(RequestFirmwareConfig));
|
||||
mSetCommand(msg, C_STREAM);
|
||||
mSetPayloadType(msg,P_CUSTOM);
|
||||
// copy node settings to reqFWConfig
|
||||
memcpy(reqFWConfig,&fc,sizeof(NodeFirmwareConfig));
|
||||
// add bootloader information
|
||||
reqFWConfig->BLVersion = MYSBOOTLOADER_VERSION;
|
||||
|
||||
// send node config and request FW config from controller
|
||||
if (!sendAndWait(ST_FIRMWARE_CONFIG_REQUEST, ST_FIRMWARE_CONFIG_RESPONSE)) {
|
||||
startup();
|
||||
}
|
||||
|
||||
NodeFirmwareConfig *firmwareConfigResponse = (NodeFirmwareConfig *)inMsg.data;
|
||||
|
||||
// compare with current node configuration, if equal startup
|
||||
if (!memcmp(&fc,firmwareConfigResponse,sizeof(NodeFirmwareConfig))) {
|
||||
startup();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,6 +309,12 @@ class MySensor
|
||||
void (*timeCallback)(unsigned long); // Callback for requested time messages
|
||||
void (*msgCallback)(const MyMessage &); // Callback for incoming messages from other nodes and gateway.
|
||||
|
||||
#ifdef MY_OTA_FRIMWARE_FEATURE
|
||||
// do a crc16 on the whole received firmware
|
||||
bool isValidFirmware();
|
||||
#endif
|
||||
|
||||
|
||||
void requestNodeId();
|
||||
void setupNode();
|
||||
void findParentNode();
|
||||
|
||||
Reference in New Issue
Block a user