Wi-Fi Management

Overview

The Wi-Fi management API is used to manage Wi-Fi networks. It supports below modes:

  • IEEE802.11 Station (STA)

  • IEEE802.11 Access Point (AP)

Only personal mode security is supported with below types:

  • Open

  • WPA2-PSK

  • WPA3-PSK-256

  • WPA3-SAE

The Wi-Fi management API is implemented in the wifi_mgmt module as a part of the networking L2 stack. Currently, two types of Wi-Fi drivers are supported:

  • Networking or socket offloaded drivers

  • Native L2 Ethernet drivers

API Reference

group wifi_mgmt

Wi-Fi Management API.

Wi-Fi utility functions.

Utility functions for the Wi-Fi subsystem.

int wifi_utils_parse_scan_bands(char *scan_bands_str, uint8_t *band_map)

Convert a band specification string to a bitmap representing the bands.

The function will parse a string which specifies Wi-Fi frequency band values as a comma separated string and convert it to a bitmap. The string can use the following characters to represent the bands:

  • 2: 2.4 GHz

  • 5: 5 GHz

  • 6: 6 GHz

For the bitmap generated refer to wifi_frequency_bands for bit position of each band.

E.g. a string “2,5,6” will be converted to a bitmap value of 0x7

Parameters:
  • scan_bands_str – String which spe.

  • band_map – Pointer to the bitmap variable to be updated.

Return values:
  • 0 – on success.

  • -errno – value in case of failure.

int wifi_utils_parse_scan_ssids(char *scan_ssids_str, const char *ssids[], uint8_t num_ssids)

Append a string containing an SSID to an array of SSID strings.

Parameters:
  • scan_ssids_str – string to be appended in the list of scanned SSIDs.

  • ssids – Pointer to an array where the SSIDs pointers are to be stored.

  • num_ssids – Maximum number of SSIDs that can be stored.

Return values:
  • 0 – on success.

  • -errno – value in case of failure.

int wifi_utils_parse_scan_chan(char *scan_chan_str, struct wifi_band_channel *chan, uint8_t max_channels)

Convert a string containing a specification of scan channels to an array.

The function will parse a string which specifies channels to be scanned as a string and convert it to an array.

The channel string has to be formatted using the colon (:), comma(,), hyphen (-) and underscore (_) delimiters as follows:

  • A colon identifies the value preceding it as a band. A band value (2: 2.4 GHz, 5: 5 GHz 6: 6 GHz) has to precede the channels in that band (e.g. 2: etc)

  • Hyphens (-) are used to identify channel ranges (e.g. 2-7, 32-48 etc)

  • Commas are used to separate channel values within a band. Channels can be specified as individual values (2,6,48 etc) or channel ranges using hyphens (1-14, 32-48 etc)

  • Underscores (_) are used to specify multiple band-channel sets (e.g. 2:1,2_5:36,40 etc)

  • No spaces should be used anywhere, i.e. before/after commas, before/after hyphens etc.

An example channel specification specifying channels in the 2.4 GHz and 5 GHz bands is as below: 2:1,5,7,9-11_5:36-48,100,163-167

Parameters:
  • scan_chan_str – List of channels expressed in the format described above.

  • chan – Pointer to an array where the parsed channels are to be stored.

  • max_channels – Maximum number of channels to store

Return values:
  • 0 – on success.

  • -errno – value in case of failure.

bool wifi_utils_validate_chan(uint8_t band, uint16_t chan)

Validate a channel against a band.

Parameters:
  • band – Band to validate the channel against.

  • chan – Channel to validate.

Return values:
  • true – if the channel is valid for the band.

  • false – if the channel is not valid for the band.

bool wifi_utils_validate_chan_2g(uint16_t chan)

Validate a channel against the 2.4 GHz band.

Parameters:
  • chan – Channel to validate.

Return values:
  • true – if the channel is valid for the band.

  • false – if the channel is not valid for the band.

bool wifi_utils_validate_chan_5g(uint16_t chan)

Validate a channel against the 5 GHz band.

Parameters:
  • chan – Channel to validate.

Return values:
  • true – if the channel is valid for the band.

  • false – if the channel is not valid for the band.

bool wifi_utils_validate_chan_6g(uint16_t chan)

Validate a channel against the 6 GHz band.

Parameters:
  • chan – Channel to validate.

Return values:
  • true – if the channel is valid for the band.

  • false – if the channel is not valid for the band.

WIFI_UTILS_MAX_BAND_STR_LEN

Maximum length of the band specification string.

WIFI_UTILS_MAX_CHAN_STR_LEN

Maximum length of the channel specification string.

Defines

WIFI_COUNTRY_CODE_LEN

Length of the country code string.

WIFI_SSID_MAX_LEN

Max SSID length.

WIFI_PSK_MIN_LEN

Minimum PSK length.

WIFI_PSK_MAX_LEN

Maximum PSK length.

WIFI_SAE_PSWD_MAX_LEN

Max SAW password length.

WIFI_MAC_ADDR_LEN

MAC address length.

WIFI_CHANNEL_MIN

Minimum channel number.

WIFI_CHANNEL_MAX

Maximum channel number.

WIFI_CHANNEL_ANY

Any channel number.

WIFI_INTERFACE_INDEX_MIN

Network interface index min value.

WIFI_INTERFACE_INDEX_MAX

Network interface index max value.

NET_REQUEST_WIFI_SCAN

Request a Wi-Fi scan.

NET_REQUEST_WIFI_CONNECT

Request a Wi-Fi connect.

NET_REQUEST_WIFI_DISCONNECT

Request a Wi-Fi disconnect.

NET_REQUEST_WIFI_AP_ENABLE

Request a Wi-Fi access point enable.

NET_REQUEST_WIFI_AP_DISABLE

Request a Wi-Fi access point disable.

NET_REQUEST_WIFI_IFACE_STATUS

Request a Wi-Fi network interface status.

NET_REQUEST_WIFI_PS

Request a Wi-Fi power save.

NET_REQUEST_WIFI_TWT

Request a Wi-Fi TWT.

NET_REQUEST_WIFI_PS_CONFIG

Request a Wi-Fi power save configuration.

NET_REQUEST_WIFI_REG_DOMAIN

Request a Wi-Fi regulatory domain.

NET_REQUEST_WIFI_MODE

Request current Wi-Fi mode.

NET_REQUEST_WIFI_PACKET_FILTER

Request Wi-Fi packet filter.

NET_REQUEST_WIFI_CHANNEL

Request a Wi-Fi channel.

NET_REQUEST_WIFI_AP_STA_DISCONNECT

Request a Wi-Fi access point to disconnect a station.

NET_REQUEST_WIFI_VERSION

Request a Wi-Fi version.

NET_REQUEST_WIFI_RTS_THRESHOLD

Request a Wi-Fi RTS threshold.

NET_REQUEST_WIFI_AP_CONFIG_PARAM

Request a Wi-Fi AP parameters configuration.

NET_EVENT_WIFI_SCAN_RESULT

Event emitted for Wi-Fi scan result.

NET_EVENT_WIFI_SCAN_DONE

Event emitted when Wi-Fi scan is done.

NET_EVENT_WIFI_CONNECT_RESULT

Event emitted for Wi-Fi connect result.

NET_EVENT_WIFI_DISCONNECT_RESULT

Event emitted for Wi-Fi disconnect result.

NET_EVENT_WIFI_IFACE_STATUS

Event emitted for Wi-Fi network interface status.

NET_EVENT_WIFI_TWT

Event emitted for Wi-Fi TWT information.

NET_EVENT_WIFI_TWT_SLEEP_STATE

Event emitted for Wi-Fi TWT sleep state.

NET_EVENT_WIFI_RAW_SCAN_RESULT

Event emitted for Wi-Fi raw scan result.

NET_EVENT_WIFI_DISCONNECT_COMPLETE

Event emitted Wi-Fi disconnect is completed.

NET_EVENT_WIFI_AP_ENABLE_RESULT

Event emitted for Wi-Fi access point enable result.

NET_EVENT_WIFI_AP_DISABLE_RESULT

Event emitted for Wi-Fi access point disable result.

NET_EVENT_WIFI_AP_STA_CONNECTED

Event emitted when Wi-Fi station is connected in AP mode.

NET_EVENT_WIFI_AP_STA_DISCONNECTED

Event emitted Wi-Fi station is disconnected from AP.

MAX_REG_CHAN_NUM

Max regulatory channel number.

Typedefs

typedef void (*scan_result_cb_t)(struct net_if *iface, int status, struct wifi_scan_result *entry)

Scan result callback.

Param iface:

Network interface

Param status:

Scan result status

Param entry:

Scan result entry

Enums

enum wifi_security_type

IEEE 802.11 security types.

Values:

enumerator WIFI_SECURITY_TYPE_NONE = 0

No security.

enumerator WIFI_SECURITY_TYPE_PSK

WPA2-PSK security.

enumerator WIFI_SECURITY_TYPE_PSK_SHA256

WPA2-PSK-SHA256 security.

enumerator WIFI_SECURITY_TYPE_SAE

WPA3-SAE security.

enumerator WIFI_SECURITY_TYPE_WAPI

GB 15629.11-2003 WAPI security.

enumerator WIFI_SECURITY_TYPE_EAP

EAP security - Enterprise.

enumerator WIFI_SECURITY_TYPE_WEP

WEP security.

enumerator WIFI_SECURITY_TYPE_WPA_PSK

WPA-PSK security.

enumerator WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL

WPA/WPA2/WPA3 PSK security.

enum wifi_mfp_options

IEEE 802.11w - Management frame protection.

Values:

enumerator WIFI_MFP_DISABLE = 0

MFP disabled.

enumerator WIFI_MFP_OPTIONAL

MFP optional.

enumerator WIFI_MFP_REQUIRED

MFP required.

enum wifi_frequency_bands

IEEE 802.11 operational frequency bands (not exhaustive).

Values:

enumerator WIFI_FREQ_BAND_2_4_GHZ = 0

2.4 GHz band.

enumerator WIFI_FREQ_BAND_5_GHZ

5 GHz band.

enumerator WIFI_FREQ_BAND_6_GHZ

6 GHz band (Wi-Fi 6E, also extends to 7GHz).

enumerator __WIFI_FREQ_BAND_AFTER_LAST

Number of frequency bands available.

enumerator WIFI_FREQ_BAND_MAX = __WIFI_FREQ_BAND_AFTER_LAST - 1

Highest frequency band available.

enumerator WIFI_FREQ_BAND_UNKNOWN

Invalid frequency band.

enum wifi_iface_state

Wi-Fi interface states.

Based on https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc

Values:

enumerator WIFI_STATE_DISCONNECTED = 0

Interface is disconnected.

enumerator WIFI_STATE_INTERFACE_DISABLED

Interface is disabled (administratively).

enumerator WIFI_STATE_INACTIVE

No enabled networks in the configuration.

enumerator WIFI_STATE_SCANNING

Interface is scanning for networks.

enumerator WIFI_STATE_AUTHENTICATING

Authentication with a network is in progress.

enumerator WIFI_STATE_ASSOCIATING

Association with a network is in progress.

enumerator WIFI_STATE_ASSOCIATED

Association with a network completed.

enumerator WIFI_STATE_4WAY_HANDSHAKE

4-way handshake with a network is in progress.

enumerator WIFI_STATE_GROUP_HANDSHAKE

Group Key exchange with a network is in progress.

enumerator WIFI_STATE_COMPLETED

All authentication completed, ready to pass data.

enum wifi_iface_mode

Wi-Fi interface modes.

Based on https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc

Values:

enumerator WIFI_MODE_INFRA = 0

Infrastructure station mode.

enumerator WIFI_MODE_IBSS = 1

IBSS (ad-hoc) station mode.

enumerator WIFI_MODE_AP = 2

AP mode.

enumerator WIFI_MODE_P2P_GO = 3

P2P group owner mode.

enumerator WIFI_MODE_P2P_GROUP_FORMATION = 4

P2P group formation mode.

enumerator WIFI_MODE_MESH = 5

802.11s Mesh mode.

Wi-Fi link operating modes.

As per https://en.wikipedia.org/wiki/Wi-Fi#Versions_and_generations.

Values:

802.11 (legacy).

802.11b.

802.11a.

802.11g.

802.11n.

802.11ac.

802.11ax.

802.11ax 6GHz.

802.11be.

enum wifi_scan_type

Wi-Fi scanning types.

Values:

enumerator WIFI_SCAN_TYPE_ACTIVE = 0

Active scanning (default).

enumerator WIFI_SCAN_TYPE_PASSIVE

Passive scanning.

enum wifi_ps

Wi-Fi power save states.

Values:

enumerator WIFI_PS_DISABLED = 0

Power save disabled.

enumerator WIFI_PS_ENABLED

Power save enabled.

enum wifi_ps_mode

Wi-Fi power save modes.

Values:

enumerator WIFI_PS_MODE_LEGACY = 0

Legacy power save mode.

enumerator WIFI_PS_MODE_WMM

WMM power save mode.

enum wifi_operational_modes

Wifi operational mode.

Values:

enumerator WIFI_STA_MODE = BIT(0)

STA mode setting enable.

enumerator WIFI_MONITOR_MODE = BIT(1)

Monitor mode setting enable.

enumerator WIFI_TX_INJECTION_MODE = BIT(2)

TX injection mode setting enable.

enumerator WIFI_PROMISCUOUS_MODE = BIT(3)

Promiscuous mode setting enable.

enumerator WIFI_AP_MODE = BIT(4)

AP mode setting enable.

enumerator WIFI_SOFTAP_MODE = BIT(5)

Softap mode setting enable.

enum wifi_filter

Mode filter settings.

Values:

enumerator WIFI_PACKET_FILTER_ALL = BIT(0)

Support management, data and control packet sniffing.

enumerator WIFI_PACKET_FILTER_MGMT = BIT(1)

Support only sniffing of management packets.

enumerator WIFI_PACKET_FILTER_DATA = BIT(2)

Support only sniffing of data packets.

enumerator WIFI_PACKET_FILTER_CTRL = BIT(3)

Support only sniffing of control packets.

enum wifi_twt_operation

Wi-Fi Target Wake Time (TWT) operations.

Values:

enumerator WIFI_TWT_SETUP = 0

TWT setup operation.

enumerator WIFI_TWT_TEARDOWN

TWT teardown operation.

enum wifi_twt_negotiation_type

Wi-Fi Target Wake Time (TWT) negotiation types.

Values:

enumerator WIFI_TWT_INDIVIDUAL = 0

TWT individual negotiation.

enumerator WIFI_TWT_BROADCAST

TWT broadcast negotiation.

enumerator WIFI_TWT_WAKE_TBTT

TWT wake TBTT negotiation.

enum wifi_twt_setup_cmd

Wi-Fi Target Wake Time (TWT) setup commands.

Values:

enumerator WIFI_TWT_SETUP_CMD_REQUEST = 0

TWT setup request.

enumerator WIFI_TWT_SETUP_CMD_SUGGEST

TWT setup suggest (parameters can be changed by AP)

enumerator WIFI_TWT_SETUP_CMD_DEMAND

TWT setup demand (parameters can not be changed by AP)

enumerator WIFI_TWT_SETUP_CMD_GROUPING

TWT setup grouping (grouping of TWT flows)

enumerator WIFI_TWT_SETUP_CMD_ACCEPT

TWT setup accept (parameters accepted by AP)

enumerator WIFI_TWT_SETUP_CMD_ALTERNATE

TWT setup alternate (alternate parameters suggested by AP)

enumerator WIFI_TWT_SETUP_CMD_DICTATE

TWT setup dictate (parameters dictated by AP)

enumerator WIFI_TWT_SETUP_CMD_REJECT

TWT setup reject (parameters rejected by AP)

enum wifi_twt_setup_resp_status

Wi-Fi Target Wake Time (TWT) negotiation status.

Values:

enumerator WIFI_TWT_RESP_RECEIVED = 0

TWT response received for TWT request.

enumerator WIFI_TWT_RESP_NOT_RECEIVED

TWT response not received for TWT request.

enum wifi_twt_fail_reason

Target Wake Time (TWT) error codes.

Values:

enumerator WIFI_TWT_FAIL_UNSPECIFIED

Unspecified error.

enumerator WIFI_TWT_FAIL_CMD_EXEC_FAIL

Command execution failed.

enumerator WIFI_TWT_FAIL_OPERATION_NOT_SUPPORTED

Operation not supported.

enumerator WIFI_TWT_FAIL_UNABLE_TO_GET_IFACE_STATUS

Unable to get interface status.

enumerator WIFI_TWT_FAIL_DEVICE_NOT_CONNECTED

Device not connected to AP.

enumerator WIFI_TWT_FAIL_PEER_NOT_HE_CAPAB

Peer not HE (802.11ax/Wi-Fi 6) capable.

enumerator WIFI_TWT_FAIL_PEER_NOT_TWT_CAPAB

Peer not TWT capable.

enumerator WIFI_TWT_FAIL_OPERATION_IN_PROGRESS

A TWT flow is already in progress.

enumerator WIFI_TWT_FAIL_INVALID_FLOW_ID

Invalid negotiated flow id.

enumerator WIFI_TWT_FAIL_IP_NOT_ASSIGNED

IP address not assigned or configured.

enumerator WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS

Flow already exists.

enum wifi_twt_teardown_status

Wi-Fi Target Wake Time (TWT) teradown status.

Values:

enumerator WIFI_TWT_TEARDOWN_SUCCESS = 0

TWT teardown success.

enumerator WIFI_TWT_TEARDOWN_FAILED

TWT teardown failure.

enum wifi_ps_param_type

Wi-Fi power save parameters.

Values:

enumerator WIFI_PS_PARAM_STATE

Power save state.

enumerator WIFI_PS_PARAM_LISTEN_INTERVAL

Power save listen interval.

enumerator WIFI_PS_PARAM_WAKEUP_MODE

Power save wakeup mode.

enumerator WIFI_PS_PARAM_MODE

Power save mode.

enumerator WIFI_PS_PARAM_TIMEOUT

Power save timeout.

enum wifi_ps_wakeup_mode

Wi-Fi power save modes.

Values:

enumerator WIFI_PS_WAKEUP_MODE_DTIM = 0

DTIM based wakeup.

enumerator WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL

Listen interval based wakeup.

enum wifi_config_ps_param_fail_reason

Wi-Fi power save error codes.

Values:

enumerator WIFI_PS_PARAM_FAIL_UNSPECIFIED

Unspecified error.

enumerator WIFI_PS_PARAM_FAIL_CMD_EXEC_FAIL

Command execution failed.

enumerator WIFI_PS_PARAM_FAIL_OPERATION_NOT_SUPPORTED

Parameter not supported.

enumerator WIFI_PS_PARAM_FAIL_UNABLE_TO_GET_IFACE_STATUS

Unable to get interface status.

enumerator WIFI_PS_PARAM_FAIL_DEVICE_NOT_CONNECTED

Device not connected to AP.

enumerator WIFI_PS_PARAM_FAIL_DEVICE_CONNECTED

Device already connected to AP.

enumerator WIFI_PS_PARAM_LISTEN_INTERVAL_RANGE_INVALID

Listen interval out of range.

enum wifi_ap_config_param

Wi-Fi AP mode configuration parameter.

Values:

enumerator WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY = BIT(0)

Used for AP mode configuration parameter ap_max_inactivity.

enumerator WIFI_AP_CONFIG_PARAM_MAX_NUM_STA = BIT(1)

Used for AP mode configuration parameter max_num_sta.

enum net_request_wifi_cmd

Wi-Fi management commands.

Values:

enumerator NET_REQUEST_WIFI_CMD_SCAN = 1

Scan for Wi-Fi networks.

enumerator NET_REQUEST_WIFI_CMD_CONNECT

Connect to a Wi-Fi network.

enumerator NET_REQUEST_WIFI_CMD_DISCONNECT

Disconnect from a Wi-Fi network.

enumerator NET_REQUEST_WIFI_CMD_AP_ENABLE

Enable AP mode.

enumerator NET_REQUEST_WIFI_CMD_AP_DISABLE

Disable AP mode.

enumerator NET_REQUEST_WIFI_CMD_IFACE_STATUS

Get interface status.

enumerator NET_REQUEST_WIFI_CMD_PS

Set power save status.

enumerator NET_REQUEST_WIFI_CMD_TWT

Setup or teardown TWT flow.

enumerator NET_REQUEST_WIFI_CMD_PS_CONFIG

Get power save config.

enumerator NET_REQUEST_WIFI_CMD_REG_DOMAIN

Set or get regulatory domain.

enumerator NET_REQUEST_WIFI_CMD_MODE

Set or get Mode of operation.

enumerator NET_REQUEST_WIFI_CMD_PACKET_FILTER

Set or get packet filter setting for current mode.

enumerator NET_REQUEST_WIFI_CMD_CHANNEL

Set or get Wi-Fi channel for Monitor or TX-Injection mode.

enumerator NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT

Disconnect a STA from AP.

enumerator NET_REQUEST_WIFI_CMD_VERSION

Get Wi-Fi driver and Firmware versions.

enumerator NET_REQUEST_WIFI_CMD_RTS_THRESHOLD

Set RTS threshold.

enumerator NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM

Configure AP parameter.

enum net_event_wifi_cmd

Wi-Fi management events.

Values:

enumerator NET_EVENT_WIFI_CMD_SCAN_RESULT = 1

Scan results available.

enumerator NET_EVENT_WIFI_CMD_SCAN_DONE

Scan done.

enumerator NET_EVENT_WIFI_CMD_CONNECT_RESULT

Connect result.

enumerator NET_EVENT_WIFI_CMD_DISCONNECT_RESULT

Disconnect result.

enumerator NET_EVENT_WIFI_CMD_IFACE_STATUS

Interface status.

enumerator NET_EVENT_WIFI_CMD_TWT

TWT events.

enumerator NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE

TWT sleep status: awake or sleeping, can be used by application to determine if it can send data or not.

enumerator NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT

Raw scan results available.

enumerator NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE

Disconnect complete.

enumerator NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT

AP mode enable result.

enumerator NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT

AP mode disable result.

enumerator NET_EVENT_WIFI_CMD_AP_STA_CONNECTED

STA connected to AP.

enumerator NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED

STA disconnected from AP.

enum wifi_conn_status

Wi-Fi connect result codes.

To be overlaid on top of wifi_status in the connect result event for detailed status.

Values:

enumerator WIFI_STATUS_CONN_SUCCESS = 0

Connection successful.

enumerator WIFI_STATUS_CONN_FAIL

Connection failed - generic failure.

enumerator WIFI_STATUS_CONN_WRONG_PASSWORD

Connection failed - wrong password Few possible reasons for 4-way handshake failure that we can guess are as follows: 1) Incorrect key 2) EAPoL frames lost causing timeout.

#1 is the likely cause, so, we convey to the user that it is due to Wrong passphrase/password.

enumerator WIFI_STATUS_CONN_TIMEOUT

Connection timed out.

enumerator WIFI_STATUS_CONN_AP_NOT_FOUND

Connection failed - AP not found.

enumerator WIFI_STATUS_CONN_LAST_STATUS

Last connection status.

enumerator WIFI_STATUS_DISCONN_FIRST_STATUS = WIFI_STATUS_CONN_LAST_STATUS

Connection disconnected status.

enum wifi_disconn_reason

Wi-Fi disconnect reason codes.

To be overlaid on top of wifi_status in the disconnect result event for detailed reason.

Values:

enumerator WIFI_REASON_DISCONN_SUCCESS = 0

Success, overload status as reason.

enumerator WIFI_REASON_DISCONN_UNSPECIFIED

Unspecified reason.

enumerator WIFI_REASON_DISCONN_USER_REQUEST

Disconnected due to user request.

enumerator WIFI_REASON_DISCONN_AP_LEAVING

Disconnected due to AP leaving.

enumerator WIFI_REASON_DISCONN_INACTIVITY

Disconnected due to inactivity.

enum wifi_ap_status

Wi-Fi AP mode result codes.

To be overlaid on top of wifi_status in the AP mode enable or disable result event for detailed status.

Values:

enumerator WIFI_STATUS_AP_SUCCESS = 0

AP mode enable or disable successful.

enumerator WIFI_STATUS_AP_FAIL

AP mode enable or disable failed - generic failure.

enumerator WIFI_STATUS_AP_CHANNEL_NOT_SUPPORTED

AP mode enable failed - channel not supported.

enumerator WIFI_STATUS_AP_CHANNEL_NOT_ALLOWED

AP mode enable failed - channel not allowed.

enumerator WIFI_STATUS_AP_SSID_NOT_ALLOWED

AP mode enable failed - SSID not allowed.

enumerator WIFI_STATUS_AP_AUTH_TYPE_NOT_SUPPORTED

AP mode enable failed - authentication type not supported.

enumerator WIFI_STATUS_AP_OP_NOT_SUPPORTED

AP mode enable failed - operation not supported.

enumerator WIFI_STATUS_AP_OP_NOT_PERMITTED

AP mode enable failed - operation not permitted.

enum wifi_mgmt_op

Generic get/set operation for any command.

Values:

enumerator WIFI_MGMT_GET = 0

Get operation.

enumerator WIFI_MGMT_SET = 1

Set operation.

enum wifi_twt_sleep_state

Wi-Fi TWT sleep states.

Values:

enumerator WIFI_TWT_STATE_SLEEP = 0

TWT sleep state: sleeping.

enumerator WIFI_TWT_STATE_AWAKE = 1

TWT sleep state: awake.

Functions

const char *wifi_security_txt(enum wifi_security_type security)

Helper function to get user-friendly security type name.

const char *wifi_mfp_txt(enum wifi_mfp_options mfp)

Helper function to get user-friendly MFP name.

const char *wifi_band_txt(enum wifi_frequency_bands band)

Helper function to get user-friendly frequency band name.

const char *wifi_state_txt(enum wifi_iface_state state)

Helper function to get user-friendly interface state name.

const char *wifi_mode_txt(enum wifi_iface_mode mode)

Helper function to get user-friendly interface mode name.

Helper function to get user-friendly link mode name.

const char *wifi_ps_txt(enum wifi_ps ps_name)

Helper function to get user-friendly ps name.

const char *wifi_ps_mode_txt(enum wifi_ps_mode ps_mode)

Helper function to get user-friendly ps mode name.

const char *wifi_twt_operation_txt(enum wifi_twt_operation twt_operation)

Helper function to get user-friendly twt operation name.

const char *wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation)

Helper function to get user-friendly twt negotiation type name.

const char *wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup)

Helper function to get user-friendly twt setup cmd name.

static inline const char *wifi_twt_get_err_code_str(int16_t err_no)

Helper function to get user-friendly TWT error code name.

const char *wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode)

Helper function to get user-friendly ps wakeup mode name.

static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no)

Helper function to get user-friendly power save error code name.

void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status)

Wi-Fi management connect result event.

Parameters:
  • iface – Network interface

  • status – Connect result status

void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status)

Wi-Fi management disconnect result event.

Parameters:
  • iface – Network interface

  • status – Disconnect result status

void wifi_mgmt_raise_iface_status_event(struct net_if *iface, struct wifi_iface_status *iface_status)

Wi-Fi management interface status event.

Parameters:
  • iface – Network interface

  • iface_status – Interface status

void wifi_mgmt_raise_twt_event(struct net_if *iface, struct wifi_twt_params *twt_params)

Wi-Fi management TWT event.

Parameters:
  • iface – Network interface

  • twt_params – TWT parameters

void wifi_mgmt_raise_twt_sleep_state(struct net_if *iface, int twt_sleep_state)

Wi-Fi management TWT sleep state event.

Parameters:
  • iface – Network interface

  • twt_sleep_state – TWT sleep state

void wifi_mgmt_raise_raw_scan_result_event(struct net_if *iface, struct wifi_raw_scan_result *raw_scan_info)

Wi-Fi management raw scan result event.

Parameters:
  • iface – Network interface

  • raw_scan_info – Raw scan result

void wifi_mgmt_raise_disconnect_complete_event(struct net_if *iface, int status)

Wi-Fi management disconnect complete event.

Parameters:
  • iface – Network interface

  • status – Disconnect complete status

void wifi_mgmt_raise_ap_enable_result_event(struct net_if *iface, enum wifi_ap_status status)

Wi-Fi management AP mode enable result event.

Parameters:
  • iface – Network interface

  • status – AP mode enable result status

void wifi_mgmt_raise_ap_disable_result_event(struct net_if *iface, enum wifi_ap_status status)

Wi-Fi management AP mode disable result event.

Parameters:
  • iface – Network interface

  • status – AP mode disable result status

void wifi_mgmt_raise_ap_sta_connected_event(struct net_if *iface, struct wifi_ap_sta_info *sta_info)

Wi-Fi management AP mode STA connected event.

Parameters:
  • iface – Network interface

  • sta_info – STA information

void wifi_mgmt_raise_ap_sta_disconnected_event(struct net_if *iface, struct wifi_ap_sta_info *sta_info)

Wi-Fi management AP mode STA disconnected event.

Parameters:
  • iface – Network interface

  • sta_info – STA information

struct wifi_version
#include <wifi_mgmt.h>

Wi-Fi version.

Public Members

const char *drv_version

Driver version.

const char *fw_version

Firmware version.

struct wifi_band_channel
#include <wifi_mgmt.h>

Wi-Fi structure to uniquely identify a band-channel pair.

Public Members

uint8_t band

Frequency band.

uint8_t channel

Channel.

struct wifi_scan_params
#include <wifi_mgmt.h>

Wi-Fi scan parameters structure.

Used to specify parameters which can control how the Wi-Fi scan is performed.

Public Members

enum wifi_scan_type scan_type

Scan type, see enum wifi_scan_type.

The scan_type is only a hint to the underlying Wi-Fi chip for the preferred mode of scan. The actual mode of scan can depend on factors such as the Wi-Fi chip implementation support, regulatory domain restrictions etc.

uint8_t bands

Bitmap of bands to be scanned.

Refer to wifi_frequency_bands for bit position of each band.

uint16_t dwell_time_active

Active scan dwell time (in ms) on a channel.

uint16_t dwell_time_passive

Passive scan dwell time (in ms) on a channel.

const char *ssids[WIFI_MGMT_SCAN_SSID_FILT_MAX]

Array of SSID strings to scan.

uint16_t max_bss_cnt

Specifies the maximum number of scan results to return.

These results would be the BSSIDS with the best RSSI values, in all the scanned channels. This should only be used to limit the number of returned scan results, and cannot be counted upon to limit the scan time, since the underlying Wi-Fi chip might have to scan all the channels to find the max_bss_cnt number of APs with the best signal strengths. A value of 0 signifies that there is no restriction on the number of scan results to be returned.

struct wifi_band_channel band_chan[WIFI_MGMT_SCAN_CHAN_MAX_MANUAL]

Channel information array indexed on Wi-Fi frequency bands and channels within that band.

E.g. to scan channel 6 and 11 on the 2.4 GHz band, channel 36 on the 5 GHz band:

chan[0] = {WIFI_FREQ_BAND_2_4_GHZ, 6};
chan[1] = {WIFI_FREQ_BAND_2_4_GHZ, 11};
chan[2] = {WIFI_FREQ_BAND_5_GHZ, 36};

This list specifies the channels to be considered for scan. The underlying Wi-Fi chip can silently omit some channels due to various reasons such as channels not conforming to regulatory restrictions etc. The invoker of the API should ensure that the channels specified follow regulatory rules.

struct wifi_scan_result
#include <wifi_mgmt.h>

Wi-Fi scan result, each result is provided to the net_mgmt_event_callback via its info attribute (see net_mgmt.h)

Public Members

uint8_t ssid[WIFI_SSID_MAX_LEN]

SSID.

uint8_t ssid_length

SSID length.

uint8_t band

Frequency band.

uint8_t channel

Channel.

enum wifi_security_type security

Security type.

enum wifi_mfp_options mfp

MFP options.

int8_t rssi

RSSI.

uint8_t mac[WIFI_MAC_ADDR_LEN]

BSSID.

uint8_t mac_length

BSSID length.

struct wifi_connect_req_params
#include <wifi_mgmt.h>

Wi-Fi connect request parameters.

Public Members

const uint8_t *ssid

SSID.

uint8_t ssid_length

SSID length.

const uint8_t *psk

Pre-shared key.

uint8_t psk_length

Pre-shared key length.

const uint8_t *sae_password

SAE password (same as PSK but with no length restrictions), optional.

uint8_t sae_password_length

SAE password length.

uint8_t band

Frequency band.

uint8_t channel

Channel.

enum wifi_security_type security

Security type.

enum wifi_mfp_options mfp

MFP options.

uint8_t bssid[WIFI_MAC_ADDR_LEN]

BSSID.

int timeout

Connect timeout in seconds, SYS_FOREVER_MS for no timeout.

struct wifi_status
#include <wifi_mgmt.h>

Generic Wi-Fi status for commands and events.

Public Members

int status

Status value.

enum wifi_conn_status conn_status

Connection status.

enum wifi_disconn_reason disconn_reason

Disconnection reason status.

enum wifi_ap_status ap_status

Access point status.

struct wifi_iface_status
#include <wifi_mgmt.h>

Wi-Fi interface status.

Public Members

int state

Interface state, see enum wifi_iface_state.

unsigned int ssid_len

SSID length.

char ssid[WIFI_SSID_MAX_LEN]

SSID.

char bssid[WIFI_MAC_ADDR_LEN]

BSSID.

enum wifi_frequency_bands band

Frequency band.

unsigned int channel

Channel.

enum wifi_iface_mode iface_mode

Interface mode, see enum wifi_iface_mode.

Link mode, see enum wifi_link_mode.

enum wifi_security_type security

Security type, see enum wifi_security_type.

enum wifi_mfp_options mfp

MFP options, see enum wifi_mfp_options.

int rssi

RSSI.

unsigned char dtim_period

DTIM period.

unsigned short beacon_interval

Beacon interval.

bool twt_capable

is TWT capable?

struct wifi_ps_params
#include <wifi_mgmt.h>

Wi-Fi power save parameters.

Public Members

enum wifi_ps enabled

Power save state.

unsigned short listen_interval

Listen interval.

enum wifi_ps_wakeup_mode wakeup_mode

Wi-Fi power save wakeup mode.

enum wifi_ps_mode mode

Wi-Fi power save mode.

unsigned int timeout_ms

Wi-Fi power save timeout.

This is the time out to wait after sending a TX packet before going back to power save (in ms) to receive any replies from the AP. Zero means this feature is disabled.

It’s a tradeoff between power consumption and latency.

enum wifi_ps_param_type type

Wi-Fi power save type.

enum wifi_config_ps_param_fail_reason fail_reason

Wi-Fi power save fail reason.

struct wifi_twt_params
#include <wifi_mgmt.h>

Wi-Fi TWT parameters.

Public Members

enum wifi_twt_operation operation

TWT operation, see enum wifi_twt_operation.

enum wifi_twt_negotiation_type negotiation_type

TWT negotiation type, see enum wifi_twt_negotiation_type.

enum wifi_twt_setup_cmd setup_cmd

TWT setup command, see enum wifi_twt_setup_cmd.

enum wifi_twt_setup_resp_status resp_status

TWT setup response status, see enum wifi_twt_setup_resp_status.

enum wifi_twt_teardown_status teardown_status

TWT teardown cmd status, see enum wifi_twt_teardown_status.

uint8_t dialog_token

Dialog token, used to map requests to responses.

uint8_t flow_id

Flow ID, used to map setup with teardown.

uint64_t twt_interval

Interval = Wake up time + Sleeping time.

bool responder

Requestor or responder.

bool trigger

Trigger enabled or disabled.

bool implicit

Implicit or explicit.

bool announce

Announced or unannounced.

uint32_t twt_wake_interval

Wake up time.

uint32_t twt_wake_ahead_duration

Wake ahead notification is sent earlier than TWT Service period (SP) start based on this duration.

This should give applications ample time to prepare the data before TWT SP starts.

struct wifi_twt_params setup

Setup specific parameters.

bool teardown_all

Teardown all flows.

struct wifi_twt_params teardown

Teardown specific parameters.

enum wifi_twt_fail_reason fail_reason

TWT fail reason, see enum wifi_twt_fail_reason.

struct wifi_twt_flow_info
#include <wifi_mgmt.h>

Wi-Fi TWT flow information.

Public Members

uint64_t twt_interval

Interval = Wake up time + Sleeping time.

uint8_t dialog_token

Dialog token, used to map requests to responses.

uint8_t flow_id

Flow ID, used to map setup with teardown.

enum wifi_twt_negotiation_type negotiation_type

TWT negotiation type, see enum wifi_twt_negotiation_type.

bool responder

Requestor or responder.

bool trigger

Trigger enabled or disabled.

bool implicit

Implicit or explicit.

bool announce

Announced or unannounced.

uint32_t twt_wake_interval

Wake up time.

uint32_t twt_wake_ahead_duration

Wake ahead duration.

struct wifi_ps_config
#include <wifi_mgmt.h>

Wi-Fi power save configuration.

Public Members

char num_twt_flows

Number of TWT flows.

struct wifi_twt_flow_info twt_flows[WIFI_MAX_TWT_FLOWS]

TWT flow details.

struct wifi_ps_params ps_params

Power save configuration.

struct wifi_reg_chan_info
#include <wifi_mgmt.h>

Per-channel regulatory attributes.

Public Members

unsigned short center_frequency

Center frequency in MHz.

unsigned short max_power

Maximum transmission power (in dBm)

unsigned short supported

Is channel supported or not.

unsigned short passive_only

Passive transmissions only.

unsigned short dfs

Is a DFS channel.

struct wifi_reg_domain
#include <wifi_mgmt.h>

Regulatory domain information or configuration.

Public Members

enum wifi_mgmt_op oper

Regulatory domain operation.

bool force

Ignore all other regulatory hints over this one.

uint8_t country_code[WIFI_COUNTRY_CODE_LEN]

Country code: ISO/IEC 3166-1 alpha-2.

unsigned int num_channels

Number of channels supported.

struct wifi_reg_chan_info *chan_info

Channels information.

struct wifi_raw_scan_result
#include <wifi_mgmt.h>

Wi-Fi raw scan result.

Public Members

int8_t rssi

RSSI.

int frame_length

Frame length.

unsigned short frequency

Frequency.

uint8_t data[CONFIG_WIFI_MGMT_RAW_SCAN_RESULT_LENGTH]

Raw scan data.

struct wifi_ap_sta_info
#include <wifi_mgmt.h>

AP mode - connected STA details.

Public Members

Link mode, see enum wifi_link_mode.

uint8_t mac[WIFI_MAC_ADDR_LEN]

MAC address.

uint8_t mac_length

MAC address length.

bool twt_capable

is TWT capable ?

struct wifi_mode_info
#include <wifi_mgmt.h>

Wi-Fi mode setup.

Public Members

uint8_t mode

Mode setting for a specific mode of operation.

uint8_t if_index

Interface index.

enum wifi_mgmt_op oper

Get or set operation.

struct wifi_filter_info
#include <wifi_mgmt.h>

Wi-Fi filter setting for monitor, prmoiscuous, TX-injection modes.

Public Members

uint8_t filter

Filter setting.

uint8_t if_index

Interface index.

uint16_t buffer_size

Filter buffer size.

enum wifi_mgmt_op oper

Get or set operation.

struct wifi_channel_info
#include <wifi_mgmt.h>

Wi-Fi channel setting for monitor and TX-injection modes.

Public Members

uint16_t channel

Channel value to set.

uint8_t if_index

Interface index.

enum wifi_mgmt_op oper

Get or set operation.

struct wifi_ap_config_params
#include <wifi_mgmt.h>

Wi-Fi AP configuration parameter.

Public Members

enum wifi_ap_config_param type

Parameter used to identify the different AP parameters.

uint32_t max_inactivity

Parameter used for setting maximum inactivity duration for stations.

uint32_t max_num_sta

Parameter used for setting maximum number of stations.

struct wifi_mgmt_ops
#include <wifi_mgmt.h>

Wi-Fi management API.

Public Members

int (*scan)(const struct device *dev, struct wifi_scan_params *params, scan_result_cb_t cb)

Scan for Wi-Fi networks.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

Scan parameters

Param cb:

Callback to be called for each result cb parameter is the cb that should be called for each result by the driver. The wifi mgmt part will take care of raising the necessary event etc.

Return:

0 if ok, < 0 if error

int (*connect)(const struct device *dev, struct wifi_connect_req_params *params)

Connect to a Wi-Fi network.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

Connect parameters

Return:

0 if ok, < 0 if error

int (*disconnect)(const struct device *dev)

Disconnect from a Wi-Fi network.

Param dev:

Pointer to the device structure for the driver instance.

Return:

0 if ok, < 0 if error

int (*ap_enable)(const struct device *dev, struct wifi_connect_req_params *params)

Enable AP mode.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

AP mode parameters

Return:

0 if ok, < 0 if error

int (*ap_disable)(const struct device *dev)

Disable AP mode.

Param dev:

Pointer to the device structure for the driver instance.

Return:

0 if ok, < 0 if error

int (*ap_sta_disconnect)(const struct device *dev, const uint8_t *mac)

Disconnect a STA from AP.

Param dev:

Pointer to the device structure for the driver instance.

Param mac:

MAC address of the STA to disconnect

Return:

0 if ok, < 0 if error

int (*iface_status)(const struct device *dev, struct wifi_iface_status *status)

Get interface status.

Param dev:

Pointer to the device structure for the driver instance.

Param status:

Interface status

Return:

0 if ok, < 0 if error

int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats)

Get Wi-Fi statistics.

Param dev:

Pointer to the device structure for the driver instance.

Param stats:

Wi-Fi statistics

Return:

0 if ok, < 0 if error

int (*set_power_save)(const struct device *dev, struct wifi_ps_params *params)

Set power save status.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

Power save parameters

Return:

0 if ok, < 0 if error

int (*set_twt)(const struct device *dev, struct wifi_twt_params *params)

Setup or teardown TWT flow.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

TWT parameters

Return:

0 if ok, < 0 if error

int (*get_power_save_config)(const struct device *dev, struct wifi_ps_config *config)

Get power save config.

Param dev:

Pointer to the device structure for the driver instance.

Param config:

Power save config

Return:

0 if ok, < 0 if error

int (*reg_domain)(const struct device *dev, struct wifi_reg_domain *reg_domain)

Set or get regulatory domain.

Param dev:

Pointer to the device structure for the driver instance.

Param reg_domain:

Regulatory domain

Return:

0 if ok, < 0 if error

int (*filter)(const struct device *dev, struct wifi_filter_info *filter)

Set or get packet filter settings for monitor and promiscuous modes.

Param dev:

Pointer to the device structure for the driver instance.

Param packet:

filter settings

Return:

0 if ok, < 0 if error

int (*mode)(const struct device *dev, struct wifi_mode_info *mode)

Set or get mode of operation.

Param dev:

Pointer to the device structure for the driver instance.

Param mode:

settings

Return:

0 if ok, < 0 if error

int (*channel)(const struct device *dev, struct wifi_channel_info *channel)

Set or get current channel of operation.

Param dev:

Pointer to the device structure for the driver instance.

Param channel:

settings

Return:

0 if ok, < 0 if error

int (*get_version)(const struct device *dev, struct wifi_version *params)

Get Version of WiFi driver and Firmware.

The driver that implements the get_version function must not use stack to allocate the version information pointers that are returned as params struct members. The version pointer parameters should point to a static memory either in ROM (preferred) or in RAM.

Param dev:

Pointer to the device structure for the driver instance

Param params:

Version parameters

Return:

0 if ok, < 0 if error

int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold)

Set RTS threshold value.

Param dev:

Pointer to the device structure for the driver instance.

Param RTS:

threshold value

Return:

0 if ok, < 0 if error

int (*ap_config_params)(const struct device *dev, struct wifi_ap_config_params *params)

Configure AP parameter.

Param dev:

Pointer to the device structure for the driver instance.

Param params:

AP mode parameter configuration parameter info

Return:

0 if ok, < 0 if error

struct net_wifi_mgmt_offload
#include <wifi_mgmt.h>

Wi-Fi management offload API.

Public Members

struct ethernet_api wifi_iface

Mandatory to get in first position.

A network device should indeed provide a pointer on such net_if_api structure. So we make current structure pointer that can be casted to a net_if_api structure pointer. Ethernet API

const struct wifi_mgmt_ops *const wifi_mgmt_api

Wi-Fi management API.

const void *wifi_drv_ops

Wi-Fi supplicant driver API.