|
SGDK
A free and open development kit for the Sega Mega Drive
|
MegaWiFi API implementation. More...
Go to the source code of this file.
Classes | |
| struct | mw_ap_data |
| Access Point data. More... | |
Macros | |
| #define | MW_API_VERSION_MAJOR 1 |
| API version implemented, major number. | |
| #define | MW_API_VERSION_MINOR 5 |
| API version implemented, minor number. | |
| #define | MW_COMMAND_TOUT_MS 1000 |
| Timeout for standard commands in milliseconds. | |
| #define | MW_CONNECT_TOUT_MS 10000 |
| Timeout for TCP connections. | |
| #define | MW_HTTP_OPEN_TOUT_MS 10000 |
| Timeout for HTTP open command in milliseconds. | |
| #define | MW_SCAN_TOUT_MS 10000 |
| Timeout for the AP scan command in milliseconds. | |
| #define | MW_ASSOC_TOUT_MS 20000 |
| Timeout for the AP associate command in milliseconds. | |
| #define | MW_ASSOC_WAIT_SLEEP_MS 5000 |
| Time to sleep before waiting for assoc in milliseconds. | |
| #define | MW_UPGRADE_TOUT_MS 180000 |
| Timeout for upgrade command in milliseconds. | |
| #define | MW_PING_TOUT_MS 30000 |
| Timeout for ping command in milliseconds. | |
| #define | MW_STAT_POLL_MS 250 |
| Milliseconds between status polls while in wm_ap_assoc_wait() | |
| #define | MW_BUFLEN 1460 |
| Length of the wflash buffer. | |
| #define | MW__RESET UART_MCR__DTR |
| Reset out. | |
| #define | MW__PRG UART_MCR__RTS |
| Program out. | |
| #define | MW__DCD UART_MSR__DSR |
| Data request in. | |
| #define | MW_SSID_MAXLEN 32 |
| Maximum SSID length (including '\0'). | |
| #define | MW_PASS_MAXLEN 64 |
| Maximum password length (including '\0'). | |
| #define | MW_NTP_POOL_MAXLEN 80 |
| Maximum length of an NTP pool URI (including '\0'). | |
| #define | MW_NUM_CFG_SLOTS 3 |
| Number of AP configurations stored to nvflash. | |
| #define | MW_NUM_DNS_SERVERS 2 |
| Number of DSN servers supported per AP configuration. | |
| #define | MW_FSM_QUEUE_LEN 8 |
| Length of the FSM queue. | |
| #define | MW_MAX_SOCK 3 |
| Maximum number of simultaneous TCP connections. | |
| #define | MW_CTRL_CH 0 |
| Control channel used for LSD protocol. | |
| #define | MW_HTTP_CH LSD_MAX_CH - 1 |
| Channel used for HTTP requests and cert sets. | |
| #define | MW_CMD_MIN_BUFLEN 168 |
| #define | mw_tcp_disconnect(ch) |
| Closes a TCP socket. This is an alias of mw_close(). | |
| #define | mw_udp_unset(ch) |
| Frees a UDP socket. This is an alias of mw_close(). | |
| #define | mw_module_reset() |
| Puts the WiFi module in reset state. | |
| #define | mw_module_start() |
| Releases the module from reset state. | |
Enumerations | |
| enum | mw_err { MW_ERR_NONE = 0 , MW_ERR , MW_ERR_NOT_READY , MW_ERR_BUFFER_TOO_SHORT , MW_ERR_PARAM , MW_ERR_SEND , MW_ERR_RECV } |
| Error codes for MegaWiFi API functions. More... | |
| enum | mw_http_method { MW_HTTP_METHOD_GET = 0 , MW_HTTP_METHOD_POST , MW_HTTP_METHOD_PUT , MW_HTTP_METHOD_PATCH , MW_HTTP_METHOD_DELETE , MW_HTTP_METHOD_HEAD , MW_HTTP_METHOD_NOTIFY , MW_HTTP_METHOD_SUBSCRIBE , MW_HTTP_METHOD_UNSUBSCRIBE , MW_HTTP_METHOD_OPTIONS , MW_HTTP_METHOD_MAX } |
| Supported HTTP methods. More... | |
| enum | mw_if_type { MW_IF_STATION = 0 , MW_IF_SOFTAP , MW_IF_MAX } |
| Interface type for the mw_bssid_get() function. More... | |
Functions | |
| int16_t | mw_init (uint16_t *cmd_buf, uint16_t buf_len) |
| Module initialization. Must be called once before using any other function. It also initializes de UART. | |
| void | mw_cmd_data_cb_set (lsd_recv_cb cmd_recv_cb) |
| Sets the callback function to be run when network data is received while waiting for a command reply. | |
| enum mw_err | mw_detect (uint8_t *major, uint8_t *minor, char **variant) |
| Performs the startup sequence for the WiFi module, and tries detecting it by requesting the version data. | |
| enum mw_err | mw_version_get (uint8_t version[3], char **variant) |
| Obtain module version numbers and string. | |
| uint8_t * | mw_bssid_get (enum mw_if_type interface_type) |
| Gets the module BSSID (the MAC address) for the specified interface. | |
| enum mw_err | mw_default_cfg_set (void) |
| Set default module configuration (AKA factory settings). | |
| enum mw_err | mw_ap_cfg_set (uint8_t slot, const char *ssid, const char *pass, enum mw_phy_type phy_type) |
| Set access point configuration (SSID and password). | |
| enum mw_err | mw_ap_cfg_get (uint8_t slot, char **ssid, char **pass, enum mw_phy_type *phy_type) |
| Gets access point configuration (SSID and password). | |
| enum mw_err | mw_ip_cfg_set (uint8_t slot, const struct mw_ip_cfg *ip) |
| Set IPv4 configuration. | |
| enum mw_err | mw_ip_cfg_get (uint8_t slot, struct mw_ip_cfg **ip) |
| Get IPv4 configuration. | |
| enum mw_err | mw_wifi_adv_cfg_set (const struct mw_wifi_adv_cfg *wifi) |
| Set advanced WiFi configuration. | |
| struct mw_wifi_adv_cfg * | mw_wifi_adv_cfg_get (void) |
| Get advanced WiFi configuration. | |
| enum mw_err | mw_cfg_save (void) |
| Saves changed configuration parameters to non-volatile memory. | |
| enum mw_err | mw_ip_current (struct mw_ip_cfg **ip) |
| Get current IP configuration, of the joined AP. | |
| int16_t | mw_ap_scan (enum mw_phy_type phy_type, char **ap_data, uint8_t *aps) |
| Scan for access points. | |
| int16_t | mw_ap_fill_next (const char *ap_data, uint16_t pos, struct mw_ap_data *apd, uint16_t data_len) |
| Parses received AP data and fills information of the AP at "pos". Useful to extract AP information from the data obtained by calling mw_ap_scan() function. | |
| enum mw_err | mw_ap_assoc (uint8_t slot) |
| Tries associating to an AP. If successful, also configures IPv4. | |
| enum mw_err | mw_ap_assoc_wait (int16_t tout_frames) |
| Polls the module status until it reports device is associated to AP or timeout occurs. | |
| enum mw_err | mw_def_ap_cfg (uint8_t slot) |
| Sets default AP/IP configuration. | |
| enum mw_err | mw_ap_disassoc (void) |
| Dissasociates from a previously associated AP. | |
| int16_t | mw_def_ap_cfg_get (void) |
| Gets default AP/IP configuration slot. | |
| enum mw_err | mw_tcp_connect (uint8_t ch, const char *dst_addr, const char *dst_port, const char *src_port) |
| Tries establishing a TCP connection with specified server. | |
| enum mw_err | mw_close (uint8_t ch) |
| Closes and disconnects a socket from specified channel. | |
| enum mw_err | mw_udp_set (uint8_t ch, const char *dst_addr, const char *dst_port, const char *src_port) |
| Configures a UDP socket to send/receive data. | |
| enum mw_err | mw_tcp_bind (uint8_t ch, uint16_t port) |
| Binds a socket to a port, and listens to connections on the port. If a connection request is received, it will be automatically accepted. | |
| enum mw_err | mw_sock_conn_wait (uint8_t ch, int16_t tout_frames) |
| Polls a socket until it is ready to transfer data. Typical use of this function is after a successful mw_tcp_bind(). | |
| enum mw_err | mw_recv_sync (uint8_t *ch, char *buf, int16_t *buf_len, int16_t tout_frames) |
| Receive data, syncrhonous interface. | |
| enum mw_err | mw_send_sync (uint8_t ch, const char *data, uint16_t len, int16_t tout_frames) |
| Sends data through a socket, using a previously allocated channel. Synchronous interface. | |
| union mw_msg_sys_stat * | mw_sys_stat_get (void) |
| Get system status. | |
| enum mw_sock_stat | mw_sock_stat_get (uint8_t ch) |
| Get socket status. | |
| enum mw_err | mw_sntp_cfg_set (const char *tz_str, const char *server[3]) |
| Configure SNTP parameters and timezone. | |
| enum mw_err | mw_sntp_cfg_get (char **tz_str, char *server[3]) |
| Get SNTP parameters and timezone configuration. | |
| char * | mw_date_time_get (uint32_t dt_bin[2]) |
| Get date and time. | |
| enum mw_err | mw_flash_id_get (uint8_t *man_id, uint16_t *dev_id) |
| Get the identifiers of the flash chip in the WiFi module. | |
| enum mw_err | mw_flash_sector_erase (uint16_t sect) |
| Erase a 4 KiB Flash sector. Every byte of an erased sector will be read as 0xFF. | |
| enum mw_err | mw_flash_write (uint32_t addr, uint8_t *data, uint16_t data_len) |
| Write data to specified flash address. | |
| uint8_t * | mw_flash_read (uint32_t addr, uint16_t data_len) |
| Read data from specified flash address. | |
| enum mw_err | mw_gamertag_set (uint8_t slot, const struct mw_gamertag *gamertag) |
| Set gamertag information for one slot. | |
| struct mw_gamertag * | mw_gamertag_get (uint8_t slot) |
| Get gamertag information for one slot. | |
| enum mw_err | mw_log (const char *msg) |
| Write a message to the WiFi module log trace. | |
| enum mw_err | mw_factory_settings (void) |
| Set factory default configuration. | |
| void | mw_power_off (void) |
| Powers off the WiFi module. | |
| void | mw_sleep (int16_t frames) |
| Sleep the specified amount of frames. | |
| enum mw_err | mw_http_url_set (const char *url) |
| Set URL for HTTP requests. | |
| enum mw_err | mw_http_method_set (enum mw_http_method method) |
| Set method for HTTP requests. | |
| enum mw_err | mw_http_header_add (const char *key, const char *value) |
| Add an HTTP header. | |
| enum mw_err | mw_http_header_del (const char *key) |
| Delete a previously added HTTP header. | |
| enum mw_err | mw_http_open (uint32_t content_len) |
| Open HTTP connection. | |
| int16_t | mw_http_finish (uint32_t *content_len, int16_t tout_frames) |
| Finish an opened HTTP request. | |
| uint32_t | mw_http_cert_query (void) |
| Query the X.509 hash of the installed PEM certificate. | |
| enum mw_err | mw_http_cert_set (uint32_t cert_hash, const char *cert, uint16_t cert_len) |
| Set the PEM certificate to use on HTTPS requests. | |
| int16_t | mw_http_cleanup (void) |
| Clean-up an HTTP request, freeing associated resources. | |
| char * | mw_def_server_get (void) |
| Get the default server used for MegaWiFi connections. | |
| enum mw_err | mw_def_server_set (const char *server_url) |
| Set the default server used for MegaWiFi connections. | |
| uint8_t * | mw_hrng_get (uint16_t rnd_len) |
| Get random numbers. | |
| enum mw_err | mw_ga_endpoint_set (const char *endpoint, const char *priv_key) |
| Set endpoint for Game API. | |
| enum mw_err | mw_ga_key_value_add (const char **key, const char **value, uint16_t num_pairs) |
| Add parameters to the Game API request in key/value format. | |
| int16_t | mw_ga_request (enum mw_http_method method, const char **path, uint8_t num_paths, const char **key, const char **value, uint8_t num_kv_pairs, uint32_t *content_len, int16_t tout_frames) |
| Perform a GameAPI request, with the previously set endpoint and key/value pairs. | |
| enum mw_err | mw_fw_list_upgrades (uint8_t page, uint8_t size, uint8_t offset, char **listUpgrades, uint8_t *len, uint8_t *total) |
| List available upgrades WiFi module firmware. | |
| enum mw_err | mw_fw_upgrade (const char *name) |
| Over-The-Air upgrade WiFi module firmware. | |
| struct mw_ping_response * | mw_ping (const char *domain, u8 retries) |
| Run ICMP requesto to domain. | |
MegaWiFi API implementation.