// // Created by jedi on 13.09.22. // namespace fiatlux { namespace messages { enum id : uint8_t { NONE = 0, RESTART, CLEAR_CONFIG, FIRMWARE_FRAME, FIRMWARE_CHECK, VOLTAGE_INFO, SYSTEM_INFO, count }; const char* id_to_string(id val){ static const char* lookup[] = { "NONE", "RESTART", "CLEAR_CONFIG", "FIRMWARE_FRAME", "FIRMWARE_CHECK", "VOLTAGE_INFO", "SYSTEM_INFO", "out of range" }; if(val < id::count) return lookup[val]; else return lookup[id::count]; } template struct frame { id cmd; T msg; } __attribute__((packed)); struct fw_frame { char t; uint8_t reserved[3]; uint16_t seq; uint16_t len; uint32_t hash; uint8_t data[]; } __attribute__((packed)); struct fw_check { char t; uint8_t reserved[3]; uint32_t len; uint32_t hash; } __attribute__((packed)); struct system_info { unsigned walltime; unsigned uptime; int heap; uint32_t chipid; uint32_t flashid; uint32_t flashsize; /* " \"hostname\" : \"%s\"" "}" */ } __attribute__((packed)); struct response { id cmd; uint8_t ret; uint16_t val; } __attribute__((packed)); } }