#pragma once #include #include "zaf_ecode.h" #include "zaf_port.h" #include "zaf_regs.hpp" #pragma pack(1) #define VERSION(main, sub, fix) (main << 16 | sub << 8 | fix << 0) #define VERSION_MAIN(v) ((v >> 16) & 0xFF) #define VERSION_SUB(v) ((v >> 8) & 0xFF) #define VERSION_FIX(v) ((v >> 0) & 0xFF) #define PACKET_HEADER 0x5A5A #define PACKET_TAIL 0xA5A5 typedef struct { uint16_t packet_header; uint16_t packet_type; // zaf_protocol_packet_type_t uint16_t index; // uint16_t cmd; // zaf_protocol_cmd_t uint16_t ndata; // uint32_t data[]; // first is always checksum } zaf_packet_header_t; #pragma pack() /** * @brief CMD */ typedef enum { kzaf_cmd_none = 0, kzaf_cmd_reg_read = 1, kzaf_cmd_reg_write = 2, kzaf_cmd_reg_read_regs = 3, kzaf_cmd_generator_new_mac = 4, kzaf_cmd_factory_reset = 5, kzaf_cmd_reboot = 6, kzaf_cmd_storage_cfg = 7, } zaf_protocol_cmd_t; typedef enum { kzaf_packet_type_cmd = 0, kzaf_packet_type_receipt = 1, kzaf_packet_type_report = 2, kzaf_packet_type_heart = 3, } zaf_protocol_packet_type_t; typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1, } obtaining_ip_mode_t; static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) { switch (mode) { case obtaining_ip_mode_type_static: return "static"; case obtaining_ip_mode_type_dhcp: return "dhcp"; default: return "unknown"; } }