MySensors bootloader supporting over-the-air firmware updates
All initialization the bootloader does (finding parent / requesting nodeId on first start) uses the same packets as a normal MySensors sketch. There is no need for the controller to distinguish between packets from the bootloader and packets from normal sketch execution. The controller only needs to care about two additional request/response communications. All communication is binary.- the bootloader sends a RequestFirmwareConfig packet to the gateway to request information about the firmware it should execute:
typedef struct {
uint16_t type;
uint16_t version;
uint16_t blocks;
uint16_t crc;
uint16_t BLVersion;
} RequestFirmwareConfig;
- the gateway (the controller) responds with a NodeFirmwareConfig including details about the firmware the sensor should execute:
typedef struct {
uint16_t type;
uint16_t version;
uint16_t blocks;
uint16_t crc;
} NodeFirmwareConfig;
- the bootloader sends a RequestFirmwareBlock packet to the gateway to request a specific subset (block) of the compiled firmware:
typedef struct {
uint16_t type;
uint16_t version;
uint16_t block;
} RequestFirmwareBlock;
- the gateway (the controller) responds with a ResponseFirmwareBlock including the specific block of the compiled firmware:
typedef struct {
uint16_t type;
uint16_t version;
uint16_t block;
uint8_t data[FIRMWARE_BLOCK_SIZE];
} ResponseFirmwareBlock;