93 lines
No EOL
2.2 KiB
C++
93 lines
No EOL
2.2 KiB
C++
//
|
|
// 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,
|
|
LIGHTS,
|
|
LIGHT_CONFIG,
|
|
count
|
|
};
|
|
|
|
const char *id_to_string(id val) {
|
|
static const char *lookup[] = {
|
|
"NONE",
|
|
"RESTART",
|
|
"CLEAR_CONFIG",
|
|
"FIRMWARE_FRAME",
|
|
"FIRMWARE_CHECK",
|
|
"VOLTAGE_INFO",
|
|
"SYSTEM_INFO",
|
|
"LIGHTS",
|
|
"LIGHT_CONFIG",
|
|
"out of range"
|
|
};
|
|
if(val < id::count)
|
|
return lookup[val];
|
|
else
|
|
return lookup[id::count];
|
|
}
|
|
|
|
template<typename T>
|
|
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 {
|
|
uint32_t walltime;
|
|
uint32_t uptime;
|
|
int32_t heap;
|
|
uint32_t chipid;
|
|
uint32_t flashid;
|
|
uint32_t flashsize;
|
|
uint16_t version;
|
|
uint16_t peripheral_version;
|
|
|
|
/*
|
|
" \"hostname\" : \"%s\""
|
|
"}"
|
|
*/
|
|
} __attribute__((packed));
|
|
|
|
struct response {
|
|
id cmd;
|
|
uint8_t ret;
|
|
uint16_t val;
|
|
} __attribute__((packed));
|
|
|
|
struct lights {
|
|
uint32_t top_color;
|
|
uint32_t bottom_color;
|
|
uint16_t white_brightness;
|
|
} __attribute__((packed));
|
|
|
|
struct light_config {
|
|
int32_t led_amount;
|
|
} __attribute__((packed));
|
|
}
|
|
} |