22#if (MODULE_MEGAWIFI != 0)
25#define PACKED __attribute__((__packed__))
28#define MW_MSG_MAX_BUFLEN 512
31#define MW_CMD_HEADLEN (2 * sizeof(uint16_t))
34#define MW_CMD_MAX_BUFLEN (MW_MSG_MAX_BUFLEN - MW_CMD_HEADLEN)
37#define MW_SSID_MAXLEN 32
39#define MW_PASS_MAXLEN 64
42#define MW_GT_NICKNAME_MAX 32
44#define MW_GT_SECURITY_MAX 32
46#define MW_GT_TAGLINE_MAX 32
48#define MW_GT_AVATAR_WIDTH 32
50#define MW_GT_AVATAR_HEIGHT 48
52#define MW_GT_TG_TOKEN_MAX 64
55enum PACKED mw_command {
61 MW_CMD_AP_CFG_GET = 5,
62 MW_CMD_IP_CURRENT = 6,
65 MW_CMD_IP_CFG_GET = 9,
66 MW_CMD_DEF_AP_CFG = 10,
67 MW_CMD_DEF_AP_CFG_GET = 11,
76 MW_CMD_SOCK_STAT = 20,
79 MW_CMD_SNTP_CFG_GET = 23,
82 MW_CMD_FLASH_WRITE = 26,
83 MW_CMD_FLASH_READ = 27,
84 MW_CMD_FLASH_ERASE = 28,
87 MW_CMD_DEF_CFG_SET = 31,
89 MW_CMD_BSSID_GET = 33,
90 MW_CMD_GAMERTAG_SET = 34,
91 MW_CMD_GAMERTAG_GET = 35,
93 MW_CMD_FACTORY_RESET = 37,
95 MW_CMD_HTTP_URL_SET = 39,
96 MW_CMD_HTTP_METHOD_SET = 40,
97 MW_CMD_HTTP_CERT_QUERY = 41,
98 MW_CMD_HTTP_CERT_SET = 42,
99 MW_CMD_HTTP_HDR_ADD = 43,
100 MW_CMD_HTTP_HDR_DEL = 44,
101 MW_CMD_HTTP_OPEN = 45,
102 MW_CMD_HTTP_FINISH = 46,
103 MW_CMD_HTTP_CLEANUP = 47,
105 MW_CMD_SERVER_URL_GET = 49,
106 MW_CMD_SERVER_URL_SET = 50,
107 MW_CMD_WIFI_ADV_GET = 51,
108 MW_CMD_WIFI_ADV_SET = 52,
109 MW_CMD_NV_CFG_SAVE = 53,
110 MW_CMD_UPGRADE_LIST = 54,
111 MW_CMD_UPGRADE_PERFORM = 55,
112 MW_CMD_GAME_ENDPOINT_SET = 56,
113 MW_CMD_GAME_KEYVAL_ADD = 57,
114 MW_CMD_GAME_REQUEST = 58,
119enum PACKED mw_security {
129enum PACKED mw_phy_type {
142struct mw_msg_in_addr {
154 union ip_addr gateway;
163struct mw_msg_ap_cfg {
165 enum mw_phy_type phy_type;
166 char ssid[MW_SSID_MAXLEN];
167 char pass[MW_PASS_MAXLEN];
171struct mw_msg_ip_cfg {
178struct mw_msg_sntp_cfg {
184 char servers[MW_CMD_MAX_BUFLEN - 4];
188struct mw_msg_date_time {
191 char dt_str[MW_CMD_MAX_BUFLEN - 2 *
sizeof(uint32_t)];
195struct mw_msg_flash_data {
198 uint8_t data[MW_CMD_MAX_BUFLEN -
sizeof(uint32_t)];
202struct mw_msg_flash_range {
215struct mw_wifi_adv_cfg {
217 uint8_t ampdu_rx_enable;
219 uint8_t rx_ampdu_buf_num;
220 uint32_t rx_ampdu_buf_len;
221 uint32_t rx_max_single_pkt_len;
223 uint8_t amsdu_rx_enable;
226 uint8_t left_continuous_rx_buf_num;
236 char nickname[MW_GT_NICKNAME_MAX];
238 char security[MW_GT_SECURITY_MAX];
240 char tagline[MW_GT_TAGLINE_MAX];
242 char tg_token[MW_GT_TG_TOKEN_MAX];
244 uint8_t avatar_tiles[MW_GT_AVATAR_WIDTH * MW_GT_AVATAR_HEIGHT / 2];
246 uint8_t avatar_pal[32];
250struct mw_gamertag_set_msg {
253 struct mw_gamertag gamertag;
276union mw_msg_sys_stat {
279#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
280 enum mw_state sys_stat:8;
294 enum mw_state sys_stat:8;
302 uint8_t manufacturer;
306struct mw_ga_request {
309 uint8_t num_kv_pairs;
314typedef union mw_cmd {
315 char packet[MW_CMD_MAX_BUFLEN + 2 *
sizeof(uint16_t)];
324 uint8_t data[MW_CMD_MAX_BUFLEN];
326 uint16_t w_data[MW_CMD_MAX_BUFLEN /
sizeof(uint16_t)];
328 uint32_t dw_data[MW_CMD_MAX_BUFLEN /
sizeof(uint32_t)];
329 struct mw_msg_in_addr in_addr;
330 struct mw_msg_ap_cfg ap_cfg;
331 struct mw_msg_ip_cfg ip_cfg;
332 struct mw_msg_sntp_cfg sntp_cfg;
333 struct mw_msg_date_time date_time;
334 struct mw_msg_flash_data fl_data;
335 struct mw_msg_flash_range fl_range;
336 struct mw_msg_bind bind;
337 union mw_msg_sys_stat sys_stat;
338 struct mw_gamertag_set_msg gamertag_set;
339 struct mw_gamertag gamertag_get;
340 struct mw_wifi_adv_cfg wifi_adv_cfg;
341 struct mw_flash_id flash_id;
342 struct mw_ga_request ga_request;
356struct mw_reuse_payload {
358 uint16_t remote_port;
360 char payload[MW_CMD_MAX_BUFLEN - 4 - 2];