BSB Developer Docs
Loading...
Searching...
No Matches
wifi.h File Reference

API for controlling WiFi networks. More...

#include "wifi_common.h"

Go to the source code of this file.

Functions

FuriState * wifi_get_state (Wifi *instance)
 Get the state object that supports change notifications.
 
WifiStatus wifi_scan (Wifi *instance, WifiScanResult *results, uint8_t *result_count, uint8_t max_result_count)
 Scan for available Wifi access points nearby.
 
WifiStatus wifi_connect (Wifi *instance, const WifiCredentials *credentials, const WifiIpConfig *ip_config)
 Connect to an access point using the specified configuration.
 
WifiStatus wifi_disconnect (Wifi *instance)
 Disconnect from the access point.
 
WifiStatus wifi_forget (Wifi *instance)
 Forget the currently saved network credentials.
 
WifiStatus wifi_get_info (Wifi *instance, WifiInfo *info)
 Get the information about current state of the Wifi system.
 

Detailed Description

API for controlling WiFi networks.

Some functions are blocking (will block the calling thread until completion).

Additionally, the Wifi system only serves one thread at a time, so attempting to access it from multiple threads will put them in a blocked state until the previous thread is done working with its blocking functions.

Function Documentation

◆ wifi_connect()

WifiStatus wifi_connect ( Wifi * instance,
const WifiCredentials * credentials,
const WifiIpConfig * ip_config )

Connect to an access point using the specified configuration.

This function will block the calling thread until completion.

Parameters
[in,out]instancepointer to the Wifi instance
[in]credentialspointer to the structure containing the connection credentials
[in]ip_configpointer to the structure containing the connection configuration
Returns
WifiStatusOk on success, error code otherwise

◆ wifi_disconnect()

WifiStatus wifi_disconnect ( Wifi * instance)

Disconnect from the access point.

This function will block the calling thread until completion.

Parameters
[in,out]instancepointer to the Wifi instance
Returns
WifiStatusOk on success, error code otherwise

◆ wifi_forget()

WifiStatus wifi_forget ( Wifi * instance)

Forget the currently saved network credentials.

Note
It is only possible to forget a network when disconnected.
Parameters
[in,out]instancepointer to the Wifi instance
Returns
WifiStatusOk on success, error code otherwise

◆ wifi_get_info()

WifiStatus wifi_get_info ( Wifi * instance,
WifiInfo * info )

Get the information about current state of the Wifi system.

This function never blocks.

Parameters
[in,out]instancepointer to the Wifi instance
[out]infopointer to the structure to contain the information
Returns
WifiStatusOk on success, error code otherwise

◆ wifi_get_state()

FuriState * wifi_get_state ( Wifi * instance)

Get the state object that supports change notifications.

The received FuriState object will have an underlying type of WifiInfo. Use furi_state_subscribe() to get notifications about changes in the current state.

This function never blocks.

Parameters
[in,out]instancepointer to the Wifi instance
Returns
pointer to the FuriState object

◆ wifi_scan()

WifiStatus wifi_scan ( Wifi * instance,
WifiScanResult * results,
uint8_t * result_count,
uint8_t max_result_count )

Scan for available Wifi access points nearby.

The array pointed to by the results parameter MUST be allocated by the user code. Naturally, it is also responsible for freeing the array when it is no longer needed.

This function will block the calling thread until completion.

Note
Scanning is only possible when the Wifi is disconnected from a network.
Parameters
[in,out]instancepointer to the Wifi instance
[out]resultspointer to the array to contain the scan results
[out]result_countpointer to the variable to contain the result count
[in]max_result_countmaximum capacity of the scan results array
Returns
WifiStatusOk on success, error code otherwise