WINC3400 Simple Roaming UDP Client Example.
Copyright (c) 2021 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include <string.h>
#include "main.h"
#include "common/include/nm_common.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
Data Structures | |
struct | s_msg_wifi_product |
Message format definitions. More... | |
struct | s_msg_wifi_product_main |
Macros | |
#define | STRING_EOL "\r\n" |
#define | STRING_HEADER |
Typedefs | |
typedef struct s_msg_wifi_product | t_msg_wifi_product |
Message format definitions. More... | |
typedef struct s_msg_wifi_product_main | t_msg_wifi_product_main |
Functions | |
static void | configure_console (void) |
int | main (void) |
Main application function. More... | |
static void | socket_cb (SOCKET sock, uint8_t u8Msg, void *pvMsg) |
Callback to get the Data from socket. More... | |
static void | wifi_cb (uint8_t u8MsgType, void *pvMsg) |
Callback to get the Wi-Fi status update. More... | |
Variables | |
struct sockaddr_in | addr |
static uint8_t | gau8ReceivedBuffer [MAIN_WIFI_M2M_BUFFER_SIZE] = {0} |
Receive buffer definition. More... | |
static uint8_t | gau8SocketTestBuffer [MAIN_WIFI_M2M_BUFFER_SIZE] = {0} |
Test buffer. More... | |
static t_msg_wifi_product | msg_wifi_product |
Message format declarations. More... | |
static t_msg_wifi_product_main | msg_wifi_product_main |
static uint8_t | packetCnt = 0 |
UDP packet count. More... | |
static SOCKET | udp_client_socket = -1 |
Socket for client. More... | |
static uint8_t | wifi_connected |
Wi-Fi connection state. More... | |
#define STRING_EOL "\r\n" |
#define STRING_HEADER |
Referenced by main().
typedef struct s_msg_wifi_product t_msg_wifi_product |
Message format definitions.
typedef struct s_msg_wifi_product_main t_msg_wifi_product_main |
|
static |
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, CONSOLE_UART_ID, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
int main | ( | void | ) |
Main application function.
Initialize system, UART console, network then start function of UDP socket.
References _htonl, _htons, AF_INET, bind(), board_init(), configure_console(), M2M_SUCCESS, M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_CONNECTED, m2m_wifi_enable_roaming(), m2m_wifi_handle_events(), m2m_wifi_init(), MAIN_WIFI_M2M_SERVER_IP, MAIN_WIFI_M2M_SERVER_PORT, MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, nm_bsp_init(), NULL, tstrWifiInitParam::pfAppWifiCb, registerSocketCallback(), in_addr::s_addr, sendto(), sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, socket(), socket_cb(), socketInit(), STRING_HEADER, sysclk_init(), udp_client_socket, wifi_cb(), and wifi_connected.
|
static |
Callback to get the Data from socket.
[in] | sock | socket handler. |
[in] | u8Msg | socket event type. Possible values are:
|
[in] | pvMsg | is a pointer to message structure. Existing types are: |
References addr, gau8ReceivedBuffer, gau8SocketTestBuffer, MAIN_WIFI_M2M_BUFFER_SIZE, tstrSocketRecvMsg::pu8Buffer, recvfrom(), tstrSocketRecvMsg::s16BufferSize, sendto(), SOCKET_MSG_BIND, SOCKET_MSG_RECVFROM, SOCKET_MSG_SENDTO, and tstrSocketBindMsg::status.
Referenced by main().
|
static |
Callback to get the Wi-Fi status update.
[in] | u8MsgType | type of Wi-Fi notification. Possible types are:
|
[in] | pvMsg | A pointer to a buffer containing the notification parameters (if any). It should be casted to the correct data type corresponding to the notification type. Existing types are:
|
References M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, M2M_WIFI_RESP_CON_STATE_CHANGED, M2M_WIFI_ROAMED, MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, tstrM2mWifiStateChanged::u8CurrState, and wifi_connected.
Referenced by main().
struct sockaddr_in addr |
Referenced by socket_cb().
|
static |
Receive buffer definition.
Referenced by socket_cb().
|
static |
Test buffer.
Referenced by socket_cb().
|
static |
Message format declarations.
|
static |
|
static |
UDP packet count.