Network Interface#
Note
Event/Callback handlers must not contain function calls or code which can block or delay the execution of the event/callback handler as it will cause all the other events to queue up and delay the execution of other events since all the events are invoked and handled from a single thread.
Do not call any synchronous SDK APIs from within the Event/Callback handlers.
Functions#
Initialize the specified network interface.
De-initialize a network interface.
Bring a network interface up.
Bring a network interface down.
Resolve the given host name to an IP address.
Sets DNS server IP addresses.
Function Documentation#
sl_net_init#
sl_status_t sl_net_init (sl_net_interface_t interface, const void * configuration, void * network_context, sl_net_event_handler_t event_handler)
Initialize the specified network interface.
[in] | interface | The network interface to initialize. One of the values from sl_net_interface_t | ||||||
[in] | configuration | Pointer to the configuration structure for the specified interface of type sl_wifi_device_configuration_t. If NULL, then the following configuration is used internally by SDK:
| ||||||
[in] | network_context | Runtime context specific to network interface. | ||||||
[in] | event_handler | Function pointer to the network event handler callback of sl_net_event_handler_t type |
This function initializes the specified network interface with the provided configuration, network context, and event handler. It supports various network interfaces such as Wi-Fi client, Wi-Fi access point.
Once the user passes a function pointer to the event handler, the network context is passed in the callback, and various events can be received through this callback.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
Note
For Wi-Fi events, sl_net uses the wifi callback framework. Register the corresponding Wi-Fi event handlers using sl_wifi_set_callback API.
The
network_context
parameter is used only when the module is acting as a station in external stack mode (lwIP). In this case,network_context
should refer to a valid sl_net_wifi_lwip_context_t variable.
78
of file components/service/network_manager/inc/sl_net.h
sl_net_deinit#
sl_status_t sl_net_deinit (sl_net_interface_t interface)
De-initialize a network interface.
[in] | interface | Interface identified by sl_net_interface_t. |
This function de-initializes the specified network interface, releasing any resources that were allocated during initialization.
After this, the user will not receive callbacks related to events.
For the SL_NET_WIFI_CLIENT_INTERFACE
and SL_NET_WIFI_AP_INTERFACE
interface, this function ensures proper shutdown of the Wi-Fi driver, soft resets the NWP, and releases resources.
Pre-conditions:
sl_net_init should be called before this API.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
102
of file components/service/network_manager/inc/sl_net.h
sl_net_up#
sl_status_t sl_net_up (sl_net_interface_t interface, sl_net_profile_id_t profile_id)
Bring a network interface up.
[in] | interface | Interface identified by sl_net_interface_t. |
[in] | profile_id | Network profile identifier for the specific interface of type sl_net_profile_id_t |
This function brings the specified network interface up, making it ready for network communication.
For SL_NET_WIFI_CLIENT_INTERFACE
, the API fetches profile data from the profile ID, scans the network and connects to the network, configures the IP address, and updates the profile data.
For SL_NET_WIFI_AP_INTERFACE
, the API fetches profile data from the profile ID, configures the IP address, updates the profile data, and starts the Access Point (AP).
Pre-conditions:
sl_net_init should be called before this API.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
Note
By default, profile and credential configurations in sl_net_defaults.h are used by SDK.
To enable support for both IPv4 and IPv6, the ip.type in the profile should be set to (SL_IPV4|SL_IPV6).
The user can define their profile and credential configurations for an interface by calling sl_net_set_profile and sl_net_set_credential APIs before calling sl_net_up API.
135
of file components/service/network_manager/inc/sl_net.h
sl_net_down#
sl_status_t sl_net_down (sl_net_interface_t interface)
Bring a network interface down.
[in] | interface | Interface identified by sl_net_interface_t. This parameter specifies which network interface to bring down. |
This function deactivates the specified network interface, effectively disconnecting it from the WLAN network. It should be called to properly shut down the interface and release any associated resources.
Pre-conditions:
sl_net_up should be called before this API to ensure the interface is active before attempting to bring it down.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
158
of file components/service/network_manager/inc/sl_net.h
sl_net_host_get_by_name#
sl_status_t sl_net_host_get_by_name (const char * host_name, const uint32_t timeout, const sl_net_dns_resolution_ip_type_t dns_resolution_ip, sl_ip_address_t * ip_address)
Resolve the given host name to an IP address.
[in] | host_name |
|
[in] | timeout |
|
[in] | dns_resolution_ip |
|
[out] | ip_address |
|
This function resolves a host name to its corresponding IP address. It requires the DNS client feature to be enabled in the TCP/IP feature bitmap before calling.
Pre-conditions:
The SL_SI91X_TCP_IP_FEAT_DNS_CLIENT bit should be enabled in the TCP/IP feature bitmap.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
74
of file components/service/network_manager/inc/sl_net_dns.h
sl_net_set_dns_server#
sl_status_t sl_net_set_dns_server (sl_net_interface_t interface, sl_net_dns_address_t * address)
Sets DNS server IP addresses.
[in] | interface | The network interface of type sl_net_interface_t. |
[in] | address | The structure containing the primary and secondary server addresses of type sl_net_dns_address_t. |
This function configures the DNS server IP addresses for the specified network interface.
If both primary and secondary server addresses are NULL, the DNS mode will be set to DHCP. Otherwise, the DNS mode will be set to static.
Pre-conditions:
The SL_SI91X_TCP_IP_FEAT_DNS_CLIENT bit should be enabled in the TCP/IP feature bitmap.
Returns
sl_status_t. See Status Codes and Additional Status Codes for details.
101
of file components/service/network_manager/inc/sl_net_dns.h