CMSIS-Driver
Version 2.8.0
Peripheral Interface for Middleware and Application Code
|
Configure and manage the connection to a WiFi access point (AP) or configure and manage the access point (AP). More...
Content | |
WiFi Option Codes | |
WiFi Option Codes for ARM_WIFI_SetOption or ARM_WIFI_GetOption function. | |
WiFi Security Type | |
Specifies WiFi security type for ARM_WIFI_Activate. | |
WiFi Protected Setup (WPS) Method | |
Specifies WiFi WPS method for ARM_WIFI_Activate. | |
WiFi DHCPv6 Mode | |
Specifies IPv6 Dynamic Host Configuration Protocol (DHCP) Mode. | |
Data Structures | |
struct | ARM_WIFI_CONFIG_t |
WiFi Configuration. More... | |
struct | ARM_WIFI_SCAN_INFO_t |
WiFi Scan Information. More... | |
struct | ARM_WIFI_NET_INFO_t |
WiFi Network Information. More... | |
Functions | |
int32_t | ARM_WIFI_SetOption (uint32_t interface, uint32_t option, const void *data, uint32_t len) |
Set WiFi Module Options. More... | |
int32_t | ARM_WIFI_GetOption (uint32_t interface, uint32_t option, void *data, uint32_t *len) |
Get WiFi Module Options. More... | |
int32_t | ARM_WIFI_Scan (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num) |
Scan for available networks in range. More... | |
int32_t | ARM_WIFI_Activate (uint32_t interface, ARM_WIFI_CONFIG_t *config) |
Activate interface (Connect to a wireless network or activate an access point). More... | |
int32_t | ARM_WIFI_Deactivate (uint32_t interface) |
Deactivate interface (Disconnect from a wireless network or deactivate an access point). More... | |
uint32_t | ARM_WIFI_IsConnected (void) |
Get station connection status. More... | |
int32_t | ARM_WIFI_GetNetInfo (ARM_WIFI_NET_INFO_t *net_info) |
Get station Network Information. More... | |
Configure and manage the connection to a WiFi access point (AP) or configure and manage the access point (AP).
The WiFi Management functions are used to configure and manage the connection to a WiFi access point (AP) also called hotspot when in station mode. They are also used to configure and manage the access point (AP) itself when in access point mode.
struct ARM_WIFI_CONFIG_t |
WiFi Configuration.
Provides information needed to connect to the WiFi network for station or how to configure the access point (AP).
Used in:
struct ARM_WIFI_SCAN_INFO_t |
WiFi Scan Information.
Provides information about the wireless networks that were detected when searching for available WiFi networks. The structure contains the information needed to connect to the WiFi network. Of course, the access password is not included and must be provided separately.
Used in:
struct ARM_WIFI_NET_INFO_t |
WiFi Network Information.
Provides information about the network that the station is connected to.
Used in:
int32_t ARM_WIFI_SetOption | ( | uint32_t | interface, |
uint32_t | option, | ||
const void * | data, | ||
uint32_t | len | ||
) |
Set WiFi Module Options.
[in] | interface | Interface (0 = Station, 1 = Access Point) |
[in] | option | Option to set |
[in] | data | Pointer to data relevant to selected option |
[in] | len | Length of data (in bytes) |
The function ARM_WIFI_SetOption sets the value of the specified option of the WiFi module.
The argument interface specifies the interface (0 = Station, 1 = Access Point).
The argument option specifies the option that is to be set (see below).
The argument data points to a buffer containing the value of the option to be set and must be aligned to the data type of the corresponding option.
The argument len specifies the length of the buffer data and must be equal (or higher) to the length of the corresponding option.
Option | Description | Data | Type/Length |
---|---|---|---|
ARM_WIFI_BSSID | BSSID of AP to connect or AP | bssid | uint8_t[6] |
ARM_WIFI_TX_POWER | Transmit power | power[dbm] | uint32_t |
ARM_WIFI_LP_TIMER | Low-power deep-sleep time | time[seconds] | uint32_t |
ARM_WIFI_DTIM | DTIM interval | dtim[beacons] | uint32_t |
ARM_WIFI_BEACON | Beacon interval | interval[ms] | uint32_t |
ARM_WIFI_MAC | MAC address | mac | uint8_t[6] |
ARM_WIFI_IP | IPv4 address | ip | uint8_t[4] |
ARM_WIFI_IP_SUBNET_MASK | IPv4 subnet mask | mask | uint8_t[4] |
ARM_WIFI_IP_GATEWAY | IPv4 gateway address | ip | uint8_t[4] |
ARM_WIFI_IP_DNS1 | IPv4 primary DNS server address | ip | uint8_t[4] |
ARM_WIFI_IP_DNS2 | IPv4 secondary DNS server address | ip | uint8_t[4] |
ARM_WIFI_IP_DHCP | IPv4 DHCP client/server enable/disable | dhcp (0, 1) | uint32_t |
ARM_WIFI_IP_DHCP_POOL_BEGIN | IPv4 DHCP server begin address | ip | uint8_t[4] |
ARM_WIFI_IP_DHCP_POOL_END | IPv4 DHCP server end address | ip | uint8_t[4] |
ARM_WIFI_IP_DHCP_LEASE_TIME | IPv4 DHCP server lease time | time[seconds] | uint32_t |
ARM_WIFI_IP6_GLOBAL | IPv6 global address | ip6 | uint8_t[16] |
ARM_WIFI_IP6_LINK_LOCAL | IPv6 link-local address | ip6 | uint8_t[16] |
ARM_WIFI_IP6_SUBNET_PREFIX_LEN | IPv6 subnet prefix length | len (1..127) | uint32_t |
ARM_WIFI_IP6_GATEWAY | IPv6 gateway address | ip6 | uint8_t[16] |
ARM_WIFI_IP6_DNS1 | IPv6 primary DNS server address | ip6 | uint8_t[16] |
ARM_WIFI_IP6_DNS2 | IPv6 secondary DNS server address | ip6 | uint8_t[16] |
ARM_WIFI_IP6_DHCP_MODE | IPv6 DHCP client mode | mode | uint32_t |
Example:
int32_t ARM_WIFI_GetOption | ( | uint32_t | interface, |
uint32_t | option, | ||
void * | data, | ||
uint32_t * | len | ||
) |
Get WiFi Module Options.
[in] | interface | Interface (0 = Station, 1 = Access Point) |
[in] | option | Option to get |
[out] | data | Pointer to memory where data for selected option will be returned |
[in,out] | len | Pointer to length of data (input/output)
|
The function ARM_WIFI_GetOption retrieves the current value of the specified option of the WiFi module.
The argument interface specifies the interface (0 = Station, 1 = Access Point).
The argument option specifies the option that is to be retrieved (see ARM_WIFI_SetOption).
The argument data points to a buffer that will be used to store the value of the option and must be aligned to the data type of the corresponding option.
The argument len is a pointer to the length of the buffer at input and returns the length of the option information on the output.
Example:
int32_t ARM_WIFI_Scan | ( | ARM_WIFI_SCAN_INFO_t | scan_info[], |
uint32_t | max_num | ||
) |
Scan for available networks in range.
[out] | scan_info | Pointer to array of ARM_WIFI_SCAN_INFO_t structures where available Scan Information will be returned |
[in] | max_num | Maximum number of Network Information structures to return |
The function ARM_WIFI_Scan searches for available WiFi networks. Using this function, you can determine which wireless networks are available for the connection. If the network is secured, you must also know the password to connect.
The argument scan_info is a pointer to an array of network information structures, where the available network information will be returned.
The argument max_num specifies maximum number of network information structures, that can be stored to the scan_info.
Example:
int32_t ARM_WIFI_Activate | ( | uint32_t | interface, |
ARM_WIFI_CONFIG_t * | config | ||
) |
Activate interface (Connect to a wireless network or activate an access point).
[in] | interface | Interface (0 = Station, 1 = Access Point) |
[in] | config | Pointer to ARM_WIFI_CONFIG_t structure where Configuration parameters are located |
The function ARM_WIFI_Activate activates the specified interface.
The argument interface specifies the interface (0 = Station, 1 = Access Point).
When station interface is specified, the WiFi module connects to a wireless network.
The wireless network trying to connect to must be available, otherwise the operation will fail after a timeout.
Available wireless networks can be scanned by using the function ARM_WIFI_Scan.
When access point interface is specified, the WiFi module creates a wireless network by activating the access point.
The argument config is a pointer to the configuration ARM_WIFI_CONFIG_t which provides information needed to connect to a WiFi network for station interface or information used to configure the access point (AP) for access point interface.
ssid specifies the name of the network to connect to or the network to create.
pass specifies the password for accessing the wireless network.
security specifies the security type which will be used for the connection.
ch specifies the WiFi channel which will be used for the connection. Valid channels for 2.4 GHz frequency are from 1 to 13. If the value for ch = 0, the system automatically selects the channel. For station interface the channel of the AP being connected to is used. For access point interface the module automatically selects the best channel for the WiFi connection.
wps_method specifies if WiFi Protected Setup (WPS) is used and which method.
wps_pin specifies the PIN used with WPS (ARM_WIFI_WPS_METHOD_PIN).
With the push-button method, you typically press the button, either real or virtual, both at the access point and the station. No credentials are needed.
With 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 ARM_WIFI_GetNetInfo.
WPS configuration for access point is used when access point is activated. Subsequent activate calls re-trigger the WPS procedure.
Example:
int32_t ARM_WIFI_Deactivate | ( | uint32_t | interface | ) |
Deactivate interface (Disconnect from a wireless network or deactivate an access point).
[in] | interface | Interface (0 = Station, 1 = Access Point) |
The function ARM_WIFI_Deactivate deactivates the specified interface.
The argument interface specifies the interface (0 = Station, 1 = Access Point).
When station interface is specified, the WiFi module disconnects from the wireless network.
When access point interface is specified, the WiFi module deactivates the access point.
Example:
uint32_t ARM_WIFI_IsConnected | ( | void | ) |
Get station connection status.
The function ARM_WIFI_IsConnected checks if the station is connected to a wireless network and returns the connection status.
The function returns a non-zero value, if the station is connected. If the station is not connected, the function returns 0.
Example:
int32_t ARM_WIFI_GetNetInfo | ( | ARM_WIFI_NET_INFO_t * | net_info | ) |
Get station Network Information.
[out] | net_info | Pointer to ARM_WIFI_NET_INFO_t structure where station Network Information will be returned |
The function ARM_WIFI_GetNetInfo retrieves wireless network information of a connected station.
It can be used to retrieve network connection information for subsequent connections after initially connecting using WPS.
Example: