WINC1500 IoT Software APIs: socketInit

WINC1500 IoT Software API

WINC1500 IoT Software APIs  19.5.2
WINC Software API Reference Manual
socketInit

Functions

NMI_API void socketInit (void)
 
NMI_API void socketDeinit (void)
 

Detailed Description

The function performs the necessary initializations for the socket library through the following steps:

  • A check made by the global variable gbSocketInit, ensuring that initialization for sockets is performed only once, in-order to prevent reseting the socket instances already created in the global socket array (gastrSockets).
  • Zero initializations to the global socket array (gastrSockets), which holds the list of TCP sockets.
  • Registers the socket (Host Interface)hif callback function through the call to the hif_register_cb function. This facilitates handling all of the socket related functions received through interrupts from the firmware.

Function Documentation

◆ socketInit()

NMI_API void socketInit ( void  )
Parameters
[in]void
Returns
void
Remarks
This initialization function must be invoked before any socket operation is performed. No error codes from this initialization function since the socket array is statically allocated based in the maximum number of sockets MAX_SOCKET based on the systems capability.

Example

This example demonstrates the use of the socketinit for socket initialization for an mqtt chat application.

int8_t ret;
char topic[strlen(MAIN_CHAT_TOPIC) + MAIN_CHAT_USER_NAME_SIZE + 1];
//Initialize the board.
system_init();
//Initialize the UART console.
configure_console();
// Initialize the BSP.
----------
// Initialize socket interface.
registerSocketCallback(socket_event_handler, socket_resolve_handler);
// 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);

◆ socketDeinit()

NMI_API void socketDeinit ( void  )

Socket Layer De-initialization.

The function performs the necessary cleanup for the socket library static data It must be invoked as the last any socket operation is performed on any active sockets.

Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by   doxygen 1.8.13