CMSIS-Driver  Version 2.7.1
Peripheral Interface for Middleware and Application Code
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
WiFi Management

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...
 

Description

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.


Data Structure Documentation

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:

Data Fields
const char * ssid Pointer to Service Set Identifier (SSID) null-terminated string.
const char * pass Pointer to Password null-terminated string.
uint8_t security Security type (ARM_WIFI_SECURITY_xxx)
uint8_t ch WiFi Channel (0 = auto, otherwise = exact channel)
uint8_t reserved Reserved.
uint8_t wps_method WiFi Protected Setup (WPS) method (ARM_WIFI_WPS_METHOD_xxx)
const char * wps_pin Pointer to WiFi Protected Setup (WPS) PIN null-terminated string.
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:

Data Fields
char ssid[32+1] Service Set Identifier (SSID) null-terminated string.
uint8_t bssid[6] Basic Service Set Identifier (BSSID)
uint8_t security Security type (ARM_WIFI_SECURITY_xxx)
uint8_t ch WiFi Channel.
uint8_t rssi Received Signal Strength Indicator.
struct ARM_WIFI_NET_INFO_t

WiFi Network Information.

Provides information about the network that the station is connected to.

Used in:

Data Fields
char ssid[32+1] Service Set Identifier (SSID) null-terminated string.
char pass[64+1] Password null-terminated string.
uint8_t security Security type (ARM_WIFI_SECURITY_xxx)
uint8_t ch WiFi Channel.
uint8_t rssi Received Signal Strength Indicator.

Function Documentation

int32_t ARM_WIFI_SetOption ( uint32_t  interface,
uint32_t  option,
const void *  data,
uint32_t  len 
)

Set WiFi Module Options.

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]optionOption to set
[in]dataPointer to data relevant to selected option
[in]lenLength of data (in bytes)
Returns
execution status

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:

uint8_t ip[4];
ip[0] = 192U;
ip[1] = 168U;
ip[2] = 0U;
ip[3] = 1U;
// Set IP static address of the Station
wifi->SetOption (0U, ARM_WIFI_IP, &ip, sizeof(ip));
int32_t ARM_WIFI_GetOption ( uint32_t  interface,
uint32_t  option,
void *  data,
uint32_t *  len 
)

Get WiFi Module Options.

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]optionOption to get
[out]dataPointer to memory where data for selected option will be returned
[in,out]lenPointer to length of data (input/output)
  • input: maximum length of data that can be returned (in bytes)
  • output: length of returned data (in bytes)
Returns
execution status

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:

uint8_t ip[4]; // IP address
uint8_t mask[4]; // Subnet mask
uint8_t gateway[4]; // Gateway address
// Get IP address, Subnet mask and Gateway address of the Station
wifi->GetOption (0U, ARM_WIFI_IP, &ip, sizeof(ip));
wifi->GetOption (0U, ARM_WIFI_IP_SUBNET_MASK, &mask, sizeof(mask));
wifi->GetOption (0U, ARM_WIFI_IP_GATEWAY, &gateway, sizeof(gateway));
int32_t ARM_WIFI_Scan ( ARM_WIFI_SCAN_INFO_t  scan_info[],
uint32_t  max_num 
)

Scan for available networks in range.

Parameters
[out]scan_infoPointer to array of ARM_WIFI_SCAN_INFO_t structures where available Scan Information will be returned
[in]max_numMaximum number of Network Information structures to return
Returns
number of ARM_WIFI_SCAN_INFO_t structures returned or error code

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:

ARM_WIFI_SCAN_INFO_t scan_info[8];
num = wifi->Scan (scan_info, 8U);
// Print SSIDs of available WiFi networks
for (i = 0; i < num; i++) {
printf ("%d. ssid=%s\n", i, scan_info[i].ssid);
}
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).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
[in]configPointer to ARM_WIFI_CONFIG_t structure where Configuration parameters are located
Returns
execution status

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.

Note
Optionally BSSID parameter can be also set using ARM_WIFI_SetOption. It allows connection to specific BSSID when connecting to an access point or specifies the BSSID of the access point.

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.

Note
WPS is typically activated by pressing the WPS button at the access point. During the discovery mode (usually 2 minutes or less) any wireless device may connect to the access point (PIN needs to match when PIN method is selected).

Example:

ARM_WIFI_CONFIG_t wifi_config;
wifi_config.ssid = "GuestAccess";
wifi_config.pass = "guest";
wifi_config.ch = 0U;
// Connect to wireless network
status = wifi->Activate (0U, &wifi_config);
if (status != ARM_DRIVER_OK) {
// error handling
}
int32_t ARM_WIFI_Deactivate ( uint32_t  interface)

Deactivate interface (Disconnect from a wireless network or deactivate an access point).

Parameters
[in]interfaceInterface (0 = Station, 1 = Access Point)
Returns
execution status

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.

Returns
station connection status
  • value != 0: Station connected
  • value = 0: Station not connected

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.

Parameters
[out]net_infoPointer to ARM_WIFI_NET_INFO_t structure where station Network Information will be returned
Returns
execution status

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:

ARM_WIFI_CONFIG_t wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config));
// Connect to wireless network (WPS)
status = wifi->Activate (0U, &wifi_config);
if (status != ARM_DRIVER_OK) {
// error handling
}
// Retrieve network information
if (wifi->IsConnected ()) {
status = wifi->GetNetInfo (&net_info);
if (status != ARM_DRIVER_OK) {
// error handling
}
printf("SSID=%s, Password=%s",net_info.ssid, net_info.pass);
}
// Disconnect from wireless network
wifi->Deactivate (0U);