Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more
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).
Functions | |
| NMI_API void | socketInit (void) |
| NMI_API void | socketDeinit (void) |
| Socket Layer De-initialization. | |
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
| 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.
| 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.
tstrWifiInitParam param; 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. nm_bsp_init(); ---------- // Initialize socket interface. socketInit (); 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);
Generated on Wed Jul 13 2022 16:32:38 by
1.7.2