Network Interface#
Note
Stack overflows may occur when invoking functions or using your own variables or data structures while handling callbacks. Configure the stack size by modifying the pre-processor macro
SL_SI91X_EVENT_HANDLER_STACK_SIZE
as per your application's requirements. See here for the instructions in modifying a pre-processor macro.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 a network interface.
De-initialize a network interface.
Bring a network interface up.
Bring a network interface down.
Resolve given host name to 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 a network interface.
[in] | interface | Interface identified by sl_net_interface_t | ||||||
[in] | configuration | Configuration object specific to network interface of type sl_wifi_device_configuration_t. If configuration = NULL, then following configuration is used internally by SDK
| ||||||
[in] | network_context | Runtime context specific to network interface. | ||||||
[in] | event_handler | Processes all network events related to network interface as identified by sl_net_event_handler_t |
This API should be called before calling any sl_net API. Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details.4
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.
Parameter
network_context
is only used when module is acting as station in external stack mode[lwIP]. In such case,network_context
is supposed to refer a valid sl_net_wifi_lwip_context_t variable.
76
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 |
Pre-conditions:
sl_net_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details.
92
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 specific interface of type sl_net_profile_id_t |
Pre-conditions:
sl_net_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status 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).
User can define their profile and credential configurations for an interface by calling sl_net_set_profile and sl_net_set_credentials APIs before calling sl_net_up API.
111
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 |
Pre-conditions:
sl_net_up should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details.
124
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 given host name to IP address.
[in] | host_name | Host name which needs to be resolved. |
[in] | timeout | Timeout in millisecs. |
[in] | dns_resolution_ip | DNS resolution by IP of type sl_net_dns_resolution_ip_type_t. |
[out] | ip_address | IP address object to store resolved IP address of type sl_ip_address_t. |
Pre-conditions:
Before calling this API, SL_SI91X_TCP_IP_FEAT_DNS_CLIENT bit should be enabled in TCP/IP feature bitmap.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details.
Note
If timeout value is greater than zero, caller(the function or module that invokes the sl_net_host_get_by_name API) would be blocked till timeout milliseconds to get the response. If the values are equal to zero, response would be sent through sl_net_event_handler_t.
59
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. |
[in] | address | The structure containing the primary and secondary server addresses. |
Pre-conditions:
Before calling this API, SL_SI91X_TCP_IP_FEAT_DNS_CLIENT bit should be enabled in the TCP/IP feature bitmap.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/4.1/common/api/group-status for details.
Note
If both primary_server_address and secondary_server_address in the address structure are NULL, the DNS mode will be set to DHCP. Otherwise, the DNS mode will be set to static.
78
of file components/service/network_manager/inc/sl_net_dns.h