MegaWiFi 1.5
MegaWiFi API documentation
mw-msg.h File Reference

MegaWiFi command message definitions. More...

#include <stdint.h>
#include "util.h"

Go to the source code of this file.

Data Structures

union  ip_addr
 IPv4 address. More...
 
struct  mw_msg_in_addr
 TCP/UDP address message. More...
 
struct  mw_ip_cfg
 IP configuration parameters. More...
 
struct  mw_msg_ap_cfg
 AP configuration message. More...
 
struct  mw_msg_ip_cfg
 IP configuration message. More...
 
struct  mw_msg_sntp_cfg
 SNTP and timezone configuration. More...
 
struct  mw_msg_date_time
 Date and time message. More...
 
struct  mw_msg_flash_data
 Flash memory address and data. More...
 
struct  mw_msg_flash_range
 Flash memory block. More...
 
struct  mw_msg_bind
 Bind message data. More...
 
struct  mw_wifi_adv_cfg
 Advanced WiFi configuration. More...
 
struct  mw_gamertag
 Gamertag data. More...
 
struct  mw_gamertag_set_msg
 Gamertag set message data. More...
 
union  mw_msg_sys_stat
 System status. More...
 
struct  mw_flash_id
 Flash chip identifiers. More...
 
struct  mw_ga_request
 Game API request. More...
 
union  mw_cmd
 Command sent to system FSM. More...
 
struct  mw_reuse_payload
 Payload with remote IP and port. More...
 

Macros

#define MW_MSG_MAX_BUFLEN   512
 Maximum buffer length (bytes) More...
 
#define MW_CMD_HEADLEN   (2 * sizeof(uint16_t))
 Command header length (command code and data length fields). More...
 
#define MW_CMD_MAX_BUFLEN   (MW_MSG_MAX_BUFLEN - MW_CMD_HEADLEN)
 Maximum data length contained inside command buffer. More...
 
#define MW_SSID_MAXLEN   32
 Maximum SSID length (including '\0'). More...
 
#define MW_PASS_MAXLEN   64
 Maximum password length (including '\0'). More...
 
#define MW_GT_NICKNAME_MAX   32
 Gamertag nickname maximum length. More...
 
#define MW_GT_SECURITY_MAX   32
 Gamertag security maximum length. More...
 
#define MW_GT_TAGLINE_MAX   32
 Gamertag tagline maximum length. More...
 
#define MW_GT_AVATAR_WIDTH   32
 Gamertag avatar graphick width in pixels. More...
 
#define MW_GT_AVATAR_HEIGHT   48
 Gamertag avatar graphick height in pixels. More...
 
#define MW_GT_TG_TOKEN_MAX   64
 Telegram token maximum length. More...
 

Typedefs

typedef union mw_cmd mw_cmd
 Command sent to system FSM.
 

Enumerations

enum  mw_state
 MwState Possible states of the system state machine. More...
 
enum  mw_sock_stat
 Socket status. More...
 

Variables

enum PACKED mw_command
 Supported commands. More...
 
 MW_CMD_OK = 0
 OK command reply. More...
 
 MW_CMD_VERSION = 1
 Get firmware version. More...
 
 MW_CMD_ECHO = 2
 Echo data. More...
 
 MW_CMD_AP_SCAN = 3
 Scan for access points. More...
 
 MW_CMD_AP_CFG = 4
 Configure access point. More...
 
 MW_CMD_AP_CFG_GET = 5
 Get access point configuration. More...
 
 MW_CMD_IP_CURRENT = 6
 Get current IPv4 configuration. More...
 
 MW_CMD_IP_CFG = 8
 Configure IPv4. More...
 
 MW_CMD_IP_CFG_GET = 9
 Get IPv4 configuration. More...
 
 MW_CMD_DEF_AP_CFG = 10
 Set default AP configuration. More...
 
 MW_CMD_DEF_AP_CFG_GET = 11
 Get default AP configuration. More...
 
 MW_CMD_AP_JOIN = 12
 Join access point. More...
 
 MW_CMD_AP_LEAVE = 13
 Leave previously joined AP. More...
 
 MW_CMD_TCP_CON = 14
 Connect TCP socket. More...
 
 MW_CMD_TCP_BIND = 15
 Bind TCP socket to port. More...
 
 MW_CMD_CLOSE = 17
 Disconnect and free TCP/UDP socket. More...
 
 MW_CMD_UDP_SET = 18
 Configure UDP socket. More...
 
 MW_CMD_SOCK_STAT = 20
 Get socket status. More...
 
 MW_CMD_PING = 21
 Ping host. More...
 
 MW_CMD_SNTP_CFG = 22
 Configure SNTP service. More...
 
 MW_CMD_SNTP_CFG_GET = 23
 Get SNTP configuration. More...
 
 MW_CMD_DATETIME = 24
 Get date and time. More...
 
 MW_CMD_DT_SET = 25
 Set date and time. More...
 
 MW_CMD_FLASH_WRITE = 26
 Write to WiFi module flash. More...
 
 MW_CMD_FLASH_READ = 27
 Read from WiFi module flash. More...
 
 MW_CMD_FLASH_ERASE = 28
 Erase sector from WiFi flash. More...
 
 MW_CMD_FLASH_ID = 29
 Get WiFi flash chip identifiers. More...
 
 MW_CMD_SYS_STAT = 30
 Get system status. More...
 
 MW_CMD_DEF_CFG_SET = 31
 Set default configuration. More...
 
 MW_CMD_HRNG_GET = 32
 Gets random numbers. More...
 
 MW_CMD_BSSID_GET = 33
 Gets the WiFi BSSID. More...
 
 MW_CMD_GAMERTAG_SET = 34
 Configures a gamertag. More...
 
 MW_CMD_GAMERTAG_GET = 35
 Gets a stored gamertag. More...
 
 MW_CMD_LOG = 36
 Write a message to log trace. More...
 
 MW_CMD_FACTORY_RESET = 37
 Set default configuratioSet default configuration. More...
 
 MW_CMD_SLEEP = 38
 Set the module to sleep mode. More...
 
 MW_CMD_HTTP_URL_SET = 39
 Set HTTP URL for request. More...
 
 MW_CMD_HTTP_METHOD_SET = 40
 Set HTTP request method. More...
 
 MW_CMD_HTTP_CERT_QUERY = 41
 Query the X.509 hash of cert. More...
 
 MW_CMD_HTTP_CERT_SET = 42
 Set HTTPS certificate. More...
 
 MW_CMD_HTTP_HDR_ADD = 43
 Add HTTP request header. More...
 
 MW_CMD_HTTP_HDR_DEL = 44
 Delete HTTP request header. More...
 
 MW_CMD_HTTP_OPEN = 45
 Open HTTP request. More...
 
 MW_CMD_HTTP_FINISH = 46
 Finish HTTP request. More...
 
 MW_CMD_HTTP_CLEANUP = 47
 Clean request data. More...
 
 MW_CMD_SERVER_URL_GET = 49
 Get the main server URL. More...
 
 MW_CMD_SERVER_URL_SET = 50
 Set the main server URL. More...
 
 MW_CMD_WIFI_ADV_GET = 51
 Get advanced WiFi parameters. More...
 
 MW_CMD_WIFI_ADV_SET = 52
 Set advanced WiFi parameters. More...
 
 MW_CMD_NV_CFG_SAVE = 53
 Save non-volatile config. More...
 
 MW_CMD_UPGRADE_LIST = 54
 Get firmware upgrade versions. More...
 
 MW_CMD_UPGRADE_PERFORM = 55
 Start firmware upgrade. More...
 
 MW_CMD_GAME_ENDPOINT_SET = 56
 Set game API endpoint. More...
 
 MW_CMD_GAME_KEYVAL_ADD = 57
 Add key/value appended to requests. More...
 
 MW_CMD_GAME_REQUEST = 58
 Perform a game API request. More...
 
enum PACKED mw_security
 Supported security protocols. More...
 
 MW_SEC_OPEN = 0
 Open WiFi network. More...
 
 MW_SEC_WEP
 WEP security. More...
 
 MW_SEC_WPA_PSK
 WPA PSK security. More...
 
 MW_SEC_WPA2_PSK
 WPA2 PSK security. More...
 
 MW_SEC_WPA_WPA2_PSK
 WPA or WPA2 security. More...
 
enum PACKED mw_phy_type
 WiFi PHY configuration for the connection to the AP. More...
 
 MW_PHY_11B = 1
 Legacy, do not use unless necessary. More...
 
 MW_PHY_11BG = 3
 No 802.11n compatibility. More...
 

Detailed Description

MegaWiFi command message definitions.

Definition in file mw-msg.h.

Variable Documentation

◆ MW_CMD_AP_CFG

MW_CMD_AP_CFG = 4

Configure access point.

Definition at line 56 of file mw-msg.h.

◆ MW_CMD_AP_CFG_GET

MW_CMD_AP_CFG_GET = 5

Get access point configuration.

Definition at line 57 of file mw-msg.h.

◆ MW_CMD_AP_JOIN

MW_CMD_AP_JOIN = 12

Join access point.

Definition at line 64 of file mw-msg.h.

◆ MW_CMD_AP_LEAVE

MW_CMD_AP_LEAVE = 13

Leave previously joined AP.

Definition at line 65 of file mw-msg.h.

◆ MW_CMD_AP_SCAN

MW_CMD_AP_SCAN = 3

Scan for access points.

Definition at line 55 of file mw-msg.h.

◆ MW_CMD_BSSID_GET

MW_CMD_BSSID_GET = 33

Gets the WiFi BSSID.

Definition at line 85 of file mw-msg.h.

◆ MW_CMD_CLOSE

MW_CMD_CLOSE = 17

Disconnect and free TCP/UDP socket.

Definition at line 69 of file mw-msg.h.

◆ MW_CMD_DATETIME

MW_CMD_DATETIME = 24

Get date and time.

Definition at line 76 of file mw-msg.h.

◆ MW_CMD_DEF_AP_CFG

MW_CMD_DEF_AP_CFG = 10

Set default AP configuration.

Definition at line 62 of file mw-msg.h.

◆ MW_CMD_DEF_AP_CFG_GET

MW_CMD_DEF_AP_CFG_GET = 11

Get default AP configuration.

Definition at line 63 of file mw-msg.h.

◆ MW_CMD_DEF_CFG_SET

MW_CMD_DEF_CFG_SET = 31

Set default configuration.

Definition at line 83 of file mw-msg.h.

◆ MW_CMD_DT_SET

MW_CMD_DT_SET = 25

Set date and time.

Definition at line 77 of file mw-msg.h.

◆ MW_CMD_ECHO

MW_CMD_ECHO = 2

Echo data.

Definition at line 54 of file mw-msg.h.

◆ MW_CMD_FACTORY_RESET

MW_CMD_FACTORY_RESET = 37

Set default configuratioSet default configuration.

Definition at line 89 of file mw-msg.h.

◆ MW_CMD_FLASH_ERASE

MW_CMD_FLASH_ERASE = 28

Erase sector from WiFi flash.

Definition at line 80 of file mw-msg.h.

◆ MW_CMD_FLASH_ID

MW_CMD_FLASH_ID = 29

Get WiFi flash chip identifiers.

Definition at line 81 of file mw-msg.h.

◆ MW_CMD_FLASH_READ

MW_CMD_FLASH_READ = 27

Read from WiFi module flash.

Definition at line 79 of file mw-msg.h.

◆ MW_CMD_FLASH_WRITE

MW_CMD_FLASH_WRITE = 26

Write to WiFi module flash.

Definition at line 78 of file mw-msg.h.

◆ MW_CMD_GAME_ENDPOINT_SET

MW_CMD_GAME_ENDPOINT_SET = 56

Set game API endpoint.

Definition at line 108 of file mw-msg.h.

◆ MW_CMD_GAME_KEYVAL_ADD

MW_CMD_GAME_KEYVAL_ADD = 57

Add key/value appended to requests.

Definition at line 109 of file mw-msg.h.

◆ MW_CMD_GAME_REQUEST

MW_CMD_GAME_REQUEST = 58

Perform a game API request.

Definition at line 110 of file mw-msg.h.

◆ MW_CMD_GAMERTAG_GET

MW_CMD_GAMERTAG_GET = 35

Gets a stored gamertag.

Definition at line 87 of file mw-msg.h.

◆ MW_CMD_GAMERTAG_SET

MW_CMD_GAMERTAG_SET = 34

Configures a gamertag.

Definition at line 86 of file mw-msg.h.

◆ MW_CMD_HRNG_GET

MW_CMD_HRNG_GET = 32

Gets random numbers.

Definition at line 84 of file mw-msg.h.

◆ MW_CMD_HTTP_CERT_QUERY

MW_CMD_HTTP_CERT_QUERY = 41

Query the X.509 hash of cert.

Definition at line 93 of file mw-msg.h.

◆ MW_CMD_HTTP_CERT_SET

MW_CMD_HTTP_CERT_SET = 42

Set HTTPS certificate.

Definition at line 94 of file mw-msg.h.

◆ MW_CMD_HTTP_CLEANUP

MW_CMD_HTTP_CLEANUP = 47

Clean request data.

Definition at line 99 of file mw-msg.h.

◆ MW_CMD_HTTP_FINISH

MW_CMD_HTTP_FINISH = 46

Finish HTTP request.

Definition at line 98 of file mw-msg.h.

◆ MW_CMD_HTTP_HDR_ADD

MW_CMD_HTTP_HDR_ADD = 43

Add HTTP request header.

Definition at line 95 of file mw-msg.h.

◆ MW_CMD_HTTP_HDR_DEL

MW_CMD_HTTP_HDR_DEL = 44

Delete HTTP request header.

Definition at line 96 of file mw-msg.h.

◆ MW_CMD_HTTP_METHOD_SET

MW_CMD_HTTP_METHOD_SET = 40

Set HTTP request method.

Definition at line 92 of file mw-msg.h.

◆ MW_CMD_HTTP_OPEN

MW_CMD_HTTP_OPEN = 45

Open HTTP request.

Definition at line 97 of file mw-msg.h.

◆ MW_CMD_HTTP_URL_SET

MW_CMD_HTTP_URL_SET = 39

Set HTTP URL for request.

Definition at line 91 of file mw-msg.h.

◆ MW_CMD_IP_CFG

MW_CMD_IP_CFG = 8

Configure IPv4.

Definition at line 60 of file mw-msg.h.

◆ MW_CMD_IP_CFG_GET

MW_CMD_IP_CFG_GET = 9

Get IPv4 configuration.

Definition at line 61 of file mw-msg.h.

◆ MW_CMD_IP_CURRENT

MW_CMD_IP_CURRENT = 6

Get current IPv4 configuration.

Definition at line 58 of file mw-msg.h.

◆ MW_CMD_LOG

MW_CMD_LOG = 36

Write a message to log trace.

Definition at line 88 of file mw-msg.h.

◆ MW_CMD_NV_CFG_SAVE

MW_CMD_NV_CFG_SAVE = 53

Save non-volatile config.

Definition at line 105 of file mw-msg.h.

◆ MW_CMD_OK

MW_CMD_OK = 0

OK command reply.

Definition at line 52 of file mw-msg.h.

◆ MW_CMD_PING

MW_CMD_PING = 21

Ping host.

Definition at line 73 of file mw-msg.h.

◆ MW_CMD_SERVER_URL_GET

MW_CMD_SERVER_URL_GET = 49

Get the main server URL.

Definition at line 101 of file mw-msg.h.

◆ MW_CMD_SERVER_URL_SET

MW_CMD_SERVER_URL_SET = 50

Set the main server URL.

Definition at line 102 of file mw-msg.h.

◆ MW_CMD_SLEEP

MW_CMD_SLEEP = 38

Set the module to sleep mode.

Definition at line 90 of file mw-msg.h.

◆ MW_CMD_SNTP_CFG

MW_CMD_SNTP_CFG = 22

Configure SNTP service.

Definition at line 74 of file mw-msg.h.

◆ MW_CMD_SNTP_CFG_GET

MW_CMD_SNTP_CFG_GET = 23

Get SNTP configuration.

Definition at line 75 of file mw-msg.h.

◆ MW_CMD_SOCK_STAT

MW_CMD_SOCK_STAT = 20

Get socket status.

Definition at line 72 of file mw-msg.h.

◆ MW_CMD_SYS_STAT

MW_CMD_SYS_STAT = 30

Get system status.

Definition at line 82 of file mw-msg.h.

◆ MW_CMD_TCP_BIND

MW_CMD_TCP_BIND = 15

Bind TCP socket to port.

Definition at line 67 of file mw-msg.h.

◆ MW_CMD_TCP_CON

MW_CMD_TCP_CON = 14

Connect TCP socket.

Definition at line 66 of file mw-msg.h.

◆ MW_CMD_UDP_SET

MW_CMD_UDP_SET = 18

Configure UDP socket.

Definition at line 70 of file mw-msg.h.

◆ MW_CMD_UPGRADE_LIST

MW_CMD_UPGRADE_LIST = 54

Get firmware upgrade versions.

Definition at line 106 of file mw-msg.h.

◆ MW_CMD_UPGRADE_PERFORM

MW_CMD_UPGRADE_PERFORM = 55

Start firmware upgrade.

Definition at line 107 of file mw-msg.h.

◆ MW_CMD_VERSION

MW_CMD_VERSION = 1

Get firmware version.

Definition at line 53 of file mw-msg.h.

◆ MW_CMD_WIFI_ADV_GET

MW_CMD_WIFI_ADV_GET = 51

Get advanced WiFi parameters.

Definition at line 103 of file mw-msg.h.

◆ MW_CMD_WIFI_ADV_SET

MW_CMD_WIFI_ADV_SET = 52

Set advanced WiFi parameters.

Definition at line 104 of file mw-msg.h.

◆ MW_PHY_11B

MW_PHY_11B = 1

Legacy, do not use unless necessary.

Definition at line 126 of file mw-msg.h.

◆ MW_PHY_11BG

MW_PHY_11BG = 3

No 802.11n compatibility.

Definition at line 127 of file mw-msg.h.

◆ MW_SEC_OPEN

MW_SEC_OPEN = 0

Open WiFi network.

Definition at line 116 of file mw-msg.h.

◆ MW_SEC_WEP

MW_SEC_WEP

WEP security.

Definition at line 117 of file mw-msg.h.

◆ MW_SEC_WPA2_PSK

MW_SEC_WPA2_PSK

WPA2 PSK security.

Definition at line 119 of file mw-msg.h.

◆ MW_SEC_WPA_PSK

MW_SEC_WPA_PSK

WPA PSK security.

Definition at line 118 of file mw-msg.h.

◆ MW_SEC_WPA_WPA2_PSK

MW_SEC_WPA_WPA2_PSK

WPA or WPA2 security.

Definition at line 120 of file mw-msg.h.