1 /* 2 * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 8 #ifndef __ESP_WIFI_TYPES_H__ 9 #define __ESP_WIFI_TYPES_H__ 10 11 #include "esp_private/esp_wifi_types_private.h" 12 #if CONFIG_SOC_WIFI_HE_SUPPORT 13 #include "esp_wifi_he_types.h" 14 #endif 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 typedef enum { 21 ESP32_WIFI_MODE_NULL = 0, /**< null mode */ 22 ESP32_WIFI_MODE_STA, /**< WiFi station mode */ 23 ESP32_WIFI_MODE_AP, /**< WiFi soft-AP mode */ 24 ESP32_WIFI_MODE_APSTA, /**< WiFi station + soft-AP mode */ 25 ESP32_WIFI_MODE_NAN, /**< WiFi NAN mode */ 26 ESP32_WIFI_MODE_MAX 27 } wifi_mode_t; 28 29 typedef enum { 30 WIFI_IF_STA = ESP_IF_WIFI_STA, 31 WIFI_IF_AP = ESP_IF_WIFI_AP, 32 #if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) 33 WIFI_IF_NAN = ESP_IF_WIFI_NAN, 34 #endif 35 WIFI_IF_MAX 36 } wifi_interface_t; 37 38 #define WIFI_OFFCHAN_TX_REQ 1 39 #define WIFI_OFFCHAN_TX_CANCEL 0 40 41 #define WIFI_ROC_REQ 1 42 #define WIFI_ROC_CANCEL 0 43 44 typedef enum { 45 WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */ 46 WIFI_COUNTRY_POLICY_MANUAL, /**< Country policy is manual, always use the configured country info */ 47 } wifi_country_policy_t; 48 49 /** @brief Structure describing WiFi country-based regional restrictions. */ 50 typedef struct { 51 char cc[3]; /**< country code string */ 52 uint8_t schan; /**< start channel */ 53 uint8_t nchan; /**< total channel number */ 54 int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ 55 wifi_country_policy_t policy; /**< country policy */ 56 } wifi_country_t; 57 58 /* Strength of authmodes */ 59 /* OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA2_ENTERPRISE < WPA3_PSK = WPA2_WPA3_PSK */ 60 typedef enum { 61 WIFI_AUTH_OPEN = 0, /**< authenticate mode : open */ 62 WIFI_AUTH_WEP, /**< authenticate mode : WEP */ 63 WIFI_AUTH_WPA_PSK, /**< authenticate mode : WPA_PSK */ 64 WIFI_AUTH_WPA2_PSK, /**< authenticate mode : WPA2_PSK */ 65 WIFI_AUTH_WPA_WPA2_PSK, /**< authenticate mode : WPA_WPA2_PSK */ 66 WIFI_AUTH_WPA2_ENTERPRISE, /**< authenticate mode : WPA2_ENTERPRISE */ 67 WIFI_AUTH_WPA3_PSK, /**< authenticate mode : WPA3_PSK */ 68 WIFI_AUTH_WPA2_WPA3_PSK, /**< authenticate mode : WPA2_WPA3_PSK */ 69 WIFI_AUTH_WAPI_PSK, /**< authenticate mode : WAPI_PSK */ 70 WIFI_AUTH_OWE, /**< authenticate mode : OWE */ 71 WIFI_AUTH_MAX 72 } wifi_auth_mode_t; 73 74 typedef enum { 75 WIFI_REASON_UNSPECIFIED = 1, 76 WIFI_REASON_AUTH_EXPIRE = 2, 77 WIFI_REASON_AUTH_LEAVE = 3, 78 WIFI_REASON_ASSOC_EXPIRE = 4, 79 WIFI_REASON_ASSOC_TOOMANY = 5, 80 WIFI_REASON_NOT_AUTHED = 6, 81 WIFI_REASON_NOT_ASSOCED = 7, 82 WIFI_REASON_ASSOC_LEAVE = 8, 83 WIFI_REASON_ASSOC_NOT_AUTHED = 9, 84 WIFI_REASON_DISASSOC_PWRCAP_BAD = 10, 85 WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11, 86 WIFI_REASON_BSS_TRANSITION_DISASSOC = 12, 87 WIFI_REASON_IE_INVALID = 13, 88 WIFI_REASON_MIC_FAILURE = 14, 89 WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, 90 WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, 91 WIFI_REASON_IE_IN_4WAY_DIFFERS = 17, 92 WIFI_REASON_GROUP_CIPHER_INVALID = 18, 93 WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19, 94 WIFI_REASON_AKMP_INVALID = 20, 95 WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21, 96 WIFI_REASON_INVALID_RSN_IE_CAP = 22, 97 WIFI_REASON_802_1X_AUTH_FAILED = 23, 98 WIFI_REASON_CIPHER_SUITE_REJECTED = 24, 99 WIFI_REASON_TDLS_PEER_UNREACHABLE = 25, 100 WIFI_REASON_TDLS_UNSPECIFIED = 26, 101 WIFI_REASON_SSP_REQUESTED_DISASSOC = 27, 102 WIFI_REASON_NO_SSP_ROAMING_AGREEMENT = 28, 103 WIFI_REASON_BAD_CIPHER_OR_AKM = 29, 104 WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30, 105 WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS = 31, 106 WIFI_REASON_UNSPECIFIED_QOS = 32, 107 WIFI_REASON_NOT_ENOUGH_BANDWIDTH = 33, 108 WIFI_REASON_MISSING_ACKS = 34, 109 WIFI_REASON_EXCEEDED_TXOP = 35, 110 WIFI_REASON_STA_LEAVING = 36, 111 WIFI_REASON_END_BA = 37, 112 WIFI_REASON_UNKNOWN_BA = 38, 113 WIFI_REASON_TIMEOUT = 39, 114 WIFI_REASON_PEER_INITIATED = 46, 115 WIFI_REASON_AP_INITIATED = 47, 116 WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48, 117 WIFI_REASON_INVALID_PMKID = 49, 118 WIFI_REASON_INVALID_MDE = 50, 119 WIFI_REASON_INVALID_FTE = 51, 120 WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED = 67, 121 WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED = 68, 122 123 WIFI_REASON_BEACON_TIMEOUT = 200, 124 WIFI_REASON_NO_AP_FOUND = 201, 125 WIFI_REASON_AUTH_FAIL = 202, 126 WIFI_REASON_ASSOC_FAIL = 203, 127 WIFI_REASON_HANDSHAKE_TIMEOUT = 204, 128 WIFI_REASON_CONNECTION_FAIL = 205, 129 WIFI_REASON_AP_TSF_RESET = 206, 130 WIFI_REASON_ROAMING = 207, 131 WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG = 208, 132 WIFI_REASON_SA_QUERY_TIMEOUT = 209, 133 } wifi_err_reason_t; 134 135 typedef enum { 136 WIFI_SECOND_CHAN_NONE = 0, /**< the channel width is HT20 */ 137 WIFI_SECOND_CHAN_ABOVE, /**< the channel width is HT40 and the secondary channel is above the primary channel */ 138 WIFI_SECOND_CHAN_BELOW, /**< the channel width is HT40 and the secondary channel is below the primary channel */ 139 } wifi_second_chan_t; 140 141 typedef enum { 142 ESP32_WIFI_SCAN_TYPE_ACTIVE = 0, /**< active scan */ 143 ESP32_WIFI_SCAN_TYPE_PASSIVE, /**< passive scan */ 144 } wifi_scan_type_t; 145 146 /** @brief Range of active scan times per channel */ 147 typedef struct { 148 uint32_t min; /**< minimum active scan time per channel, units: millisecond */ 149 uint32_t max; /**< maximum active scan time per channel, units: millisecond, values above 1500ms may 150 cause station to disconnect from AP and are not recommended. */ 151 } wifi_active_scan_time_t; 152 153 /** @brief Aggregate of active & passive scan time per channel */ 154 typedef struct { 155 wifi_active_scan_time_t active; /**< active scan time per channel, units: millisecond. */ 156 uint32_t passive; /**< passive scan time per channel, units: millisecond, values above 1500ms may 157 cause station to disconnect from AP and are not recommended. */ 158 } wifi_scan_time_t; 159 160 /** @brief Parameters for an SSID scan. */ 161 typedef struct { 162 uint8_t *ssid; /**< SSID of AP */ 163 uint8_t *bssid; /**< MAC address of AP */ 164 uint8_t channel; /**< channel, scan the specific channel */ 165 bool show_hidden; /**< enable to scan AP whose SSID is hidden */ 166 wifi_scan_type_t scan_type; /**< scan type, active or passive */ 167 wifi_scan_time_t scan_time; /**< scan time per channel */ 168 uint8_t home_chan_dwell_time;/**< time spent at home channel between scanning consecutive channels.*/ 169 } wifi_scan_config_t; 170 171 typedef enum { 172 WIFI_CIPHER_TYPE_NONE = 0, /**< the cipher type is none */ 173 WIFI_CIPHER_TYPE_WEP40, /**< the cipher type is WEP40 */ 174 WIFI_CIPHER_TYPE_WEP104, /**< the cipher type is WEP104 */ 175 WIFI_CIPHER_TYPE_TKIP, /**< the cipher type is TKIP */ 176 WIFI_CIPHER_TYPE_CCMP, /**< the cipher type is CCMP */ 177 WIFI_CIPHER_TYPE_TKIP_CCMP, /**< the cipher type is TKIP and CCMP */ 178 WIFI_CIPHER_TYPE_AES_CMAC128,/**< the cipher type is AES-CMAC-128 */ 179 WIFI_CIPHER_TYPE_SMS4, /**< the cipher type is SMS4 */ 180 WIFI_CIPHER_TYPE_GCMP, /**< the cipher type is GCMP */ 181 WIFI_CIPHER_TYPE_GCMP256, /**< the cipher type is GCMP-256 */ 182 WIFI_CIPHER_TYPE_AES_GMAC128,/**< the cipher type is AES-GMAC-128 */ 183 WIFI_CIPHER_TYPE_AES_GMAC256,/**< the cipher type is AES-GMAC-256 */ 184 WIFI_CIPHER_TYPE_UNKNOWN, /**< the cipher type is unknown */ 185 } wifi_cipher_type_t; 186 187 /** 188 * @brief WiFi antenna 189 * 190 */ 191 typedef enum { 192 WIFI_ANT_ANT0, /**< WiFi antenna 0 */ 193 WIFI_ANT_ANT1, /**< WiFi antenna 1 */ 194 WIFI_ANT_MAX, /**< Invalid WiFi antenna */ 195 } wifi_ant_t; 196 197 /** @brief Description of a WiFi AP HE Info */ 198 typedef struct { 199 uint8_t bss_color:6; /**< an unsigned integer whose value is the BSS Color of the BSS corresponding to the AP */ 200 uint8_t partial_bss_color:1; /**< indicate if an AID assignment rule based on the BSS color */ 201 uint8_t bss_color_disabled:1; /**< indicate if the use of BSS color is disabled */ 202 uint8_t bssid_index; /**< in M-BSSID set, identifies the nontransmitted BSSID */ 203 } wifi_he_ap_info_t; 204 205 /** @brief Description of a WiFi AP */ 206 typedef struct { 207 uint8_t bssid[6]; /**< MAC address of AP */ 208 uint8_t ssid[33]; /**< SSID of AP */ 209 uint8_t primary; /**< channel of AP */ 210 wifi_second_chan_t second; /**< secondary channel of AP */ 211 int8_t rssi; /**< signal strength of AP */ 212 wifi_auth_mode_t authmode; /**< authmode of AP */ 213 wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of AP */ 214 wifi_cipher_type_t group_cipher; /**< group cipher of AP */ 215 wifi_ant_t ant; /**< antenna used to receive beacon from AP */ 216 uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */ 217 uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ 218 uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ 219 uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ 220 uint32_t phy_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ 221 uint32_t wps:1; /**< bit: 5 flag to identify if WPS is supported or not */ 222 uint32_t ftm_responder:1; /**< bit: 6 flag to identify if FTM is supported in responder mode */ 223 uint32_t ftm_initiator:1; /**< bit: 7 flag to identify if FTM is supported in initiator mode */ 224 uint32_t reserved:24; /**< bit: 8..31 reserved */ 225 wifi_country_t country; /**< country information of AP */ 226 wifi_he_ap_info_t he_ap; /**< HE AP info */ 227 } wifi_ap_record_t; 228 229 typedef enum { 230 WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */ 231 WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */ 232 }wifi_scan_method_t; 233 234 typedef enum { 235 WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */ 236 WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */ 237 }wifi_sort_method_t; 238 239 /** @brief Structure describing parameters for a WiFi fast scan */ 240 typedef struct { 241 int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */ 242 wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode 243 Note: Incase 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 authmode threshold as WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK to connect to WEP/WPA networks */ 244 }wifi_scan_threshold_t; 245 246 typedef enum { 247 WIFI_PS_NONE, /**< No power save */ 248 WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. In this mode, station wakes up to receive beacon every DTIM period */ 249 WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. In this mode, interval to receive beacons is determined by the listen_interval parameter in wifi_sta_config_t */ 250 } wifi_ps_type_t; 251 252 #define WIFI_PROTOCOL_11B 1 253 #define WIFI_PROTOCOL_11G 2 254 #define WIFI_PROTOCOL_11N 4 255 #define WIFI_PROTOCOL_LR 8 256 #define WIFI_PROTOCOL_11AX 16 257 258 typedef enum { 259 WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */ 260 WIFI_BW_HT40, /* Bandwidth is HT40 */ 261 } wifi_bandwidth_t; 262 263 /** Configuration structure for Protected Management Frame */ 264 typedef struct { 265 bool capable; /**< Deprecated variable. Device will always connect in PMF mode if other device also advertizes PMF capability. */ 266 bool required; /**< Advertizes that Protected Management Frame is required. Device will not associate to non-PMF capable devices. */ 267 } wifi_pmf_config_t; 268 269 /** Configuration for SAE PWE derivation */ 270 typedef enum { 271 WPA3_SAE_PWE_UNSPECIFIED, 272 WPA3_SAE_PWE_HUNT_AND_PECK, 273 WPA3_SAE_PWE_HASH_TO_ELEMENT, 274 WPA3_SAE_PWE_BOTH, 275 } wifi_sae_pwe_method_t; 276 277 /** Configuration for SAE-PK */ 278 typedef enum { 279 WPA3_SAE_PK_MODE_AUTOMATIC = 0, 280 WPA3_SAE_PK_MODE_ONLY = 1, 281 WPA3_SAE_PK_MODE_DISABLED = 2, 282 } wifi_sae_pk_mode_t; 283 284 /** @brief Soft-AP configuration settings for the device */ 285 typedef struct { 286 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. */ 287 uint8_t password[64]; /**< Password of soft-AP. */ 288 uint8_t ssid_len; /**< Optional length of SSID field. */ 289 uint8_t channel; /**< Channel of soft-AP */ 290 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. */ 291 uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */ 292 uint8_t max_connection; /**< Max number of stations allowed to connect in */ 293 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 */ 294 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. */ 295 bool ftm_responder; /**< Enable FTM Responder mode */ 296 wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame */ 297 wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */ 298 } wifi_ap_config_t; 299 300 #define SAE_H2E_IDENTIFIER_LEN 32 301 /** @brief STA configuration settings for the device */ 302 typedef struct { 303 uint8_t ssid[32]; /**< SSID of target AP. */ 304 uint8_t password[64]; /**< Password of target AP. */ 305 wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */ 306 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.*/ 307 uint8_t bssid[6]; /**< MAC address of target AP*/ 308 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.*/ 309 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. */ 310 wifi_sort_method_t sort_method; /**< sort the connect AP in the list by rssi or security mode */ 311 wifi_scan_threshold_t threshold; /**< When sort_method 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. */ 312 wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame. Will be advertised in RSN Capabilities in RSN IE. */ 313 uint32_t rm_enabled:1; /**< Whether Radio Measurements are enabled for the connection */ 314 uint32_t btm_enabled:1; /**< Whether BSS Transition Management is enabled for the connection */ 315 uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */ 316 uint32_t ft_enabled:1; /**< Whether FT is enabled for the connection */ 317 uint32_t owe_enabled:1; /**< Whether OWE is enabled for the connection */ 318 uint32_t transition_disable:1; /**< Whether to enable transition disable feature */ 319 uint32_t reserved:26; /**< Reserved for future feature set */ 320 wifi_sae_pwe_method_t sae_pwe_h2e; /**< Configuration for SAE PWE derivation method */ 321 wifi_sae_pk_mode_t sae_pk_mode; /**< Configuration for SAE-PK (Public Key) Authentication method */ 322 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. 323 Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. */ 324 uint32_t he_dcm_set:1; /**< Whether DCM max.constellation for transmission and reception is set. */ 325 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. */ 326 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. */ 327 uint32_t he_mcs9_enabled:1; /**< Whether to support HE-MCS 0 to 9. The default value is 0. */ 328 uint32_t he_su_beamformee_disabled:1; /**< Whether to disable support for operation as an SU beamformee. */ 329 uint32_t he_trig_su_bmforming_feedback_disabled:1; /**< Whether to disable support the transmission of SU feedback in an HE TB sounding sequence. */ 330 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. */ 331 uint32_t he_trig_cqi_feedback_disabled:1; /**< Whether to disable support the transmission of CQI feedback in an HE TB sounding sequence. */ 332 uint32_t he_reserved:22; /**< Reserved for future feature set */ 333 uint8_t sae_h2e_identifier[SAE_H2E_IDENTIFIER_LEN];/**< Password identifier for H2E. this needs to be null terminated string */ 334 } wifi_sta_config_t; 335 336 /** 337 * @brief NAN Discovery start configuration 338 * 339 */ 340 typedef struct { 341 uint8_t op_channel; /**< NAN Discovery operating channel */ 342 uint8_t master_pref; /**< Device's preference value to serve as NAN Master */ 343 uint8_t scan_time; /**< Scan time in seconds while searching for a NAN cluster */ 344 uint16_t warm_up_sec; /**< Warm up time before assuming NAN Anchor Master role */ 345 } wifi_nan_config_t; 346 347 /** @brief Configuration data for device's AP or STA or NAN. 348 * 349 * The usage of this union (for ap, sta or nan configuration) is determined by the accompanying 350 * interface argument passed to esp_wifi_set_config() or esp_wifi_get_config() 351 * 352 */ 353 typedef union { 354 wifi_ap_config_t ap; /**< configuration of AP */ 355 wifi_sta_config_t sta; /**< configuration of STA */ 356 wifi_nan_config_t nan; /**< configuration of NAN */ 357 } wifi_config_t; 358 359 /** @brief Description of STA associated with AP */ 360 typedef struct { 361 uint8_t mac[6]; /**< mac address */ 362 int8_t rssi; /**< current average rssi of sta connected */ 363 uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */ 364 uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ 365 uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ 366 uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ 367 uint32_t phy_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ 368 uint32_t is_mesh_child:1;/**< bit: 5 flag to identify mesh child */ 369 uint32_t reserved:26; /**< bit: 6..31 reserved */ 370 } wifi_sta_info_t; 371 372 #if CONFIG_IDF_TARGET_ESP32C2 373 #define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ 374 #elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 375 #define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32C3 soft-AP */ 376 #else 377 #define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ 378 #endif 379 380 /** @brief List of stations associated with the Soft-AP */ 381 typedef struct { 382 wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ 383 int num; /**< number of stations in the list (other entries are invalid) */ 384 } wifi_sta_list_t; 385 386 typedef enum { 387 WIFI_STORAGE_FLASH, /**< all configuration will store in both memory and flash */ 388 WIFI_STORAGE_RAM, /**< all configuration will only store in the memory */ 389 } wifi_storage_t; 390 391 /** 392 * @brief Vendor Information Element type 393 * 394 * Determines the frame type that the IE will be associated with. 395 */ 396 typedef enum { 397 WIFI_VND_IE_TYPE_BEACON, 398 WIFI_VND_IE_TYPE_PROBE_REQ, 399 WIFI_VND_IE_TYPE_PROBE_RESP, 400 WIFI_VND_IE_TYPE_ASSOC_REQ, 401 WIFI_VND_IE_TYPE_ASSOC_RESP, 402 } wifi_vendor_ie_type_t; 403 404 /** 405 * @brief Vendor Information Element index 406 * 407 * Each IE type can have up to two associated vendor ID elements. 408 */ 409 typedef enum { 410 WIFI_VND_IE_ID_0, 411 WIFI_VND_IE_ID_1, 412 } wifi_vendor_ie_id_t; 413 414 #define WIFI_VENDOR_IE_ELEMENT_ID 0xDD 415 416 /** 417 * @brief Operation Phymode 418 */ 419 typedef enum 420 { 421 WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */ 422 WIFI_PHY_MODE_11B, /**< PHY mode for 11b */ 423 WIFI_PHY_MODE_11G, /**< PHY mode for 11g */ 424 WIFI_PHY_MODE_HT20, /**< PHY mode for Bandwidth HT20 */ 425 WIFI_PHY_MODE_HT40, /**< PHY mode for Bandwidth HT40 */ 426 WIFI_PHY_MODE_HE20, /**< PHY mode for Bandwidth HE20 */ 427 } wifi_phy_mode_t; 428 429 /** 430 * @brief Vendor Information Element header 431 * 432 * The first bytes of the Information Element will match this header. Payload follows. 433 */ 434 typedef struct { 435 uint8_t element_id; /**< Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */ 436 uint8_t length; /**< Length of all bytes in the element data following this field. Minimum 4. */ 437 uint8_t vendor_oui[3]; /**< Vendor identifier (OUI). */ 438 uint8_t vendor_oui_type; /**< Vendor-specific OUI type. */ 439 uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ 440 } vendor_ie_data_t; 441 442 #if CONFIG_SOC_WIFI_HE_SUPPORT 443 typedef esp_wifi_rxctrl_t wifi_pkt_rx_ctrl_t; 444 #else 445 /** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */ 446 typedef struct { 447 signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ 448 unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ 449 unsigned :1; /**< reserved */ 450 unsigned sig_mode:2; /**< 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ 451 unsigned :16; /**< reserved */ 452 unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ 453 unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ 454 unsigned :16; /**< reserved */ 455 unsigned smoothing:1; /**< reserved */ 456 unsigned not_sounding:1; /**< reserved */ 457 unsigned :1; /**< reserved */ 458 unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ 459 unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ 460 unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */ 461 unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ 462 #if CONFIG_IDF_TARGET_ESP32 463 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ 464 #elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 465 unsigned :8; /**< reserved */ 466 #endif 467 unsigned ampdu_cnt:8; /**< ampdu cnt */ 468 unsigned channel:4; /**< primary channel on which this packet is received */ 469 unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ 470 unsigned :8; /**< reserved */ 471 unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */ 472 unsigned :32; /**< reserved */ 473 #if CONFIG_IDF_TARGET_ESP32S2 474 unsigned :32; /**< reserved */ 475 #elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 476 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ 477 unsigned :24; /**< reserved */ 478 unsigned :32; /**< reserved */ 479 #endif 480 unsigned :31; /**< reserved */ 481 unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */ 482 #if CONFIG_IDF_TARGET_ESP32S2 483 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ 484 unsigned :24; /**< reserved */ 485 #elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 486 unsigned :32; /**< reserved */ 487 unsigned :32; /**< reserved */ 488 unsigned :32; /**< reserved */ 489 #endif 490 unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */ 491 unsigned :12; /**< reserved */ 492 unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ 493 } wifi_pkt_rx_ctrl_t; 494 #endif 495 496 /** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. 497 */ 498 typedef struct { 499 wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ 500 uint8_t payload[0]; /**< Data or management payload. Length of payload is described by rx_ctrl.sig_len. Type of content determined by packet type argument of callback. */ 501 } wifi_promiscuous_pkt_t; 502 503 /** 504 * @brief Promiscuous frame type 505 * 506 * Passed to promiscuous mode RX callback to indicate the type of parameter in the buffer. 507 * 508 */ 509 typedef enum { 510 WIFI_PKT_MGMT, /**< Management frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ 511 WIFI_PKT_CTRL, /**< Control frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ 512 WIFI_PKT_DATA, /**< Data frame, indiciates 'buf' argument is wifi_promiscuous_pkt_t */ 513 WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */ 514 } wifi_promiscuous_pkt_type_t; 515 516 517 #define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */ 518 #define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */ 519 #define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */ 520 #define WIFI_PROMIS_FILTER_MASK_DATA (1<<2) /**< filter the packets with type of WIFI_PKT_DATA */ 521 #define WIFI_PROMIS_FILTER_MASK_MISC (1<<3) /**< filter the packets with type of WIFI_PKT_MISC */ 522 #define WIFI_PROMIS_FILTER_MASK_DATA_MPDU (1<<4) /**< filter the MPDU which is a kind of WIFI_PKT_DATA */ 523 #define WIFI_PROMIS_FILTER_MASK_DATA_AMPDU (1<<5) /**< filter the AMPDU which is a kind of WIFI_PKT_DATA */ 524 #define WIFI_PROMIS_FILTER_MASK_FCSFAIL (1<<6) /**< filter the FCS failed packets, do not open it in general */ 525 526 #define WIFI_PROMIS_CTRL_FILTER_MASK_ALL (0xFF800000) /**< filter all control packets */ 527 #define WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER (1<<23) /**< filter the control packets with subtype of Control Wrapper */ 528 #define WIFI_PROMIS_CTRL_FILTER_MASK_BAR (1<<24) /**< filter the control packets with subtype of Block Ack Request */ 529 #define WIFI_PROMIS_CTRL_FILTER_MASK_BA (1<<25) /**< filter the control packets with subtype of Block Ack */ 530 #define WIFI_PROMIS_CTRL_FILTER_MASK_PSPOLL (1<<26) /**< filter the control packets with subtype of PS-Poll */ 531 #define WIFI_PROMIS_CTRL_FILTER_MASK_RTS (1<<27) /**< filter the control packets with subtype of RTS */ 532 #define WIFI_PROMIS_CTRL_FILTER_MASK_CTS (1<<28) /**< filter the control packets with subtype of CTS */ 533 #define WIFI_PROMIS_CTRL_FILTER_MASK_ACK (1<<29) /**< filter the control packets with subtype of ACK */ 534 #define WIFI_PROMIS_CTRL_FILTER_MASK_CFEND (1<<30) /**< filter the control packets with subtype of CF-END */ 535 #define WIFI_PROMIS_CTRL_FILTER_MASK_CFENDACK (1<<31) /**< filter the control packets with subtype of CF-END+CF-ACK */ 536 537 /** @brief Mask for filtering different packet types in promiscuous mode. */ 538 typedef struct { 539 uint32_t filter_mask; /**< OR of one or more filter values WIFI_PROMIS_FILTER_* */ 540 } wifi_promiscuous_filter_t; 541 542 #define WIFI_EVENT_MASK_ALL (0xFFFFFFFF) /**< mask all WiFi events */ 543 #define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ 544 #define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ 545 546 /** 547 * @brief Channel state information(CSI) configuration type 548 * 549 */ 550 #if CONFIG_SOC_WIFI_HE_SUPPORT 551 typedef wifi_csi_acquire_config_t wifi_csi_config_t; 552 #else 553 typedef struct { 554 bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ 555 bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ 556 bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */ 557 bool ltf_merge_en; /**< enable to generate htlft data by averaging lltf and ht_ltf data when receiving HT packet. Otherwise, use ht_ltf data directly. Default enabled */ 558 bool channel_filter_en; /**< enable to turn on channel filter to smooth adjacent sub-carrier. Disable it to keep independence of adjacent sub-carrier. Default enabled */ 559 bool manu_scale; /**< manually scale the CSI data by left shifting or automatically scale the CSI data. If set true, please set the shift bits. false: automatically. true: manually. Default false */ 560 uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */ 561 } wifi_csi_config_t; 562 #endif 563 564 /** 565 * @brief CSI data type 566 * 567 */ 568 typedef struct { 569 wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ 570 uint8_t mac[6]; /**< source MAC address of the CSI data */ 571 uint8_t dmac[6]; /**< destination MAC address of the CSI data */ 572 bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not */ 573 int8_t *buf; /**< buffer of CSI data */ 574 uint16_t len; /**< length of CSI data */ 575 } wifi_csi_info_t; 576 577 /** 578 * @brief WiFi GPIO configuration for antenna selection 579 * 580 */ 581 typedef struct { 582 uint8_t gpio_select: 1, /**< Whether this GPIO is connected to external antenna switch */ 583 gpio_num: 7; /**< The GPIO number that connects to external antenna switch */ 584 } wifi_ant_gpio_t; 585 586 /** 587 * @brief WiFi GPIOs configuration for antenna selection 588 * 589 */ 590 typedef struct { 591 wifi_ant_gpio_t gpio_cfg[4]; /**< The configurations of GPIOs that connect to external antenna switch */ 592 } wifi_ant_gpio_config_t; 593 594 /** 595 * @brief WiFi antenna mode 596 * 597 */ 598 typedef enum { 599 WIFI_ANT_MODE_ANT0, /**< Enable WiFi antenna 0 only */ 600 WIFI_ANT_MODE_ANT1, /**< Enable WiFi antenna 1 only */ 601 WIFI_ANT_MODE_AUTO, /**< Enable WiFi antenna 0 and 1, automatically select an antenna */ 602 WIFI_ANT_MODE_MAX, /**< Invalid WiFi enabled antenna */ 603 } wifi_ant_mode_t; 604 605 /** 606 * @brief WiFi antenna configuration 607 * 608 */ 609 typedef struct { 610 wifi_ant_mode_t rx_ant_mode; /**< WiFi antenna mode for receiving */ 611 wifi_ant_t rx_ant_default; /**< Default antenna mode for receiving, it's ignored if rx_ant_mode is not WIFI_ANT_MODE_AUTO */ 612 wifi_ant_mode_t tx_ant_mode; /**< WiFi antenna mode for transmission, it can be set to WIFI_ANT_MODE_AUTO only if rx_ant_mode is set to WIFI_ANT_MODE_AUTO */ 613 uint8_t enabled_ant0: 4, /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT0 */ 614 enabled_ant1: 4; /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT1 */ 615 } wifi_ant_config_t; 616 617 /** 618 * @brief The Rx callback function of Action Tx operations 619 * 620 * @param hdr pointer to the IEEE 802.11 Header structure 621 * @param payload pointer to the Payload following 802.11 Header 622 * @param len length of the Payload 623 * @param channel channel number the frame is received on 624 * 625 */ 626 typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, 627 size_t len, uint8_t channel); 628 629 /** 630 * @brief Action Frame Tx Request 631 * 632 * 633 */ 634 typedef struct { 635 wifi_interface_t ifx; /**< WiFi interface to send request to */ 636 uint8_t dest_mac[6]; /**< Destination MAC address */ 637 bool no_ack; /**< Indicates no ack required */ 638 wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive any response */ 639 uint32_t data_len; /**< Length of the appended Data */ 640 uint8_t data[0]; /**< Appended Data payload */ 641 } wifi_action_tx_req_t; 642 643 /** 644 * @brief FTM Initiator configuration 645 * 646 */ 647 typedef struct { 648 uint8_t resp_mac[6]; /**< MAC address of the FTM Responder */ 649 uint8_t channel; /**< Primary channel of the FTM Responder */ 650 uint8_t frm_count; /**< No. of FTM frames requested in terms of 4 or 8 bursts (allowed values - 0(No pref), 16, 24, 32, 64) */ 651 uint16_t burst_period; /**< Requested time period between consecutive FTM bursts in 100's of milliseconds (0 - No pref) */ 652 } wifi_ftm_initiator_cfg_t; 653 654 /** 655 * @brief WiFi beacon monitor parameter configuration 656 * 657 */ 658 typedef struct { 659 bool enable; /**< Enable or disable beacon monitor */ 660 uint8_t loss_timeout; /**< Beacon lost timeout */ 661 uint8_t loss_threshold; /**< Maximum number of consecutive lost beacons allowed */ 662 uint8_t delta_intr_early; /**< Delta early time for RF PHY on */ 663 uint8_t delta_loss_timeout; /**< Delta timeout time for RF PHY off */ 664 #if MAC_SUPPORT_PMU_MODEM_STATE 665 uint8_t beacon_abort: 1, /**< Enable or disable beacon abort */ 666 broadcast_wakeup: 1, /**< Enable or disable TIM element multicast wakeup */ 667 reserved: 6; /**< Reserved */ 668 uint8_t tsf_time_sync_deviation; /**< Deviation range to sync with AP TSF timestamp */ 669 uint16_t modem_state_consecutive; /**< PMU MODEM state consecutive count limit */ 670 uint16_t rf_ctrl_wait_cycle; /**< RF on wait time (unit: Modem APB clock cycle) */ 671 #endif 672 } wifi_beacon_monitor_config_t; 673 674 #define ESP_WIFI_NAN_MAX_SVC_SUPPORTED 2 675 #define ESP_WIFI_NAN_DATAPATH_MAX_PEERS 2 676 677 #define ESP_WIFI_NDP_ROLE_INITIATOR 1 678 #define ESP_WIFI_NDP_ROLE_RESPONDER 2 679 680 #define ESP_WIFI_MAX_SVC_NAME_LEN 256 681 #define ESP_WIFI_MAX_FILTER_LEN 256 682 #define ESP_WIFI_MAX_SVC_INFO_LEN 64 683 684 /** 685 * @brief NAN Services types 686 * 687 */ 688 typedef enum { 689 NAN_PUBLISH_SOLICITED, /**< Send unicast Publish frame to Subscribers that match the requirement */ 690 NAN_PUBLISH_UNSOLICITED,/**< Send broadcast Publish frames in every Discovery Window(DW) */ 691 NAN_SUBSCRIBE_ACTIVE, /**< Send broadcast Subscribe frames in every DW */ 692 NAN_SUBSCRIBE_PASSIVE, /**< Passively listens to Publish frames */ 693 } wifi_nan_service_type_t; 694 695 /** 696 * @brief NAN Publish service configuration parameters 697 * 698 */ 699 typedef struct { 700 char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ 701 wifi_nan_service_type_t type; /**< Service type */ 702 char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ 703 char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Publish frame */ 704 uint8_t single_replied_event:1; /**< Give single Replied event or every time */ 705 uint8_t datapath_reqd:1; /**< NAN Datapath required for the service */ 706 uint8_t reserved:6; /**< Reserved */ 707 } wifi_nan_publish_cfg_t; 708 709 /** 710 * @brief NAN Subscribe service configuration parameters 711 * 712 */ 713 typedef struct { 714 char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ 715 wifi_nan_service_type_t type; /**< Service type */ 716 char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ 717 char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Subscribe frame */ 718 uint8_t single_match_event:1; /**< Give single Match event or every time */ 719 uint8_t reserved:7; /**< Reserved */ 720 } wifi_nan_subscribe_cfg_t; 721 722 /** 723 * @brief NAN Follow-up parameters 724 * 725 */ 726 typedef struct { 727 uint8_t inst_id; /**< Own service instance id */ 728 uint8_t peer_inst_id; /**< Peer's service instance id */ 729 uint8_t peer_mac[6]; /**< Peer's MAC address */ 730 char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service info(or message) to be shared */ 731 } wifi_nan_followup_params_t; 732 733 /** 734 * @brief NAN Datapath Request parameters 735 * 736 */ 737 typedef struct { 738 uint8_t pub_id; /**< Publisher's service instance id */ 739 uint8_t peer_mac[6]; /**< Peer's MAC address */ 740 bool confirm_required; /**< NDP Confirm frame required */ 741 } wifi_nan_datapath_req_t; 742 743 /** 744 * @brief NAN Datapath Response parameters 745 * 746 */ 747 typedef struct { 748 bool accept; /**< True - Accept incoming NDP, False - Reject it */ 749 uint8_t ndp_id; /**< NAN Datapath Identifier */ 750 uint8_t peer_mac[6]; /**< Peer's MAC address */ 751 } wifi_nan_datapath_resp_t; 752 753 /** 754 * @brief NAN Datapath End parameters 755 * 756 */ 757 typedef struct { 758 uint8_t ndp_id; /**< NAN Datapath Identifier */ 759 uint8_t peer_mac[6]; /**< Peer's MAC address */ 760 } wifi_nan_datapath_end_req_t; 761 762 /** 763 * @brief WiFi PHY rate encodings 764 * 765 */ 766 typedef enum { 767 WIFI_PHY_RATE_1M_L = 0x00, /**< 1 Mbps with long preamble */ 768 WIFI_PHY_RATE_2M_L = 0x01, /**< 2 Mbps with long preamble */ 769 WIFI_PHY_RATE_5M_L = 0x02, /**< 5.5 Mbps with long preamble */ 770 WIFI_PHY_RATE_11M_L = 0x03, /**< 11 Mbps with long preamble */ 771 WIFI_PHY_RATE_2M_S = 0x05, /**< 2 Mbps with short preamble */ 772 WIFI_PHY_RATE_5M_S = 0x06, /**< 5.5 Mbps with short preamble */ 773 WIFI_PHY_RATE_11M_S = 0x07, /**< 11 Mbps with short preamble */ 774 WIFI_PHY_RATE_48M = 0x08, /**< 48 Mbps */ 775 WIFI_PHY_RATE_24M = 0x09, /**< 24 Mbps */ 776 WIFI_PHY_RATE_12M = 0x0A, /**< 12 Mbps */ 777 WIFI_PHY_RATE_6M = 0x0B, /**< 6 Mbps */ 778 WIFI_PHY_RATE_54M = 0x0C, /**< 54 Mbps */ 779 WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */ 780 WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */ 781 WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */ 782 /**< rate table and guard interval information for each MCS rate*/ 783 /* 784 ----------------------------------------------------------------------------------------------------------- 785 MCS RATE | HT20 | HT40 | HE20 | 786 WIFI_PHY_RATE_MCS0_LGI | 6.5 Mbps (800ns) | 13.5 Mbps (800ns) | 8.1 Mbps (1600ns) | 787 WIFI_PHY_RATE_MCS1_LGI | 13 Mbps (800ns) | 27 Mbps (800ns) | 16.3 Mbps (1600ns) | 788 WIFI_PHY_RATE_MCS2_LGI | 19.5 Mbps (800ns) | 40.5 Mbps (800ns) | 24.4 Mbps (1600ns) | 789 WIFI_PHY_RATE_MCS3_LGI | 26 Mbps (800ns) | 54 Mbps (800ns) | 32.5 Mbps (1600ns) | 790 WIFI_PHY_RATE_MCS4_LGI | 39 Mbps (800ns) | 81 Mbps (800ns) | 48.8 Mbps (1600ns) | 791 WIFI_PHY_RATE_MCS5_LGI | 52 Mbps (800ns) | 108 Mbps (800ns) | 65 Mbps (1600ns) | 792 WIFI_PHY_RATE_MCS6_LGI | 58.5 Mbps (800ns) | 121.5 Mbps (800ns) | 73.1 Mbps (1600ns) | 793 WIFI_PHY_RATE_MCS7_LGI | 65 Mbps (800ns) | 135 Mbps (800ns) | 81.3 Mbps (1600ns) | 794 WIFI_PHY_RATE_MCS8_LGI | ----- | ----- | 97.5 Mbps (1600ns) | 795 WIFI_PHY_RATE_MCS9_LGI | ----- | ----- | 108.3 Mbps (1600ns) | 796 ----------------------------------------------------------------------------------------------------------- 797 */ 798 WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI */ 799 WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI */ 800 WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI */ 801 WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI */ 802 WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI */ 803 WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI */ 804 WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI */ 805 WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI */ 806 #if CONFIG_SOC_WIFI_HE_SUPPORT 807 WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 with long GI */ 808 WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 with long GI */ 809 #endif 810 /* 811 ----------------------------------------------------------------------------------------------------------- 812 MCS RATE | HT20 | HT40 | HE20 | 813 WIFI_PHY_RATE_MCS0_SGI | 7.2 Mbps (400ns) | 15 Mbps (400ns) | 8.6 Mbps (800ns) | 814 WIFI_PHY_RATE_MCS1_SGI | 14.4 Mbps (400ns) | 30 Mbps (400ns) | 17.2 Mbps (800ns) | 815 WIFI_PHY_RATE_MCS2_SGI | 21.7 Mbps (400ns) | 45 Mbps (400ns) | 25.8 Mbps (800ns) | 816 WIFI_PHY_RATE_MCS3_SGI | 28.9 Mbps (400ns) | 60 Mbps (400ns) | 34.4 Mbps (800ns) | 817 WIFI_PHY_RATE_MCS4_SGI | 43.3 Mbps (400ns) | 90 Mbps (400ns) | 51.6 Mbps (800ns) | 818 WIFI_PHY_RATE_MCS5_SGI | 57.8 Mbps (400ns) | 120 Mbps (400ns) | 68.8 Mbps (800ns) | 819 WIFI_PHY_RATE_MCS6_SGI | 65 Mbps (400ns) | 135 Mbps (400ns) | 77.4 Mbps (800ns) | 820 WIFI_PHY_RATE_MCS7_SGI | 72.2 Mbps (400ns) | 150 Mbps (400ns) | 86 Mbps (800ns) | 821 WIFI_PHY_RATE_MCS8_SGI | ----- | ----- | 103.2 Mbps (800ns) | 822 WIFI_PHY_RATE_MCS9_SGI | ----- | ----- | 114.7 Mbps (800ns) | 823 ----------------------------------------------------------------------------------------------------------- 824 */ 825 WIFI_PHY_RATE_MCS0_SGI, /**< MCS0 with short GI */ 826 WIFI_PHY_RATE_MCS1_SGI, /**< MCS1 with short GI */ 827 WIFI_PHY_RATE_MCS2_SGI, /**< MCS2 with short GI */ 828 WIFI_PHY_RATE_MCS3_SGI, /**< MCS3 with short GI */ 829 WIFI_PHY_RATE_MCS4_SGI, /**< MCS4 with short GI */ 830 WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI */ 831 WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI */ 832 WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI */ 833 #if CONFIG_SOC_WIFI_HE_SUPPORT 834 WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 with short GI */ 835 WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 with short GI */ 836 #endif 837 WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */ 838 WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */ 839 WIFI_PHY_RATE_MAX, 840 } wifi_phy_rate_t; 841 842 /** WiFi event declarations */ 843 typedef enum { 844 WIFI_EVENT_WIFI_READY = 0, /**< WiFi ready */ 845 WIFI_EVENT_SCAN_DONE, /**< Finished scanning AP */ 846 WIFI_EVENT_STA_START, /**< Station start */ 847 WIFI_EVENT_STA_STOP, /**< Station stop */ 848 WIFI_EVENT_STA_CONNECTED, /**< Station connected to AP */ 849 WIFI_EVENT_STA_DISCONNECTED, /**< Station disconnected from AP */ 850 WIFI_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by device's station changed */ 851 852 WIFI_EVENT_STA_WPS_ER_SUCCESS, /**< Station wps succeeds in enrollee mode */ 853 WIFI_EVENT_STA_WPS_ER_FAILED, /**< Station wps fails in enrollee mode */ 854 WIFI_EVENT_STA_WPS_ER_TIMEOUT, /**< Station wps timeout in enrollee mode */ 855 WIFI_EVENT_STA_WPS_ER_PIN, /**< Station wps pin code in enrollee mode */ 856 WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, /**< Station wps overlap in enrollee mode */ 857 858 WIFI_EVENT_AP_START, /**< Soft-AP start */ 859 WIFI_EVENT_AP_STOP, /**< Soft-AP stop */ 860 WIFI_EVENT_AP_STACONNECTED, /**< a station connected to Soft-AP */ 861 WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from Soft-AP */ 862 WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */ 863 864 WIFI_EVENT_FTM_REPORT, /**< Receive report of FTM procedure */ 865 866 /* Add next events after this only */ 867 WIFI_EVENT_STA_BSS_RSSI_LOW, /**< AP's RSSI crossed configured threshold */ 868 WIFI_EVENT_ACTION_TX_STATUS, /**< Status indication of Action Tx operation */ 869 WIFI_EVENT_ROC_DONE, /**< Remain-on-Channel operation complete */ 870 871 WIFI_EVENT_STA_BEACON_TIMEOUT, /**< Station beacon timeout */ 872 873 WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START, /**< Connectionless module wake interval start */ 874 875 WIFI_EVENT_AP_WPS_RG_SUCCESS, /**< Soft-AP wps succeeds in registrar mode */ 876 WIFI_EVENT_AP_WPS_RG_FAILED, /**< Soft-AP wps fails in registrar mode */ 877 WIFI_EVENT_AP_WPS_RG_TIMEOUT, /**< Soft-AP wps timeout in registrar mode */ 878 WIFI_EVENT_AP_WPS_RG_PIN, /**< Soft-AP wps pin code in registrar mode */ 879 WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP, /**< Soft-AP wps overlap in registrar mode */ 880 881 WIFI_EVENT_ITWT_SETUP, /**< iTWT setup */ 882 WIFI_EVENT_ITWT_TEARDOWN, /**< iTWT teardown */ 883 WIFI_EVENT_ITWT_PROBE, /**< iTWT probe */ 884 WIFI_EVENT_ITWT_SUSPEND, /**< iTWT suspend */ 885 886 WIFI_EVENT_NAN_STARTED, /**< NAN Discovery has started */ 887 WIFI_EVENT_NAN_STOPPED, /**< NAN Discovery has stopped */ 888 WIFI_EVENT_NAN_SVC_MATCH, /**< NAN Service Discovery match found */ 889 WIFI_EVENT_NAN_REPLIED, /**< Replied to a NAN peer with Service Discovery match */ 890 WIFI_EVENT_NAN_RECEIVE, /**< Received a Follow-up message */ 891 WIFI_EVENT_NDP_INDICATION, /**< Received NDP Request from a NAN Peer */ 892 WIFI_EVENT_NDP_CONFIRM, /**< NDP Confirm Indication */ 893 WIFI_EVENT_NDP_TERMINATED, /**< NAN Datapath terminated indication */ 894 895 WIFI_EVENT_MAX, /**< Invalid WiFi event ID */ 896 } wifi_event_t; 897 898 /** @cond **/ 899 /** @brief WiFi event base declaration */ 900 ESP_EVENT_DECLARE_BASE(WIFI_EVENT); 901 /** @endcond **/ 902 903 /** Argument structure for WIFI_EVENT_SCAN_DONE event */ 904 typedef struct { 905 uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ 906 uint8_t number; /**< number of scan results */ 907 uint8_t scan_id; /**< scan sequence number, used for block scan */ 908 } wifi_event_sta_scan_done_t; 909 910 /** Argument structure for WIFI_EVENT_STA_CONNECTED event */ 911 typedef struct { 912 uint8_t ssid[32]; /**< SSID of connected AP */ 913 uint8_t ssid_len; /**< SSID length of connected AP */ 914 uint8_t bssid[6]; /**< BSSID of connected AP*/ 915 uint8_t channel; /**< channel of connected AP*/ 916 wifi_auth_mode_t authmode;/**< authentication mode used by AP*/ 917 uint16_t aid; /**< authentication id assigned by the connected AP */ 918 } wifi_event_sta_connected_t; 919 920 /** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */ 921 typedef struct { 922 uint8_t ssid[32]; /**< SSID of disconnected AP */ 923 uint8_t ssid_len; /**< SSID length of disconnected AP */ 924 uint8_t bssid[6]; /**< BSSID of disconnected AP */ 925 uint8_t reason; /**< reason of disconnection */ 926 int8_t rssi; /**< rssi of disconnection */ 927 } wifi_event_sta_disconnected_t; 928 929 /** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */ 930 typedef struct { 931 wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ 932 wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ 933 } wifi_event_sta_authmode_change_t; 934 935 /** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */ 936 typedef struct { 937 uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ 938 } wifi_event_sta_wps_er_pin_t; 939 940 /** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */ 941 typedef enum { 942 WPS_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ 943 WPS_FAIL_REASON_RECV_M2D, /**< WPS receive M2D frame */ 944 WPS_FAIL_REASON_MAX 945 } wifi_event_sta_wps_fail_reason_t; 946 947 #define MAX_SSID_LEN 32 948 #define MAX_PASSPHRASE_LEN 64 949 #define MAX_WPS_AP_CRED 3 950 951 /** Argument structure for WIFI_EVENT_STA_WPS_ER_SUCCESS event */ 952 typedef struct { 953 uint8_t ap_cred_cnt; /**< Number of AP credentials received */ 954 struct { 955 uint8_t ssid[MAX_SSID_LEN]; /**< SSID of AP */ 956 uint8_t passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase for the AP */ 957 } ap_cred[MAX_WPS_AP_CRED]; /**< All AP credentials received from WPS handshake */ 958 } wifi_event_sta_wps_er_success_t; 959 960 /** Argument structure for WIFI_EVENT_AP_STACONNECTED event */ 961 typedef struct { 962 uint8_t mac[6]; /**< MAC address of the station connected to Soft-AP */ 963 uint8_t aid; /**< the aid that soft-AP gives to the station connected to */ 964 bool is_mesh_child; /**< flag to identify mesh child */ 965 } wifi_event_ap_staconnected_t; 966 967 /** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ 968 typedef struct { 969 uint8_t mac[6]; /**< MAC address of the station disconnects to soft-AP */ 970 uint8_t aid; /**< the aid that soft-AP gave to the station disconnects to */ 971 bool is_mesh_child; /**< flag to identify mesh child */ 972 uint8_t reason; /**< reason of disconnection */ 973 } wifi_event_ap_stadisconnected_t; 974 975 /** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ 976 typedef struct { 977 int rssi; /**< Received probe request signal strength */ 978 uint8_t mac[6]; /**< MAC address of the station which send probe request */ 979 } wifi_event_ap_probe_req_rx_t; 980 981 /** Argument structure for WIFI_EVENT_STA_BSS_RSSI_LOW event */ 982 typedef struct { 983 int32_t rssi; /**< RSSI value of bss */ 984 } wifi_event_bss_rssi_low_t; 985 986 /** 987 * @brief FTM operation status types 988 * 989 */ 990 typedef enum { 991 FTM_STATUS_SUCCESS = 0, /**< FTM exchange is successful */ 992 FTM_STATUS_UNSUPPORTED, /**< Peer does not support FTM */ 993 FTM_STATUS_CONF_REJECTED, /**< Peer rejected FTM configuration in FTM Request */ 994 FTM_STATUS_NO_RESPONSE, /**< Peer did not respond to FTM Requests */ 995 FTM_STATUS_FAIL, /**< Unknown error during FTM exchange */ 996 } wifi_ftm_status_t; 997 998 /** Argument structure for */ 999 typedef struct { 1000 uint8_t dlog_token; /**< Dialog Token of the FTM frame */ 1001 int8_t rssi; /**< RSSI of the FTM frame received */ 1002 uint32_t rtt; /**< Round Trip Time in pSec with a peer */ 1003 uint64_t t1; /**< Time of departure of FTM frame from FTM Responder in pSec */ 1004 uint64_t t2; /**< Time of arrival of FTM frame at FTM Initiator in pSec */ 1005 uint64_t t3; /**< Time of departure of ACK from FTM Initiator in pSec */ 1006 uint64_t t4; /**< Time of arrival of ACK at FTM Responder in pSec */ 1007 } wifi_ftm_report_entry_t; 1008 1009 /** Argument structure for WIFI_EVENT_FTM_REPORT event */ 1010 typedef struct { 1011 uint8_t peer_mac[6]; /**< MAC address of the FTM Peer */ 1012 wifi_ftm_status_t status; /**< Status of the FTM operation */ 1013 uint32_t rtt_raw; /**< Raw average Round-Trip-Time with peer in Nano-Seconds */ 1014 uint32_t rtt_est; /**< Estimated Round-Trip-Time with peer in Nano-Seconds */ 1015 uint32_t dist_est; /**< Estimated one-way distance in Centi-Meters */ 1016 wifi_ftm_report_entry_t *ftm_report_data; /**< Pointer to FTM Report with multiple entries, should be freed after use */ 1017 uint8_t ftm_report_num_entries; /**< Number of entries in the FTM Report data */ 1018 } wifi_event_ftm_report_t; 1019 1020 #define WIFI_STATIS_BUFFER (1<<0) 1021 #define WIFI_STATIS_RXTX (1<<1) 1022 #define WIFI_STATIS_HW (1<<2) 1023 #define WIFI_STATIS_DIAG (1<<3) 1024 #define WIFI_STATIS_PS (1<<4) 1025 #define WIFI_STATIS_ALL (-1) 1026 1027 /** Argument structure for WIFI_EVENT_ACTION_TX_STATUS event */ 1028 typedef struct { 1029 wifi_interface_t ifx; /**< WiFi interface to send request to */ 1030 uint32_t context; /**< Context to identify the request */ 1031 uint8_t da[6]; /**< Destination MAC address */ 1032 uint8_t status; /**< Status of the operation */ 1033 } wifi_event_action_tx_status_t; 1034 1035 /** Argument structure for WIFI_EVENT_ROC_DONE event */ 1036 typedef struct { 1037 uint32_t context; /**< Context to identify the request */ 1038 } wifi_event_roc_done_t; 1039 1040 /** Argument structure for WIFI_EVENT_AP_WPS_RG_PIN event */ 1041 typedef struct { 1042 uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ 1043 } wifi_event_ap_wps_rg_pin_t; 1044 1045 typedef enum { 1046 WPS_AP_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ 1047 WPS_AP_FAIL_REASON_CONFIG, /**< WPS failed due to incorrect config */ 1048 WPS_AP_FAIL_REASON_AUTH, /**< WPS failed during auth */ 1049 WPS_AP_FAIL_REASON_MAX, 1050 } wps_fail_reason_t; 1051 1052 /** Argument structure for WIFI_EVENT_AP_WPS_RG_FAILED event */ 1053 typedef struct { 1054 wps_fail_reason_t reason; /**< WPS failure reason wps_fail_reason_t */ 1055 uint8_t peer_macaddr[6]; /**< Enrollee mac address */ 1056 } wifi_event_ap_wps_rg_fail_reason_t; 1057 1058 /** Argument structure for WIFI_EVENT_AP_WPS_RG_SUCCESS event */ 1059 typedef struct { 1060 uint8_t peer_macaddr[6]; /**< Enrollee mac address */ 1061 } wifi_event_ap_wps_rg_success_t; 1062 1063 /** Argument structure for WIFI_EVENT_NAN_SVC_MATCH event */ 1064 typedef struct { 1065 uint8_t subscribe_id; /**< Subscribe Service Identifier */ 1066 uint8_t publish_id; /**< Publish Service Identifier */ 1067 uint8_t pub_if_mac[6]; /**< NAN Interface MAC of the Publisher */ 1068 bool update_pub_id; /**< Indicates whether publisher's service ID needs to be updated */ 1069 } wifi_event_nan_svc_match_t; 1070 1071 /** Argument structure for WIFI_EVENT_NAN_REPLIED event */ 1072 typedef struct { 1073 uint8_t publish_id; /**< Publish Service Identifier */ 1074 uint8_t subscribe_id; /**< Subscribe Service Identifier */ 1075 uint8_t sub_if_mac[6]; /**< NAN Interface MAC of the Subscriber */ 1076 } wifi_event_nan_replied_t; 1077 1078 /** Argument structure for WIFI_EVENT_NAN_RECEIVE event */ 1079 typedef struct { 1080 uint8_t inst_id; /**< Our Service Identifier */ 1081 uint8_t peer_inst_id; /**< Peer's Service Identifier */ 1082 uint8_t peer_if_mac[6]; /**< Peer's NAN Interface MAC */ 1083 uint8_t peer_svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Peer Service Info */ 1084 } wifi_event_nan_receive_t; 1085 1086 /** Argument structure for WIFI_EVENT_NDP_INDICATION event */ 1087 typedef struct { 1088 uint8_t publish_id; /**< Publish Id for NAN Service */ 1089 uint8_t ndp_id; /**< NDP instance id */ 1090 uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ 1091 uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ 1092 uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ 1093 } wifi_event_ndp_indication_t; 1094 1095 /** Argument structure for WIFI_EVENT_NDP_CONFIRM event */ 1096 typedef struct { 1097 uint8_t status; /**< NDP status code */ 1098 uint8_t ndp_id; /**< NDP instance id */ 1099 uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ 1100 uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ 1101 uint8_t own_ndi[6]; /**< Own NAN Data Interface MAC */ 1102 uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ 1103 } wifi_event_ndp_confirm_t; 1104 1105 /** Argument structure for WIFI_EVENT_NDP_TERMINATED event */ 1106 typedef struct { 1107 uint8_t reason; /**< Termination reason code */ 1108 uint8_t ndp_id; /**< NDP instance id */ 1109 uint8_t init_ndi[6]; /**< Initiator's NAN Data Interface MAC */ 1110 } wifi_event_ndp_terminated_t; 1111 1112 #ifdef __cplusplus 1113 } 1114 #endif 1115 1116 #endif /* __ESP_WIFI_TYPES_H__ */ 1117