WINC1500 IoT Software APIs: registerSocketCallback

WINC1500 IoT Software API

WINC1500 IoT Software APIs  19.5.2
WINC Software API Reference Manual
registerSocketCallback

Functions

NMI_API void registerSocketCallback (tpfAppSocketCb socket_cb, tpfAppResolveCb resolve_cb)
 

Detailed Description

Register two callback functions one for asynchronous socket events and the other one for DNS callback registering function. The registered callback functions are used to retrieve information in response to the asynchronous socket functions called.

Function Documentation

◆ registerSocketCallback()

NMI_API void registerSocketCallback ( tpfAppSocketCb  socket_cb,
tpfAppResolveCb  resolve_cb 
)
Parameters
[in]tpfAppSocketCbAssignment of callback function to the global callback tpfAppSocketCb gpfAppSocketCb. Delivers socket messages to the host application. In response to the asynchronous function calls, such as bind listen accept connect
[in]tpfAppResolveCbAssignment of callback function to the global callback tpfAppResolveCb gpfAppResolveCb. Used for DNS resolving functionalities. The DNS resolving technique is determined by the application registering the callback. NULL is assigned when, DNS resolution is not required.
Returns
void
Remarks
If any of the socket functionalities is not to be used, NULL is passed in as a parameter. It must be invoked after socketinit and before other socket layer operations.

Example

This example demonstrates the use of the registerSocketCallback to register a socket callback function with DNS resolution CB set to null for a simple UDP server example.

int8_t ret;
struct sockaddr_in addr;
// Initialize the board
system_init();
//Initialize the UART console.
configure_console();
// Initialize the BSP.
// Initialize socket address structure.
addr.sin_family = AF_INET;
addr.sin_port = _htons(MAIN_WIFI_M2M_SERVER_PORT);
addr.sin_addr.s_addr = _htonl(MAIN_WIFI_M2M_SERVER_IP);
// Initialize Wi-Fi parameters structure.
memset((uint8_t *)&param, 0, sizeof(tstrWifiInitParam));
// Initialize Wi-Fi driver with data and status callbacks.
param.pfAppWifiCb = wifi_cb;
ret = m2m_wifi_init(&param);
if (M2M_SUCCESS != ret) {
printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
while (1) {
}
}
// Initialize socket module
// Connect to router.
m2m_wifi_connect((char *)MAIN_WLAN_SSID, sizeof(MAIN_WLAN_SSID), MAIN_WLAN_AUTH, (char *)MAIN_WLAN_PSK, M2M_WIFI_CH_ALL);
Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by   doxygen 1.8.13