Functions of the WiFi interface. More...
Functions | |
netStatus | netWiFi_Scan (uint32_t if_num, NET_WIFI_SCAN_INFO scan_info[], uint32_t *scan_num) |
Search for available WiFi networks. [thread-safe]. | |
netStatus | netWiFi_GetOption (uint32_t if_num, netWiFi_Option option, void *buf, uint32_t buf_len) |
Get the value of the WiFi driver option. [thread-safe]. | |
netStatus | netWiFi_SetOption (uint32_t if_num, netWiFi_Option option, const void *buf, uint32_t buf_len) |
Set the value of the WiFi driver option. [thread-safe]. | |
netStatus | netWiFi_Activate (uint32_t if_num, const NET_WIFI_CONFIG *config) |
Activate the WiFi interface. [thread-safe]. | |
netStatus | netWiFi_Deactivate (uint32_t if_num) |
Deactivate the WiFi interface. [thread-safe]. | |
bool | netWiFi_IsConnected (uint32_t if_num) |
Get the connection state of the WiFi interface. [thread-safe]. | |
netStatus | netWiFi_GetNetInfo (uint32_t if_num, NET_WIFI_NET_INFO *net_info) |
Get the network information of the WiFi interface. [thread-safe]. | |
Functions of the WiFi interface.
In the Network Component, the WiFi interface is, similar to an Ethernet interface, responsible for various Application/Internet/Link layer protocols such as ARP, NDP, IGMP, MLD and DHCP. In the Network Component, these protocols are supported for IPv4 and IPv6 connections (where applicable).
netStatus netWiFi_Activate | ( | uint32_t | if_num, |
const NET_WIFI_CONFIG * | config | ||
) |
Activate the WiFi interface. [thread-safe].
[in] | if_num | WiFi interface number. |
[in] | config | pointer to the structure with configuration parameters. |
The function netWiFi_Activate activates the specified interface. In station mode, the function connects to the wireless network, which must be available or the operation will fail after the timeout. In the access point mode, the function creates a wireless network by activating the access point.
The argument if_num specifies the WiFi Interface to be activated.
The argument config is a pointer to the NET_WIFI_CONFIG structure, which provides information needed to activate the WiFi interface.
Possible netStatus return values:
With the netWiFi_WPS_PBC method, you typically press the button, either real or virtual, both at the access point and the station. No credentials are needed.
With the netWiFi_WPS_PIN method, you must provide the PIN code that you read from the label or screen on the wireless device. WPS configuration for station is used when station connects to an access point. It enables to connect without specifying SSID, Password, Security Type or WiFi Channel. The actual network information can be retrieved once connected with netWiFi_GetNetInfo. WPS configuration for access point is used when access point is activated. Subsequent activate calls re-trigger the WPS procedure.
Code Example
fn netStatus netWiFi_Deactivate | ( | uint32_t | if_num | ) |
Deactivate the WiFi interface. [thread-safe].
[in] | if_num | WiFi interface number. |
The function netWiFi_Deactivate deactivates the specified interface.
The argument if_num specifies the WiFi Interface to be deactivated.
Possible netStatus return values:
Code Example (see netWiFi_GetNetInfo)
netStatus netWiFi_GetNetInfo | ( | uint32_t | if_num, |
NET_WIFI_NET_INFO * | net_info | ||
) |
Get the network information of the WiFi interface. [thread-safe].
[in] | if_num | WiFi interface number. |
[out] | net_info | structure for storing the network information. |
The function netWiFi_GetNetInfo retrieves wireless network information of a connected station. You can use the function to retrieve network information after the initial connection using WPS. Then use this network information for all the subsequent network connections to this wireless network.
The argument if_num specifies the WiFi Interface for obtaining the network information.
The argument net_info is a pointer to the NET_WIFI_NET_INFO structure, where the network information will be returned.
Possible netStatus return values:
Code Example
netStatus netWiFi_GetOption | ( | uint32_t | if_num, |
netWiFi_Option | option, | ||
void * | buf, | ||
uint32_t | buf_len | ||
) |
Get the value of the WiFi driver option. [thread-safe].
[in] | if_num | WiFi interface number. |
[in] | option | driver option as specified by netWiFi_Option. |
[out] | buf | buffer to store the option value to. |
[in] | buf_len | length of buffer. |
The function netWiFi_GetOption retrieves the current value of an option for the WiFi interface driver specified by if_num.
The argument if_num specifies the WiFi Interface for which an option should be obtained.
The argument option specifies the driver option netWiFi_Option that is to be retrieved (see netWiFi_SetOption).
The argument buf points to a buffer that will be used to store the value of the option.
The argument buf_len specifies the length of the buffer buf.
Possible netStatus return values:
Code Example
bool netWiFi_IsConnected | ( | uint32_t | if_num | ) |
Get the connection state of the WiFi interface. [thread-safe].
[in] | if_num | WiFi interface number. |
The function netWiFi_IsConnected determines the state of the wireless connection. It returns true if the WiFi station is connected to wireless access point and IP frames can be exchanged.
The argument if_num specifies the WiFi Interface to check if it is connected.
Code Example
netStatus netWiFi_Scan | ( | uint32_t | if_num, |
NET_WIFI_SCAN_INFO | scan_info[], | ||
uint32_t * | scan_num | ||
) |
Search for available WiFi networks. [thread-safe].
[in] | if_num | WiFi interface number. |
[out] | scan_info | array of structures for storing the scan information. |
[in,out] | scan_num | input maximum number, return number of WiFi networks found. |
The function netWiFi_Scan scans the WiFi networks within range. This function is usually executing for a long time, typically for a few seconds. The execution time is determined by the WiFi driver and the number of available WiFi networks.
The argument if_num specifies the WiFi Interface which is used for scanning.
The argument scan_info is a pointer to an array of NET_WIFI_SCAN_INFO structures, where the available network information will be returned.
The argument scan_num is a pointer to the length of scan_info array. It should initially contain the number of records available in scan_info. Upon return, it contains the actual number of WiFi networks found.
Possible netStatus return values:
Code Example
netStatus netWiFi_SetOption | ( | uint32_t | if_num, |
netWiFi_Option | option, | ||
const void * | buf, | ||
uint32_t | buf_len | ||
) |
Set the value of the WiFi driver option. [thread-safe].
[in] | if_num | WiFi interface number. |
[in] | option | driver option as specified by netWiFi_Option. |
[in] | buf | buffer containing the option value. |
[in] | buf_len | length of buffer. |
The function netWiFi_SetOption sets different options for the WiFi interface driver identified by the argument if_num.
The argument if_num specifies the WiFi Interface for which the option must be set.
The argument option specifies the driver option netWiFi_Option that is to be set (see below).
The argument buf points to a buffer containing the value of the option to be set.
The argument buf_len specifies the actual length of the buffer buf and must match the length of the corresponding option as specified with argument option (see below).
Option | Description | Length |
---|---|---|
netWiFi_OptionBSSID | BSSID of the WiFi Station or Access Point | 6 bytes |
netWiFi_OptionTxPower | WiFi transmit power | 4 bytes |
netWiFi_OptionLpTimer | Low-power deep-sleep time | 4 bytes |
netWiFi_OptionDTIM | DTIM interval | 4 bytes |
netWiFi_OptionBeacon | Beacon interval | 4 bytes |
Possible netStatus return values:
Code Example