Common#
Note
To manage the Wi-Fi interface lifecycle correctly, it's important to use functions like sl_wifi_init(), sl_wifi_connect(), sl_wifi_disconnect(), and sl_wifi_deinit() as intended. Improper sequencing or combining sl_wifi_* and sl_net_* API functions without following the recommended order may lead to unpredictable or undefined behavior.
Functions#
This function initializes the Wi-Fi module using the specified device configuration, device context, and event handler.
This function ensures proper shutdown of the Wi-Fi driver, resetting configurations and releasing resources.
Check if Wi-Fi interface is up.
Return the firmware version running on the Wi-Fi device.
Get wireless connection information for a specific interface (AP or Station).
Gets wlan info in AP mode / Client mode.
Return the firmware image size from firmware image.
Set the default Wi-Fi interface as supported by sl_wifi_interface_t.
Get the default interface.
Retrieves the MAC addresses of the specified Wi-Fi interface, in concurrent mode retrieves two MAC addresses.
Set the Wi-Fi interface MAC address.
Function Documentation#
sl_wifi_init#
sl_status_t sl_wifi_init (const sl_wifi_device_configuration_t * configuration, const sl_wifi_device_context_t * device_context, sl_wifi_event_handler_t event_handler)
This function initializes the Wi-Fi module using the specified device configuration, device context, and event handler.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const sl_wifi_device_configuration_t * | [in] | configuration | sl_wifi_device_configuration_t object that contains Wi-Fi device configuration. |
| const sl_wifi_device_context_t * | [in] | device_context | Reserved for future use. |
| sl_wifi_event_handler_t | [in] | event_handler | Wi-Fi event handler function of type sl_wifi_event_handler_t. |
It configures the Wi-Fi device and establishes the event handler for Wi-Fi events. This function must be called before using any other Wi-Fi functions. Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
This function should be called before calling any other sl_wifi functions.
In SoC mode, wireless initialization must be completed before using the NVM3 APIs in the common flash, as flash write and erase operations require communication between the NWP & M4.
sl_wifi_deinit#
sl_status_t sl_wifi_deinit (void )
This function ensures proper shutdown of the Wi-Fi driver, resetting configurations and releasing resources.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
Call this API to deinitialize the Wi-Fi module to avoid resource leaks.
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
All si91x, BSD, and IoT sockets must be closed before invoking this API.
sl_wifi_is_interface_up#
bool sl_wifi_is_interface_up (sl_wifi_interface_t interface)
Check if Wi-Fi interface is up.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_interface_t | [in] | interface | Wi-Fi interface as identified by sl_wifi_interface_t |
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
true: interface is up.
false: interface is down.
sl_wifi_get_firmware_version#
sl_status_t sl_wifi_get_firmware_version (sl_wifi_firmware_version_t * version)
Return the firmware version running on the Wi-Fi device.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_firmware_version_t * | [out] | version | sl_wifi_firmware_version_t object that contains the version string. |
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
Moving forward, this API will be deprecated. Instead, use the sl_si91x_get_firmware_version API.
sl_wifi_get_interface_info#
sl_status_t sl_wifi_get_interface_info (sl_wifi_interface_t interface, sl_wifi_interface_info_t * info)
Get wireless connection information for a specific interface (AP or Station).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_interface_t | [in] | interface |
|
| sl_wifi_interface_info_t * | [out] | info | Pointer to a sl_wifi_connection_info_t structure to be filled |
This function retrieves wireless connection information for the specified interface. It supports concurrent mode and allows querying AP and Station (Client) information separately. By default, both AP and Station interfaces are supported.
Pre-conditions: sl_wifi_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
For extended interface details including MAC address, IPv4/IPv6 addresses, and Wi-Fi information, use the sl_net_get_interface_info API.
sl_wifi_get_wireless_info#
sl_status_t sl_wifi_get_wireless_info (sl_si91x_rsp_wireless_info_t * info)
Gets wlan info in AP mode / Client mode.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_si91x_rsp_wireless_info_t * | [out] | info | sl_si91x_rsp_wireless_info_t object that contains the wlan info. |
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
Moving forward, this API will be deprecated. Instead, use the sl_wifi_get_interface_info API. The sl_si91x_rsp_wireless_info_t structure is also deprecated and replaced by sl_wifi_interface_info_t.
sl_wifi_get_firmware_size#
sl_status_t sl_wifi_get_firmware_size (const void * buffer, uint32_t * fw_image_size)
Return the firmware image size from firmware image.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const void * | [in] | buffer | Buffer pointing to firmware image file. |
| uint32_t * | [out] | fw_image_size | Size of the firmware image passed in the input buffer param. The value returned in this param is valid only if this API returns SL_STATUS_OK(0). |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
Moving forward, this API will be deprecated. Instead, use the sl_si91x_get_firmware_size API.
sl_wifi_set_default_interface#
void sl_wifi_set_default_interface (sl_wifi_interface_t interface)
Set the default Wi-Fi interface as supported by sl_wifi_interface_t.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_interface_t | [in] | interface | Wi-Fi interface as identified by sl_wifi_interface_t |
sl_wifi_get_default_interface#
sl_wifi_interface_t sl_wifi_get_default_interface (void )
Get the default interface.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
sl_wifi_interface_t previously set by sl_wifi_set_default_interface
sl_wifi_get_mac_address#
sl_status_t sl_wifi_get_mac_address (sl_wifi_interface_t interface, sl_mac_address_t * mac)
Retrieves the MAC addresses of the specified Wi-Fi interface, in concurrent mode retrieves two MAC addresses.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_interface_t | [in] | interface | Wi-Fi interface as identified by sl_wifi_interface_t |
| sl_mac_address_t * | [out] | mac | sl_mac_address_t object contains the MAC address of the interface. |
MAC address of the module. In concurrent mode, two MAC addresses are returned, MAC_Address1 is the station MAC address and MAC_Address2 is the created AP MAC address. MAC address is returned in 6-bytes in hex format.
Pre-conditions:
sl_wifi_init should be called before this API.
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
sl_wifi_set_mac_address#
sl_status_t sl_wifi_set_mac_address (sl_wifi_interface_t interface, const sl_mac_address_t * mac)
Set the Wi-Fi interface MAC address.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_wifi_interface_t | [in] | interface | Wi-Fi interface as identified by sl_wifi_interface_t |
| const sl_mac_address_t * | [in] | mac | sl_mac_address_t object to store the MAC address. |
Returns
sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details.
Note
This API is not supported by SiWx91x when called directly due to firmware constraints. Alternatively, sl_wifi_init can be used to configure the MAC address. sl_wifi_init ensures the appropriate state of firmware and calls this API to set MAC address.