| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838 |
- /*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2022 Espressif Systems (Shanghai) PTE LTD
- * SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0
- */
- /** prevent recursive inclusion **/
- #ifndef __CTRL_API_H
- #define __CTRL_API_H
- #include <stdbool.h>
- #include "esp_hosted_config.pb-c.h"
- #define SUCCESS 0
- #define FAILURE -1
- #define MAC_SIZE_BYTES 6
- #define SSID_LENGTH 33
- #define MAX_MAC_STR_SIZE 18
- #define BSSID_STR_SIZE MAX_MAC_STR_SIZE
- #define PASSWORD_LENGTH 65
- #define STATUS_LENGTH 14
- #define VENDOR_OUI_BUF 3
- #define CALLBACK_SET_SUCCESS 0
- #define CALLBACK_AVAILABLE 0
- #define CALLBACK_NOT_REGISTERED -1
- #define MSG_ID_OUT_OF_ORDER -2
- #define MAX_FREE_BUFF_HANDLES 20
- /* If request is already being served and
- * another request is pending, time period for
- * which new request will wait in seconds
- * */
- #define WAIT_TIME_B2B_CTRL_REQ 5
- #define DEFAULT_CTRL_RESP_TIMEOUT 30
- #define DEFAULT_CTRL_RESP_AP_SCAN_TIMEOUT (60*3)
- #define DEFAULT_CTRL_RESP_CONNECT_AP_TIMEOUT (15*3)
- #ifndef MAC2STR
- #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
- #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
- #endif
- /*---- Control structures ----*/
- enum {
- CTRL_ERR_NOT_CONNECTED = 1,
- CTRL_ERR_NO_AP_FOUND,
- CTRL_ERR_INVALID_PASSWORD,
- CTRL_ERR_INVALID_ARGUMENT,
- CTRL_ERR_OUT_OF_RANGE,
- CTRL_ERR_MEMORY_FAILURE,
- CTRL_ERR_UNSUPPORTED_MSG,
- CTRL_ERR_INCORRECT_ARG,
- CTRL_ERR_PROTOBUF_ENCODE,
- CTRL_ERR_PROTOBUF_DECODE,
- CTRL_ERR_SET_ASYNC_CB,
- CTRL_ERR_TRANSPORT_SEND,
- CTRL_ERR_REQUEST_TIMEOUT,
- CTRL_ERR_REQ_IN_PROG,
- OUT_OF_RANGE
- };
- typedef enum {
- CTRL_MSGTYPE_INVALID = CTRL_MSG_TYPE__MsgType_Invalid,
- CTRL_REQ = CTRL_MSG_TYPE__Req,
- CTRL_RESP = CTRL_MSG_TYPE__Resp,
- CTRL_EVENT = CTRL_MSG_TYPE__Event,
- CTRL_MSGTYPE_MAX = CTRL_MSG_TYPE__MsgType_Max,
- } AppMsgType_e;
- typedef enum {
- CTRL_MSGID_INVALID = CTRL_MSG_ID__MsgId_Invalid,
- /*
- ** Request Msgs *
- */
- CTRL_REQ_BASE = CTRL_MSG_ID__Req_Base,
- CTRL_REQ_GET_MAC_ADDR = CTRL_MSG_ID__Req_GetMACAddress, //0x65
- CTRL_REQ_SET_MAC_ADDR = CTRL_MSG_ID__Req_SetMacAddress, //0x66
- CTRL_REQ_GET_WIFI_MODE = CTRL_MSG_ID__Req_GetWifiMode, //0x67
- CTRL_REQ_SET_WIFI_MODE = CTRL_MSG_ID__Req_SetWifiMode, //0x68
- CTRL_REQ_GET_AP_SCAN_LIST = CTRL_MSG_ID__Req_GetAPScanList, //0x69
- CTRL_REQ_GET_AP_CONFIG = CTRL_MSG_ID__Req_GetAPConfig, //0x6a
- CTRL_REQ_CONNECT_AP = CTRL_MSG_ID__Req_ConnectAP, //0x6b
- CTRL_REQ_DISCONNECT_AP = CTRL_MSG_ID__Req_DisconnectAP, //0x6c
- CTRL_REQ_GET_SOFTAP_CONFIG = CTRL_MSG_ID__Req_GetSoftAPConfig, //0x6d
- CTRL_REQ_SET_SOFTAP_VND_IE = CTRL_MSG_ID__Req_SetSoftAPVendorSpecificIE, //0x6e
- CTRL_REQ_START_SOFTAP = CTRL_MSG_ID__Req_StartSoftAP, //0x6f
- CTRL_REQ_GET_SOFTAP_CONN_STA_LIST = CTRL_MSG_ID__Req_GetSoftAPConnectedSTAList, //0x70
- CTRL_REQ_STOP_SOFTAP = CTRL_MSG_ID__Req_StopSoftAP, //0x71
- CTRL_REQ_SET_PS_MODE = CTRL_MSG_ID__Req_SetPowerSaveMode, //0x72
- CTRL_REQ_GET_PS_MODE = CTRL_MSG_ID__Req_GetPowerSaveMode, //0x73
- CTRL_REQ_OTA_BEGIN = CTRL_MSG_ID__Req_OTABegin, //0x74
- CTRL_REQ_OTA_WRITE = CTRL_MSG_ID__Req_OTAWrite, //0x75
- CTRL_REQ_OTA_END = CTRL_MSG_ID__Req_OTAEnd, //0x76
- CTRL_REQ_SET_WIFI_MAX_TX_POWER = CTRL_MSG_ID__Req_SetWifiMaxTxPower, //0x77
- CTRL_REQ_GET_WIFI_CURR_TX_POWER = CTRL_MSG_ID__Req_GetWifiCurrTxPower, //0x78
- CTRL_REQ_CONFIG_HEARTBEAT = CTRL_MSG_ID__Req_ConfigHeartbeat, //0x79
- CTRL_REQ_ENABLE_DISABLE = CTRL_MSG_ID__Req_EnableDisable, //0x7a
- CTRL_REQ_GET_FW_VERSION = CTRL_MSG_ID__Req_GetFwVersion, //0x7b
- /*
- * Add new control path command response before Req_Max
- * and update Req_Max
- */
- CTRL_REQ_MAX = CTRL_MSG_ID__Req_Max,
- /*
- ** Response Msgs *
- */
- CTRL_RESP_BASE = CTRL_MSG_ID__Resp_Base,
- CTRL_RESP_GET_MAC_ADDR = CTRL_MSG_ID__Resp_GetMACAddress, //0x65 -> 0xc9
- CTRL_RESP_SET_MAC_ADDRESS = CTRL_MSG_ID__Resp_SetMacAddress, //0x66 -> 0xca
- CTRL_RESP_GET_WIFI_MODE = CTRL_MSG_ID__Resp_GetWifiMode, //0x67 -> 0xcb
- CTRL_RESP_SET_WIFI_MODE = CTRL_MSG_ID__Resp_SetWifiMode, //0x68 -> 0xcc
- CTRL_RESP_GET_AP_SCAN_LIST = CTRL_MSG_ID__Resp_GetAPScanList, //0x69 -> 0xcd
- CTRL_RESP_GET_AP_CONFIG = CTRL_MSG_ID__Resp_GetAPConfig, //0x6a -> 0xce
- CTRL_RESP_CONNECT_AP = CTRL_MSG_ID__Resp_ConnectAP, //0x6b -> 0xdf
- CTRL_RESP_DISCONNECT_AP = CTRL_MSG_ID__Resp_DisconnectAP, //0x6c -> 0xd0
- CTRL_RESP_GET_SOFTAP_CONFIG = CTRL_MSG_ID__Resp_GetSoftAPConfig, //0x6d -> 0xd1
- CTRL_RESP_SET_SOFTAP_VND_IE = CTRL_MSG_ID__Resp_SetSoftAPVendorSpecificIE, //0x6e -> 0xd2
- CTRL_RESP_START_SOFTAP = CTRL_MSG_ID__Resp_StartSoftAP, //0x6f -> 0xd3
- CTRL_RESP_GET_SOFTAP_CONN_STA_LIST = CTRL_MSG_ID__Resp_GetSoftAPConnectedSTAList, //0x70 -> 0xd4
- CTRL_RESP_STOP_SOFTAP = CTRL_MSG_ID__Resp_StopSoftAP, //0x71 -> 0xd5
- CTRL_RESP_SET_PS_MODE = CTRL_MSG_ID__Resp_SetPowerSaveMode, //0x72 -> 0xd6
- CTRL_RESP_GET_PS_MODE = CTRL_MSG_ID__Resp_GetPowerSaveMode, //0x73 -> 0xd7
- CTRL_RESP_OTA_BEGIN = CTRL_MSG_ID__Resp_OTABegin, //0x74 -> 0xd8
- CTRL_RESP_OTA_WRITE = CTRL_MSG_ID__Resp_OTAWrite, //0x75 -> 0xd9
- CTRL_RESP_OTA_END = CTRL_MSG_ID__Resp_OTAEnd, //0x76 -> 0xda
- CTRL_RESP_SET_WIFI_MAX_TX_POWER = CTRL_MSG_ID__Resp_SetWifiMaxTxPower, //0x77 -> 0xdb
- CTRL_RESP_GET_WIFI_CURR_TX_POWER = CTRL_MSG_ID__Resp_GetWifiCurrTxPower, //0x78 -> 0xdc
- CTRL_RESP_CONFIG_HEARTBEAT = CTRL_MSG_ID__Resp_ConfigHeartbeat, //0x79 -> 0xdd
- CTRL_RESP_ENABLE_DISABLE = CTRL_MSG_ID__Resp_EnableDisable, //0x7a -> 0xde
- CTRL_RESP_GET_FW_VERSION = CTRL_MSG_ID__Resp_GetFwVersion, //0x7b -> 0xdf
- /*
- * Add new control path comm and response before Resp_Max
- * and update Resp_Max
- */
- CTRL_RESP_MAX = CTRL_MSG_ID__Resp_Max,
- /*
- ** Events
- */
- CTRL_EVENT_BASE = CTRL_MSG_ID__Event_Base,
- CTRL_EVENT_ESP_INIT = CTRL_MSG_ID__Event_ESPInit,
- CTRL_EVENT_HEARTBEAT = CTRL_MSG_ID__Event_Heartbeat,
- CTRL_EVENT_STATION_DISCONNECT_FROM_AP =
- CTRL_MSG_ID__Event_StationDisconnectFromAP,
- CTRL_EVENT_STATION_DISCONNECT_FROM_ESP_SOFTAP =
- CTRL_MSG_ID__Event_StationDisconnectFromESPSoftAP,
- CTRL_EVENT_STATION_CONNECTED_TO_AP =
- CTRL_MSG_ID__Event_StationConnectedToAP,
- CTRL_EVENT_STATION_CONNECTED_TO_ESP_SOFTAP =
- CTRL_MSG_ID__Event_StationConnectedToESPSoftAP,
- /*
- * Add new control path command notification before Event_Max
- * and update Event_Max
- */
- CTRL_EVENT_MAX = CTRL_MSG_ID__Event_Max,
- } AppMsgId_e;
- typedef enum {
- WIFI_MODE_NONE = CTRL__WIFI_MODE__NONE,
- WIFI_MODE_STA = CTRL__WIFI_MODE__STA,
- WIFI_MODE_AP = CTRL__WIFI_MODE__AP,
- WIFI_MODE_APSTA = CTRL__WIFI_MODE__APSTA,
- WIFI_MODE_MAX
- } wifi_mode_e;
- typedef enum {
- WIFI_BW_HT20 = CTRL__WIFI_BW__HT20,
- WIFI_BW_HT40 = CTRL__WIFI_BW__HT40,
- } wifi_bandwidth_e;
- typedef enum {
- WIFI_PS_MIN_MODEM = CTRL__WIFI_POWER_SAVE__MIN_MODEM,
- WIFI_PS_MAX_MODEM = CTRL__WIFI_POWER_SAVE__MAX_MODEM,
- WIFI_PS_INVALID,
- } wifi_ps_type_e;
- typedef enum {
- WIFI_VND_IE_TYPE_BEACON = CTRL__VENDOR_IETYPE__Beacon,
- WIFI_VND_IE_TYPE_PROBE_REQ = CTRL__VENDOR_IETYPE__Probe_req,
- WIFI_VND_IE_TYPE_PROBE_RESP = CTRL__VENDOR_IETYPE__Probe_resp,
- WIFI_VND_IE_TYPE_ASSOC_REQ = CTRL__VENDOR_IETYPE__Assoc_req,
- WIFI_VND_IE_TYPE_ASSOC_RESP = CTRL__VENDOR_IETYPE__Assoc_resp,
- } wifi_vendor_ie_type_e;
- typedef enum {
- WIFI_VND_IE_ID_0 = CTRL__VENDOR_IEID__ID_0,
- WIFI_VND_IE_ID_1 = CTRL__VENDOR_IEID__ID_1,
- } wifi_vendor_ie_id_e;
- enum hosted_features_t {
- HOSTED_WIFI = HOSTED_FEATURE__Hosted_Wifi,
- HOSTED_BT = HOSTED_FEATURE__Hosted_Bluetooth,
- };
- typedef struct {
- /* Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */
- uint8_t element_id;
- /* Len of all bytes in the element data
- * following this field. Minimum 4 */
- uint8_t length;
- /* Vendor identifier (OUI) */
- uint8_t vendor_oui[VENDOR_OUI_BUF];
- /* Vendor-specific OUI type */
- uint8_t vendor_oui_type;
- /*length of payload field*/
- uint16_t payload_len;
- /* Payload. Length is equal to value in 'length' field, minus 4 */
- uint8_t* payload;
- } vendor_ie_data_t;
- /**
- * @brief Wi-Fi second channel type
- */
- typedef enum {
- WIFI_SECOND_CHAN_NONE = 0, /**< The channel width is HT20 */
- WIFI_SECOND_CHAN_ABOVE, /**< The channel width is HT40 and the secondary channel is above the primary channel */
- WIFI_SECOND_CHAN_BELOW, /**< The channel width is HT40 and the secondary channel is below the primary channel */
- } wifi_second_chan_t;
- /**
- * @brief Wi-Fi authmode type
- * Strength of authmodes
- * Personal Networks : OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA3_PSK = WPA2_WPA3_PSK = DPP
- * Enterprise Networks : WIFI_AUTH_WPA2_ENTERPRISE < WIFI_AUTH_WPA3_ENTERPRISE = WIFI_AUTH_WPA2_WPA3_ENTERPRISE < WIFI_AUTH_WPA3_ENT_192
- */
- typedef enum {
- WIFI_AUTH_OPEN = 0, /**< Authenticate mode : open */
- WIFI_AUTH_WEP, /**< Authenticate mode : WEP */
- WIFI_AUTH_WPA_PSK, /**< Authenticate mode : WPA_PSK */
- WIFI_AUTH_WPA2_PSK, /**< Authenticate mode : WPA2_PSK */
- WIFI_AUTH_WPA_WPA2_PSK, /**< Authenticate mode : WPA_WPA2_PSK */
- WIFI_AUTH_ENTERPRISE, /**< Authenticate mode : Wi-Fi EAP security */
- WIFI_AUTH_WPA2_ENTERPRISE = WIFI_AUTH_ENTERPRISE, /**< Authenticate mode : Wi-Fi EAP security */
- WIFI_AUTH_WPA3_PSK, /**< Authenticate mode : WPA3_PSK */
- WIFI_AUTH_WPA2_WPA3_PSK, /**< Authenticate mode : WPA2_WPA3_PSK */
- WIFI_AUTH_WAPI_PSK, /**< Authenticate mode : WAPI_PSK */
- WIFI_AUTH_OWE, /**< Authenticate mode : OWE */
- WIFI_AUTH_WPA3_ENT_192, /**< Authenticate mode : WPA3_ENT_SUITE_B_192_BIT */
- WIFI_AUTH_WPA3_EXT_PSK, /**< This authentication mode will yield same result as WIFI_AUTH_WPA3_PSK and not recommended to be used. It will be deprecated in future, please use WIFI_AUTH_WPA3_PSK instead. */
- WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE, /**< This authentication mode will yield same result as WIFI_AUTH_WPA3_PSK and not recommended to be used. It will be deprecated in future, please use WIFI_AUTH_WPA3_PSK instead.*/
- WIFI_AUTH_DPP, /**< Authenticate mode : DPP */
- WIFI_AUTH_MAX
- } wifi_auth_mode_t;
- /**
- * @brief Wi-Fi cipher type
- */
- typedef enum {
- WIFI_CIPHER_TYPE_NONE = 0, /**< The cipher type is none */
- WIFI_CIPHER_TYPE_WEP40, /**< The cipher type is WEP40 */
- WIFI_CIPHER_TYPE_WEP104, /**< The cipher type is WEP104 */
- WIFI_CIPHER_TYPE_TKIP, /**< The cipher type is TKIP */
- WIFI_CIPHER_TYPE_CCMP, /**< The cipher type is CCMP */
- WIFI_CIPHER_TYPE_TKIP_CCMP, /**< The cipher type is TKIP and CCMP */
- WIFI_CIPHER_TYPE_AES_CMAC128,/**< The cipher type is AES-CMAC-128 */
- WIFI_CIPHER_TYPE_SMS4, /**< The cipher type is SMS4 */
- WIFI_CIPHER_TYPE_GCMP, /**< The cipher type is GCMP */
- WIFI_CIPHER_TYPE_GCMP256, /**< The cipher type is GCMP-256 */
- WIFI_CIPHER_TYPE_AES_GMAC128,/**< The cipher type is AES-GMAC-128 */
- WIFI_CIPHER_TYPE_AES_GMAC256,/**< The cipher type is AES-GMAC-256 */
- WIFI_CIPHER_TYPE_UNKNOWN, /**< The cipher type is unknown */
- } wifi_cipher_type_t;
- /**
- * @brief Wi-Fi antenna
- */
- typedef enum {
- WIFI_ANT_ANT0, /**< Wi-Fi antenna 0 */
- WIFI_ANT_ANT1, /**< Wi-Fi antenna 1 */
- WIFI_ANT_MAX, /**< Invalid Wi-Fi antenna */
- } wifi_ant_t;
- /**
- * @brief Wi-Fi country policy
- */
- typedef enum {
- WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */
- WIFI_COUNTRY_POLICY_MANUAL, /**< Country policy is manual, always use the configured country info */
- } wifi_country_policy_t;
- /**
- * @brief Structure describing Wi-Fi country-based regional restrictions.
- */
- typedef struct {
- char cc[3]; /**< Country code string */
- uint8_t schan; /**< Start channel of the allowed 2.4GHz Wi-Fi channels */
- uint8_t nchan; /**< Total channel number of the allowed 2.4GHz Wi-Fi channels */
- int8_t max_tx_power; /**< This field is used for getting Wi-Fi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */
- wifi_country_policy_t policy; /**< Country policy */
- } wifi_country_t;
- /**
- * @brief Description of a Wi-Fi AP HE Info
- */
- typedef struct {
- uint8_t bss_color: 6; /**< The BSS Color value associated with the AP's corresponding BSS */
- uint8_t partial_bss_color: 1; /**< Indicates whether an AID assignment rule is based on the BSS color */
- uint8_t bss_color_disabled: 1; /**< Indicates whether the BSS color usage is disabled */
- uint8_t bssid_index; /**< In a M-BSSID set, identifies the non-transmitted BSSID */
- } wifi_he_ap_info_t;
- /**
- * @brief Configuration structure for Protected Management Frame
- */
- typedef struct {
- bool capable; /**< Deprecated variable. Device will always connect in PMF mode if other device also advertises PMF capability. */
- bool required; /**< Advertises that Protected Management Frame is required. Device will not associate to non-PMF capable devices. */
- } wifi_pmf_config_t;
- /**
- * @brief Configuration for SAE PWE derivation
- */
- typedef enum {
- WPA3_SAE_PWE_UNSPECIFIED,
- WPA3_SAE_PWE_HUNT_AND_PECK,
- WPA3_SAE_PWE_HASH_TO_ELEMENT,
- WPA3_SAE_PWE_BOTH,
- } wifi_sae_pwe_method_t;
- /**
- * @brief Description of a Wi-Fi AP
- */
- typedef struct {
- uint8_t bssid[6]; /**< MAC address of AP */
- uint8_t ssid[33]; /**< SSID of AP */
- uint8_t primary; /**< Channel of AP */
- wifi_second_chan_t second; /**< Secondary channel of AP */
- int8_t rssi; /**< Signal strength of AP. Note that in some rare cases where signal strength is very strong, RSSI values can be slightly positive */
- wifi_auth_mode_t authmode; /**< Auth mode of AP */
- wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of AP */
- wifi_cipher_type_t group_cipher; /**< Group cipher of AP */
- wifi_ant_t ant; /**< Antenna used to receive beacon from AP */
- uint32_t phy_11b: 1; /**< Bit: 0 flag to identify if 11b mode is enabled or not */
- uint32_t phy_11g: 1; /**< Bit: 1 flag to identify if 11g mode is enabled or not */
- uint32_t phy_11n: 1; /**< Bit: 2 flag to identify if 11n mode is enabled or not */
- uint32_t phy_lr: 1; /**< Bit: 3 flag to identify if low rate is enabled or not */
- uint32_t phy_11a: 1; /**< Bit: 4 flag to identify if 11ax mode is enabled or not */
- uint32_t phy_11ac: 1; /**< Bit: 5 flag to identify if 11ax mode is enabled or not */
- uint32_t phy_11ax: 1; /**< Bit: 6 flag to identify if 11ax mode is enabled or not */
- uint32_t wps: 1; /**< Bit: 7 flag to identify if WPS is supported or not */
- uint32_t ftm_responder: 1; /**< Bit: 8 flag to identify if FTM is supported in responder mode */
- uint32_t ftm_initiator: 1; /**< Bit: 9 flag to identify if FTM is supported in initiator mode */
- uint32_t reserved: 22; /**< Bit: 10..31 reserved */
- wifi_country_t country; /**< Country information of AP */
- wifi_he_ap_info_t he_ap; /**< HE AP info */
- uint8_t bandwidth; /**< For AP 20 MHz this value is set to 1. For AP 40 MHz this value is set to 2.
- For AP 80 MHz this value is set to 3. For AP 160MHz this value is set to 4.
- For AP 80+80MHz this value is set to 5*/
- uint8_t vht_ch_freq1; /**< This fields are used only AP bandwidth is 80 and 160 MHz, to transmit the center channel
- frequency of the BSS. For AP bandwidth is 80 + 80 MHz, it is the center channel frequency
- of the lower frequency segment.*/
- uint8_t vht_ch_freq2; /**< This fields are used only AP bandwidth is 80 + 80 MHz, and is used to transmit the center
- channel frequency of the second segment. */
- } wifi_ap_record_t;
- /**
- * @brief Wi-Fi scan method
- */
- typedef enum {
- WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
- WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
- } wifi_scan_method_t;
- /**
- * @brief Wi-Fi sort AP method
- */
- typedef enum {
- WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
- WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
- } wifi_sort_method_t;
- /**
- * @brief Structure describing parameters for a Wi-Fi fast scan
- */
- typedef struct {
- int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
- wifi_auth_mode_t authmode; /**< The weakest auth mode to accept in the fast scan mode
- Note: In case this value is not set and password is set as per WPA2 standards(password len >= 8), it will be defaulted to WPA2 and device won't connect to deprecated WEP/WPA networks. Please set auth mode threshold as WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK to connect to WEP/WPA networks */
- } wifi_scan_threshold_t;
- /**
- * @brief Configuration for SAE-PK
- */
- typedef enum {
- WPA3_SAE_PK_MODE_AUTOMATIC = 0,
- WPA3_SAE_PK_MODE_ONLY = 1,
- WPA3_SAE_PK_MODE_DISABLED = 2,
- } wifi_sae_pk_mode_t;
- /**
- * @brief Soft-AP configuration settings for the device
- */
- typedef struct {
- uint8_t ssid[32]; /**< SSID of soft-AP. If ssid_len field is 0, this must be a Null terminated string. Otherwise, length is set according to ssid_len. */
- uint8_t password[64]; /**< Password of soft-AP. */
- uint8_t ssid_len; /**< Optional length of SSID field. */
- uint8_t channel; /**< Channel of soft-AP */
- wifi_auth_mode_t authmode; /**< Auth mode of soft-AP. Do not support AUTH_WEP, AUTH_WAPI_PSK and AUTH_OWE in soft-AP mode. When the auth mode is set to WPA2_PSK, WPA2_WPA3_PSK or WPA3_PSK, the pairwise cipher will be overwritten with WIFI_CIPHER_TYPE_CCMP. */
- uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */
- uint8_t max_connection; /**< Max number of stations allowed to connect in */
- uint16_t beacon_interval; /**< Beacon interval which should be multiples of 100. Unit: TU(time unit, 1 TU = 1024 us). Range: 100 ~ 60000. Default value: 100 */
- uint8_t csa_count; /**< Channel Switch Announcement Count. Notify the station that the channel will switch after the csa_count beacon intervals. Range: 1 ~ 30. Default value: 3 */
- uint8_t dtim_period; /**< Dtim period of soft-AP. Range: 1 ~ 10. Default value: 1 */
- wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of SoftAP, group cipher will be derived using this. Cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */
- bool ftm_responder; /**< Enable FTM Responder mode */
- wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame */
- wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */
- } wifi_ap_config_t;
- #define SAE_H2E_IDENTIFIER_LEN 32 /**< Length of the password identifier for H2E */
- /**
- * @brief STA configuration settings for the device
- */
- typedef struct {
- uint8_t ssid[32]; /**< SSID of target AP. */
- uint8_t password[64]; /**< Password of target AP. */
- wifi_scan_method_t scan_method; /**< Do all channel scan or fast scan */
- bool bssid_set; /**< Whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
- uint8_t bssid[6]; /**< MAC address of target AP*/
- uint8_t channel; /**< Channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
- uint16_t listen_interval; /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
- wifi_sort_method_t sort_method; /**< Sort the connect AP in the list by rssi or security mode */
- wifi_scan_threshold_t threshold; /**< When scan_threshold is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
- wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame. Will be advertised in RSN Capabilities in RSN IE. */
- uint32_t rm_enabled: 1; /**< Whether Radio Measurements are enabled for the connection */
- uint32_t btm_enabled: 1; /**< Whether BSS Transition Management is enabled for the connection. Note that when btm is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a BTM supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when BTM is enabled. */
- uint32_t mbo_enabled: 1; /**< Whether MBO is enabled for the connection. Note that when mbo is enabled, the application itself should not set specific bssid (i.e using bssid_set and bssid in this config)or channel to connect to. This defeats the purpose of a MBO supported network, and hence if btm is supported and a specific bssid or channel is set in this config, it will be cleared from the config at the first disconnection or connection so that the device can roam to other BSS. It is recommended not to set BSSID when MBO is enabled. Enabling mbo here, automatically enables btm and rm above.*/
- uint32_t ft_enabled: 1; /**< Whether FT is enabled for the connection */
- uint32_t owe_enabled: 1; /**< Whether OWE is enabled for the connection */
- uint32_t transition_disable: 1; /**< Whether to enable transition disable feature */
- uint32_t reserved: 26; /**< Reserved for future feature set */
- wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */
- wifi_sae_pk_mode_t sae_pk_mode; /**< Configuration for SAE-PK (Public Key) Authentication method */
- uint8_t failure_retry_cnt; /**< Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config.
- Note: Enabling this may cause connection time to increase in case best AP doesn't behave properly. */
- uint32_t he_dcm_set: 1; /**< Whether DCM max.constellation for transmission and reception is set. */
- uint32_t he_dcm_max_constellation_tx: 2; /**< Indicate the max.constellation for DCM in TB PPDU the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
- uint32_t he_dcm_max_constellation_rx: 2; /**< Indicate the max.constellation for DCM in both Data field and HE-SIG-B field the STA supported. 0: not supported. 1: BPSK, 2: QPSK, 3: 16-QAM. The default value is 3. */
- uint32_t he_mcs9_enabled: 1; /**< Whether to support HE-MCS 0 to 9. The default value is 0. */
- uint32_t he_su_beamformee_disabled: 1; /**< Whether to disable support for operation as an SU beamformee. */
- uint32_t he_trig_su_bmforming_feedback_disabled: 1; /**< Whether to disable support the transmission of SU feedback in an HE TB sounding sequence. */
- uint32_t he_trig_mu_bmforming_partial_feedback_disabled: 1; /**< Whether to disable support the transmission of partial-bandwidth MU feedback in an HE TB sounding sequence. */
- uint32_t he_trig_cqi_feedback_disabled: 1; /**< Whether to disable support the transmission of CQI feedback in an HE TB sounding sequence. */
- uint32_t he_reserved: 22; /**< Reserved for future feature set */
- uint8_t sae_h2e_identifier[SAE_H2E_IDENTIFIER_LEN];/**< Password identifier for H2E. this needs to be null terminated string */
- } wifi_sta_config_t;
- /**
- * @brief Configuration data for device's AP or STA or NAN.
- *
- * The usage of this union (for ap, sta or nan configuration) is determined by the accompanying
- * interface argument passed to esp_wifi_set_config() or esp_wifi_get_config()
- *
- */
- typedef union {
- wifi_ap_config_t ap; /**< Configuration of AP */
- wifi_sta_config_t sta; /**< Configuration of STA */
- } wifi_config_t;
- typedef struct {
- uint8_t bssid[BSSID_STR_SIZE];
- int rssi;
- } wifi_connected_stations_list_t;
- typedef struct {
- int mode;
- char mac[MAX_MAC_STR_SIZE];
- } wifi_mac_t;
- typedef struct {
- int mode;
- } wifi_mode_t;
- typedef struct {
- uint8_t ssid[SSID_LENGTH];
- uint8_t pwd[PASSWORD_LENGTH];
- int channel;
- int encryption_mode;
- int max_connections;
- bool ssid_hidden;
- wifi_bandwidth_e bandwidth;
- char out_mac[MAX_MAC_STR_SIZE];
- int band_mode;
- } softap_config_t;
- typedef struct {
- int count;
- /* dynamic size */
- wifi_ap_record_t *out_list;
- } wifi_ap_scan_list_t;
- typedef struct {
- int count;
- /* dynamic list*/
- wifi_connected_stations_list_t *out_list;
- } wifi_softap_conn_sta_list_t;
- typedef struct {
- int ps_mode;
- } wifi_power_save_t;
- typedef struct {
- bool enable;
- wifi_vendor_ie_type_e type;
- wifi_vendor_ie_id_e idx;
- vendor_ie_data_t vnd_ie;
- } wifi_softap_vendor_ie_t;
- typedef struct {
- uint8_t *ota_data;
- uint32_t ota_data_len;
- } ota_write_t;
- typedef struct {
- int power;
- } wifi_tx_power_t;
- typedef struct {
- char project_name[3];
- uint8_t major_1;
- uint8_t major_2;
- uint8_t minor;
- uint8_t revision_patch_1;
- uint8_t revision_patch_2;
- } fw_version_t;
- typedef struct {
- HostedFeature feature;
- uint8_t enable;
- } feature_enable_disable_t;
- typedef struct {
- /* event */
- uint32_t hb_num;
- /* Req */
- uint8_t enable;
- uint32_t duration;
- } event_heartbeat_t;
- typedef struct {
- uint8_t ssid[SSID_LENGTH];
- uint32_t ssid_len;
- uint8_t bssid[BSSID_STR_SIZE];
- int channel;
- int authmode;
- int aid;
- } event_sta_conn_t;
- typedef struct {
- uint8_t ssid[SSID_LENGTH];
- uint32_t ssid_len;
- uint8_t bssid[BSSID_STR_SIZE];
- uint32_t reason;
- int32_t rssi;
- } event_sta_disconn_t;
- typedef struct {
- uint8_t mac[MAX_MAC_STR_SIZE];
- int32_t aid;
- int32_t is_mesh_child;
- } event_softap_sta_conn_t;
- typedef struct {
- uint8_t mac[MAX_MAC_STR_SIZE];
- int32_t aid;
- int32_t is_mesh_child;
- uint32_t reason;
- } event_softap_sta_disconn_t;
- typedef struct Ctrl_cmd_t {
- /* msg type could be 1. req 2. resp 3. notification */
- uint8_t msg_type;
- /* control path protobuf msg number */
- uint16_t msg_id;
- /* uid of request / response */
- int32_t uid;
- /* statusof response or notification */
- int32_t resp_event_status;
- union {
- wifi_mac_t wifi_mac;
- wifi_mode_t wifi_mode;
- wifi_ap_scan_list_t wifi_ap_scan;
- wifi_ap_record_t wifi_ap_record;
- // wifi_ap_config_t wifi_ap_config;
- wifi_sta_config_t wifi_sta_config;
- softap_config_t wifi_softap_config;
- wifi_softap_vendor_ie_t wifi_softap_vendor_ie;
- wifi_softap_conn_sta_list_t wifi_softap_con_sta;
- wifi_power_save_t wifi_ps;
- ota_write_t ota_write;
- feature_enable_disable_t feat_ena_disable;
- wifi_tx_power_t wifi_tx_power;
- fw_version_t fw_version;
- event_heartbeat_t e_heartbeat;
- event_sta_conn_t e_sta_conn;
- event_sta_disconn_t e_sta_disconn;
- event_softap_sta_conn_t e_softap_sta_conn;
- event_softap_sta_disconn_t e_softap_sta_disconn;
- }u;
- /* By default this callback is set to NULL.
- * When this callback is set by app while triggering request,
- * it will be automatically called asynchronously
- * by hosted control lib on receiving control response
- * in this case app will not be waiting for response.
- *
- * Whereas, when this is not set i.e. is NULL, it is understood
- * as synchronous response, and app after sending request,
- * will wait till getting a response
- */
- int (*ctrl_resp_cb)(struct Ctrl_cmd_t *data);
- /* Wait for timeout duration, if response not received,
- * it will send timeout response.
- * Default value for this time out is DEFAULT_CTRL_RESP_TIMEOUT */
- int cmd_timeout_sec;
- /* assign the data pointer to free by lower layer.
- * Ignored if assigned as NULL */
- void *free_buffer_handle;
- /* free handle to be registered
- * Ignored if assigned as NULL */
- void (*free_buffer_func)(void *free_buffer_handle);
- void *ctrl_free_buff_hdls[MAX_FREE_BUFF_HANDLES];
- uint8_t n_ctrl_free_buff_hdls;
- } ctrl_cmd_t;
- /* resp callback */
- typedef int (*ctrl_resp_cb_t) (ctrl_cmd_t * resp);
- /* event callback */
- typedef int (*ctrl_event_cb_t) (ctrl_cmd_t * event);
- /*---- Control API Function ----*/
- /* This file contains hosted control library exposed APIs.
- * For detailed documentation, Please refer `../../../docs/common/ctrl_apis.md`
- *
- * As important note, application using these APIs, should clean
- * 1. allocated buffer within library are saved in `app_resp->free_buffer_handle`
- * Please use `app_resp->free_buffer_func` for freeing them.
- * 2. Response `ctrl_cmd_t *app_resp` is also allocated from library,
- * need to free using hosted_free() function.
- **/
- /* Set control event callback
- *
- * when user sets event callback, user provided function pointer
- * will be registered with user function
- * If user does not register event callback,
- * events received from ESP32 will be dropped
- *
- * Inputs:
- * > event - Control Event ID from `AppMsgId_e`
- * > event_cb - NULL - resets event callback
- * Function pointer - Registers event callback
- * Returns:
- * > MSG_ID_OUT_OF_ORDER - If event is not registered with hosted control lib
- * > CALLBACK_SET_SUCCESS - Callback is set successful
- **/
- int set_event_callback(int event, ctrl_resp_cb_t event_cb);
- /* Reset control event callback
- *
- * when user sets event callback, user provided function pointer
- * will be registered with user function
- * If user does not register event callback,
- * events received from ESP32 will be dropped
- *
- * Inputs:
- * > event - Control Event ID from `AppMsgId_e`
- *
- * Returns:
- * > MSG_ID_OUT_OF_ORDER - If event is not registered with hosted control lib
- * > CALLBACK_SET_SUCCESS - Callback is set successful
- **/
- int reset_event_callback(int event);
- /* Initialize hosted control library
- *
- * This is first step for application while using control path
- * This will allocate and instantiate hosted control library
- *
- * Returns:
- * > SUCCESS - 0
- * > FAILURE - -1
- **/
- int init_hosted_control_lib(void);
- /* De-initialize hosted control library
- *
- * This is last step for application while using control path
- * This will deallocate and cleanup hosted control library
- *
- * Returns:
- * > SUCCESS - 0
- * > FAILURE - -1
- **/
- int deinit_hosted_control_lib(void);
- /* Get the MAC address of station or softAP interface of ESP32 */
- ctrl_cmd_t * wifi_get_mac(ctrl_cmd_t req);
- /* Set MAC address of ESP32 interface for given wifi mode */
- ctrl_cmd_t * wifi_set_mac(ctrl_cmd_t req);
- /* Get Wi-Fi mode of ESP32 */
- ctrl_cmd_t * wifi_get_mode(ctrl_cmd_t req);
- /* Set the Wi-Fi mode of ESP32 */
- ctrl_cmd_t * wifi_set_mode(ctrl_cmd_t req);
- /* Set Wi-Fi power save mode of ESP32 */
- ctrl_cmd_t * wifi_set_power_save_mode(ctrl_cmd_t req);
- /* Get the Wi-Fi power save mode of ESP32 */
- ctrl_cmd_t * wifi_get_power_save_mode(ctrl_cmd_t req);
- /* Get list of available neighboring APs of ESP32 */
- ctrl_cmd_t * wifi_ap_scan_list(ctrl_cmd_t req);
- /* Get the AP config to which ESP32 station is connected */
- ctrl_cmd_t * wifi_get_ap_config(ctrl_cmd_t req);
- /* Set the AP config to which ESP32 station should connect to */
- ctrl_cmd_t * wifi_connect_ap(ctrl_cmd_t req);
- /* Disconnect ESP32 station from AP */
- ctrl_cmd_t * wifi_disconnect_ap(ctrl_cmd_t req);
- /* Set configuration of ESP32 softAP and start broadcasting */
- ctrl_cmd_t * wifi_start_softap(ctrl_cmd_t req);
- /* Get configuration of ESP32 softAP */
- ctrl_cmd_t * wifi_get_softap_config(ctrl_cmd_t req);
- /* Stop ESP32 softAP */
- ctrl_cmd_t * wifi_stop_softap(ctrl_cmd_t req);
- /* Get list of connected stations to ESP32 softAP */
- ctrl_cmd_t * wifi_get_softap_connected_station_list(ctrl_cmd_t req);
- /* Function set 802.11 Vendor-Specific Information Element.
- * It needs to get called before starting of ESP32 softAP */
- ctrl_cmd_t * wifi_set_vendor_specific_ie(ctrl_cmd_t req);
- /* Sets maximum WiFi transmitting power at ESP32 */
- ctrl_cmd_t * wifi_set_max_tx_power(ctrl_cmd_t req);
- /* Gets current WiFi transmiting power at ESP32 */
- ctrl_cmd_t * wifi_get_curr_tx_power(ctrl_cmd_t req);
- /* Configure heartbeat event. Be default heartbeat is not enabled.
- * To enable heartbeats, user need to use this API in addition
- * to setting event callback for heartbeat event */
- ctrl_cmd_t * config_heartbeat(ctrl_cmd_t req);
- /* Performs an OTA begin operation for ESP32 which erases and
- * prepares existing flash partition for new flash writing */
- ctrl_cmd_t * ota_begin(ctrl_cmd_t req);
- /* Performs an OTA write operation for ESP32, It writes bytes from `ota_data`
- * buffer with `ota_data_len` number of bytes to OTA partition in flash. Number
- * of bytes can be small than size of complete binary to be flashed. In that
- * case, this caller is expected to repeatedly call this function till
- * total size written equals size of complete binary */
- ctrl_cmd_t * ota_write(ctrl_cmd_t req);
- /* Performs an OTA end operation for ESP32, It validates written OTA image,
- * sets newly written OTA partition as boot partition for next boot,
- * Creates timer which reset ESP32 after 5 sec */
- ctrl_cmd_t * ota_end(ctrl_cmd_t req);
- /* Enable or disable specific feautures from hosted_features_t */
- ctrl_cmd_t * feature_config(ctrl_cmd_t req);
- /* Get FW Version */
- ctrl_cmd_t * get_fw_version(ctrl_cmd_t req);
- /* Get the interface up for interface `iface` */
- int interface_up(int sockfd, char* iface);
- /* Get the interface down for interface `iface` */
- int interface_down(int sockfd, char* iface);
- /* Set ethernet interface MAC address `mac` to interface `iface` */
- int set_hw_addr(int sockfd, char* iface, char* mac);
- /* Create an endpoint for communication */
- int create_socket(int domain, int type, int protocol, int *sock);
- /* Close an endpoint of the communication */
- int close_socket(int sock);
- #endif
|