#ifndef MESSAGE_STRUCTS_H #define MESSAGE_STRUCTS_H #include #include #include #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X" typedef enum { OTA_PREPARE_FOR_UPDATE, OTA_PREPARE_ACKNOWLEDGED, OTA_READY_TO_RECEIVE, OTA_CHUNK, OTA_REQUEST_BLOCK_STATUS, OTA_BLOCK_STATUS_REPORT, OTA_COMMIT_BLOCK, OTA_BLOCK_COMMITTED, OTA_FINISH_UPDATE, OTA_UPDATE_STATUS, OTA_UPDATE_SLAVE_ACKED, MASTER_READY_TO_SEND_CHUNKS, StatusPage, GetStatusPage, ConfigPage, PingPage, BroadCastPage, RegisterPage, } CommandPages; typedef struct __attribute__((packed)) { uint32_t total_size; uint32_t block_size; } OTA_PREPARE_FOR_UPDATE_Payload; typedef struct __attribute__((packed)) { // Empty } OTA_PREPARE_ACKNOWLEDGED_Payload; typedef struct __attribute__((packed)) { uint8_t status; // 0 = READY, 1 = ERROR } OTA_READY_TO_RECEIVE_Payload; typedef struct __attribute__((packed)) { uint16_t block_id; uint8_t chunk_id; uint8_t data_len; uint8_t data[200]; } OTA_CHUNK_Payload; typedef struct __attribute__((packed)) { uint16_t block_id; } OTA_REQUEST_BLOCK_STATUS_Payload; typedef struct __attribute__((packed)) { uint16_t block_id; uint32_t chunk_bitmask; } OTA_BLOCK_STATUS_REPORT_Payload; typedef struct __attribute__((packed)) { uint16_t block_id; } OTA_COMMIT_BLOCK_Payload; typedef struct __attribute__((packed)) { uint16_t block_id; } OTA_BLOCK_COMMITTED_Payload; typedef struct __attribute__((packed)) { // Empty } OTA_FINISH_UPDATE_Payload; typedef struct __attribute__((packed)) { uint8_t status; // 0 = SUCCESS, 1 = FAILED } OTA_UPDATE_STATUS_Payload; typedef struct __attribute__((packed)) { uint16_t current_block_id; uint16_t update_buffer_write_index; uint32_t update_size; uint16_t sequenz_counter; // how often the update buffer gets written uint8_t status; // 0 = SUCCESS, 1 = FAILED } OTA_UPDATE_ACK_Payload; typedef struct __attribute__((packed)) { uint16_t version; // software version uint8_t runningPartition; uint8_t status; uint32_t uptime; } StatusPayload; typedef struct __attribute__((packed)) { } GetStatusPayload; typedef struct __attribute__((packed)) { uint8_t timeslot; } ConfigPayload; typedef struct __attribute__((packed)) { uint32_t timestamp; } PingPayload; typedef struct __attribute__((packed)) { } BroadCastPayload; typedef struct __attribute__((packed)) { bool familierClient; } RegisterPayload; // TODO: Check checksum fields typedef struct __attribute__((packed)) { uint16_t length; // length of complete firmware uint8_t checksum; // checksum of firmware } FirmwarePrepPayload; // TODO: Check checksum fields typedef struct __attribute__((packed)) { uint8_t length; uint8_t checksum; uint32_t address; uint8_t payload[240]; // TODO: need a way to figure out a safe value for this } FirmwarePayload; #endif // MESSAGE_STRUCTS_H