WINC1500 AP provision example.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "main.h"
#include "common/include/nm_common.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
Macros | |
#define | STRING_EOL "\r\n" |
#define | STRING_HEADER |
Functions | |
static void | configure_console (void) |
Configure UART console. More... | |
int | main (void) |
Main application function. More... | |
static void | socket_cb (SOCKET sock, uint8_t u8Msg, void *pvMsg) |
Callback function of TCP client socket. More... | |
static void | wifi_cb (uint8_t u8MsgType, void *pvMsg) |
Callback to get the Wi-Fi status update. More... | |
Variables | |
static struct usart_module | cdc_uart_module |
UART module for debug. More... | |
static uint8_t | gau8SocketTestBuffer [MAIN_WIFI_M2M_BUFFER_SIZE] |
Receive buffer definition. More... | |
uint32_t | gu32HostIp = 0 |
IP address of host. More... | |
static SOCKET | tcp_client_socket = -1 |
static SOCKET | tcp_server_socket = -1 |
Socket for TCP communication. More... | |
#define STRING_EOL "\r\n" |
#define STRING_HEADER |
Referenced by main().
|
static |
Configure UART console.
References usart_config::baudrate, cdc_uart_module, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().
int main | ( | void | ) |
Main application function.
Initialize system, UART console, network then start function of TCP socket.
References _htons, AF_INET, bind(), configure_console(), M2M_SUCCESS, m2m_wifi_enable_ap(), m2m_wifi_handle_events(), m2m_wifi_init(), MAIN_WIFI_M2M_SERVER_PORT, MAIN_WLAN_AUTH, MAIN_WLAN_CHANNEL, MAIN_WLAN_SSID, nm_bsp_init(), NULL, tstrWifiInitParam::pfAppWifiCb, printf, registerSocketCallback(), ret, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, socket(), socket_cb(), socketInit(), STRING_HEADER, system_init(), tcp_server_socket, and wifi_cb().
|
static |
Callback function of TCP client socket.
[in] | sock | socket handler. |
[in] | u8Msg | Type of Socket notification |
[in] | pvMsg | A structure contains notification informations. |
References accept(), tstrM2mWifiWepParams::au8WepKey, close(), gau8SocketTestBuffer, listen(), M2M_MAX_PSK_LEN, M2M_MAX_SSID_LEN, m2m_memcpy(), M2M_WIFI_CH_ALL, m2m_wifi_connect(), m2m_wifi_disable_ap(), M2M_WIFI_SEC_WEP, nm_bsp_sleep(), NULL, printf, tstrSocketRecvMsg::pu8Buffer, recv(), tstrSocketRecvMsg::s16BufferSize, tstrSocketAcceptMsg::sock, SOCKET_MSG_ACCEPT, SOCKET_MSG_BIND, SOCKET_MSG_LISTEN, SOCKET_MSG_RECV, tstrSocketBindMsg::status, tstrSocketListenMsg::status, tcp_client_socket, tcp_server_socket, tstrM2mWifiWepParams::u8KeyIndx, and tstrM2mWifiWepParams::u8KeySz.
Referenced by main().
|
static |
Callback to get the Wi-Fi status update.
[in] | u8MsgType | type of Wi-Fi notification. |
[in] | pvMsg | A pointer to a buffer containing the notification parameters |
References M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, m2m_wifi_request_dhcp_client(), M2M_WIFI_RESP_CON_STATE_CHANGED, printf, and tstrM2mWifiStateChanged::u8CurrState.
Referenced by main().
|
static |
UART module for debug.
|
static |
Receive buffer definition.
Referenced by socket_cb().
uint32_t gu32HostIp = 0 |
IP address of host.
|
static |
Referenced by socket_cb().
|
static |
Socket for TCP communication.
Referenced by main(), and socket_cb().