From 07d60b1c0481c93299eff0762e7797f4aebc0cf9 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 26 Sep 2023 07:20:51 +0200 Subject: [PATCH 1/6] feat(esp_wifi): Add dependency on wifi_remote for chips with no wifi --- components/esp_wifi/CMakeLists.txt | 16 +++++++++++++++- components/esp_wifi/src/wifi_default.c | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 8605bed5df..97ddaec4ea 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -38,11 +38,18 @@ if(CONFIG_ESP_WIFI_ENABLED) if(CONFIG_ESP_WIFI_NAN_ENABLE) list(APPEND srcs "wifi_apps/src/nan_app.c") endif() + set(local_include_dirs include/local) +else() + # No local wifi: provide only netif bindings + set(srcs + "src/wifi_default.c" + "src/wifi_netif.c") + set(local_include_dirs) endif() idf_component_register(SRCS "${srcs}" - INCLUDE_DIRS "include" "wifi_apps/include" + INCLUDE_DIRS "include" "wifi_apps/include" ${local_include_dirs} REQUIRES esp_event esp_phy esp_netif PRIV_REQUIRES driver esptool_py esp_pm esp_timer nvs_flash wpa_supplicant hal lwip esp_coex ${extra_priv_requires} @@ -70,6 +77,13 @@ if(CONFIG_ESP_WIFI_ENABLED) target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) endforeach() endif() +else() + # No local wifi: use esp_wifi_remote if it's available within our components + idf_build_get_property(build_components BUILD_COMPONENTS) + if(esp_wifi_remote IN_LIST build_components) + idf_component_get_property(esp_wifi_remote esp_wifi_remote COMPONENT_LIB) + target_link_libraries(${COMPONENT_LIB} PUBLIC ${esp_wifi_remote}) + endif() if(CONFIG_SPIRAM) idf_component_optional_requires(PRIVATE esp_psram) diff --git a/components/esp_wifi/src/wifi_default.c b/components/esp_wifi/src/wifi_default.c index 9b8d06bd9d..4851d6bc7d 100644 --- a/components/esp_wifi/src/wifi_default.c +++ b/components/esp_wifi/src/wifi_default.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "sdkconfig.h" +#include "esp_system.h" #include "esp_wifi.h" #include "esp_netif.h" #include "esp_log.h" From 9088655030c232ab8487e00bef4716dcddfa54b5 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 6 Oct 2023 12:56:00 +0200 Subject: [PATCH 2/6] fix(esp_wifi): Separate public and native wifi interface types --- components/esp_wifi/Kconfig | 1217 +++++++++-------- .../esp_private/esp_wifi_types_private.h | 19 +- .../include/esp_private/wifi_os_adapter.h | 2 +- .../esp_wifi/include/esp_private/wifi_types.h | 40 +- components/esp_wifi/include/esp_wifi.h | 10 +- .../esp_wifi/include/esp_wifi_crypto_types.h | 2 +- .../esp_wifi/include/esp_wifi_he_types.h | 8 +- components/esp_wifi/include/esp_wifi_types.h | 139 +- .../esp_wifi/include/local/esp_wifi_native.h | 121 ++ components/wpa_supplicant/port/include/os.h | 1 + .../wpa_supplicant/src/utils/includes.h | 1 + tools/ci/check_copyright_ignore.txt | 2 - 12 files changed, 791 insertions(+), 771 deletions(-) create mode 100644 components/esp_wifi/include/local/esp_wifi_native.h diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 8677918390..cda9c5ecae 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -7,630 +7,637 @@ menu "Wi-Fi" bool default y if SOC_WIFI_SUPPORTED - config ESP_WIFI_STATIC_RX_BUFFER_NUM - int "Max number of WiFi static RX buffers" - range 2 25 if !SOC_WIFI_HE_SUPPORT - range 2 128 if SOC_WIFI_HE_SUPPORT - default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP - help - Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. - The static rx buffers are allocated when esp_wifi_init is called, they are not freed - until esp_wifi_deinit is called. - - WiFi hardware use these buffers to receive all 802.11 frames. - A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED - is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to - achieve better throughput and compatibility with both stations and APs. - - config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM - int "Max number of WiFi dynamic RX buffers" - range 0 128 if !LWIP_WND_SCALE - range 0 1024 if LWIP_WND_SCALE - default 32 - help - Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated - (provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of - the received data frame. - - For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers - it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has - successfully received the data frame. - - For some applications, WiFi data frames may be received faster than the application can - process them. In these cases we may run out of memory if RX buffer number is unlimited (0). - - If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers. - - choice ESP_WIFI_TX_BUFFER - prompt "Type of WiFi TX buffers" - default ESP_WIFI_DYNAMIC_TX_BUFFER - help - Select type of WiFi TX buffers: - - If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released - when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB. - - If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is - delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame - has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length - of each data frame sent by the TCP/IP layer. - - If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers. - If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM. - - config ESP_WIFI_STATIC_TX_BUFFER - bool "Static" - config ESP_WIFI_DYNAMIC_TX_BUFFER - bool "Dynamic" - depends on !SPIRAM_USE_MALLOC - endchoice - - config ESP_WIFI_TX_BUFFER_TYPE - int - default 0 if ESP_WIFI_STATIC_TX_BUFFER - default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER - - config ESP_WIFI_STATIC_TX_BUFFER_NUM - int "Max number of WiFi static TX buffers" - depends on ESP_WIFI_STATIC_TX_BUFFER - range 1 64 - default 16 - help - Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM. - The static RX buffers are allocated when esp_wifi_init() is called, they are not released - until esp_wifi_deinit() is called. - - For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a - copy of it in a TX buffer. For some applications especially UDP applications, the upper - layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out - of TX buffers. - - config ESP_WIFI_CACHE_TX_BUFFER_NUM - int "Max number of WiFi cache TX buffers" - depends on SPIRAM - range 16 128 - default 32 - help - Set the number of WiFi cache TX buffer number. - - For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX - buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer, - it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the - size of the cached TX queue. - - config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM - int "Max number of WiFi dynamic TX buffers" - depends on ESP_WIFI_DYNAMIC_TX_BUFFER - range 1 128 - default 32 - help - Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed, - it depends on the size of each transmitted data frame. - - For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy - of it in a TX buffer. For some applications, especially UDP applications, the upper layer - can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX - buffers. - - choice ESP_WIFI_MGMT_RX_BUFFER - prompt "Type of WiFi RX MGMT buffers" - default ESP_WIFI_STATIC_RX_MGMT_BUFFER - help - Select type of WiFi RX MGMT buffers: - - If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released - when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes. - - If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is - received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver. - - - config ESP_WIFI_STATIC_RX_MGMT_BUFFER - bool "Static" - config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER - bool "Dynamic" - endchoice - - config ESP_WIFI_DYNAMIC_RX_MGMT_BUF - int - default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER - default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER - - config ESP_WIFI_RX_MGMT_BUF_NUM_DEF - int "Max number of WiFi RX MGMT buffers" - range 1 10 - default 5 - help - Set the number of WiFi RX_MGMT buffers. - - For Management buffers, the number of dynamic and static management buffers is the same. - In order to prevent memory fragmentation, the management buffer type should be set to static first. - - config ESP_WIFI_CSI_ENABLED - bool "WiFi CSI(Channel State Information)" - depends on SOC_WIFI_CSI_SUPPORT - default n - help - Select this option to enable CSI(Channel State Information) feature. CSI takes about - CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable - this feature in order to save memory. - - config ESP_WIFI_AMPDU_TX_ENABLED - bool "WiFi AMPDU TX" - default y - help - Select this option to enable AMPDU TX feature - - - config ESP_WIFI_TX_BA_WIN - int "WiFi AMPDU TX BA window size" - depends on ESP_WIFI_AMPDU_TX_ENABLED - range 2 32 if !SOC_WIFI_HE_SUPPORT - range 2 64 if SOC_WIFI_HE_SUPPORT - default 6 - help - Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but - more memory. Most of time we should NOT change the default value unless special reason, e.g. - test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended - value is 9~12. - - config ESP_WIFI_AMPDU_RX_ENABLED - bool "WiFi AMPDU RX" - default y - help - Select this option to enable AMPDU RX feature - - config ESP_WIFI_RX_BA_WIN - int "WiFi AMPDU RX BA window size" - depends on ESP_WIFI_AMPDU_RX_ENABLED - range 2 32 if !SOC_WIFI_HE_SUPPORT - range 2 64 if SOC_WIFI_HE_SUPPORT - default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP - help - Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better - compatibility but more memory. Most of time we should NOT change the default value unless special - reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the - recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, - the default and minimum value should be 16 to achieve better throughput and compatibility with both - stations and APs. - - config ESP_WIFI_AMSDU_TX_ENABLED - bool "WiFi AMSDU TX" - depends on SPIRAM - default n - help - Select this option to enable AMSDU TX feature - - config ESP_WIFI_NVS_ENABLED - bool "WiFi NVS flash" - default y - help - Select this option to enable WiFi NVS flash - - choice ESP_WIFI_TASK_CORE_ID - depends on !FREERTOS_UNICORE - prompt "WiFi Task Core ID" - default ESP_WIFI_TASK_PINNED_TO_CORE_0 - help - Pinned WiFi task to core 0 or core 1. - - config ESP_WIFI_TASK_PINNED_TO_CORE_0 - bool "Core 0" - config ESP_WIFI_TASK_PINNED_TO_CORE_1 - bool "Core 1" - endchoice - - config ESP_WIFI_SOFTAP_BEACON_MAX_LEN - int "Max length of WiFi SoftAP Beacon" - range 752 1256 - default 752 - help - ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However the - default length of a beacon frame can simultaneously hold only five root node identifier structures, - meaning that a root node conflict of up to five nodes can be detected at one time. In the occurence of - more root nodes conflict involving more than five root nodes, the conflict resolution process will detect - five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will repeat - until all root node conflicts are resolved. However this process can generally take a very long time. - - To counter this situation, the beacon frame length can be increased such that more root nodes can be - detected simultaneously. Each additional root node will require 36 bytes and should be added ontop of the - default beacon frame length of - 752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon - frame length as - 932 (752+36*5). - - Setting a longer beacon length also assists with debugging as the conflicting root nodes can be identified - more quickly. - - config ESP_WIFI_MGMT_SBUF_NUM - int "WiFi mgmt short buffer number" - range 6 32 - default 32 - help - Set the number of WiFi management short buffer. - - config ESP_WIFI_IRAM_OPT - bool "WiFi IRAM speed optimization" - default n if (BT_ENABLED && SPIRAM && IDF_TARGET_ESP32) - default y - help - Select this option to place frequently called Wi-Fi library functions in IRAM. - When this option is disabled, more than 10Kbytes of IRAM memory will be saved - but Wi-Fi throughput will be reduced. - - config ESP_WIFI_EXTRA_IRAM_OPT - bool "WiFi EXTRA IRAM speed optimization" - default y if IDF_TARGET_ESP32C6 - default n - help - Select this option to place additional frequently called Wi-Fi library functions - in IRAM. When this option is disabled, more than 5Kbytes of IRAM memory will be saved - but Wi-Fi throughput will be reduced. - - config ESP_WIFI_RX_IRAM_OPT - bool "WiFi RX IRAM speed optimization" - default n if (BT_ENABLED && SPIRAM && IDF_TARGET_ESP32) - default y - help - Select this option to place frequently called Wi-Fi library RX functions in IRAM. - When this option is disabled, more than 17Kbytes of IRAM memory will be saved - but Wi-Fi performance will be reduced. - - config ESP_WIFI_ENABLE_WPA3_SAE - bool "Enable WPA3-Personal" - default y - select ESP_WIFI_MBEDTLS_CRYPTO - help - Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's. - PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be - explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details. - - config ESP_WIFI_ENABLE_SAE_PK - bool "Enable SAE-PK" - default y - depends on ESP_WIFI_ENABLE_WPA3_SAE - help - Select this option to enable SAE-PK - - config ESP_WIFI_SOFTAP_SAE_SUPPORT - bool "Enable WPA3 Personal(SAE) SoftAP" - default y - depends on ESP_WIFI_ENABLE_WPA3_SAE - depends on ESP_WIFI_SOFTAP_SUPPORT - help - Select this option to enable SAE support in softAP mode. - - config ESP_WIFI_ENABLE_WPA3_OWE_STA - bool "Enable OWE STA" - default y - select ESP_WIFI_MBEDTLS_CRYPTO - help - Select this option to allow the device to establish OWE connection with eligible AP's. - PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be - explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details. - - config ESP_WIFI_SLP_IRAM_OPT - bool "WiFi SLP IRAM speed optimization" - select PM_SLP_DEFAULT_PARAMS_OPT - select PERIPH_CTRL_FUNC_IN_IRAM - help - Select this option to place called Wi-Fi library TBTT process and receive beacon functions in IRAM. - Some functions can be put in IRAM either by ESP_WIFI_IRAM_OPT and ESP_WIFI_RX_IRAM_OPT, or this one. - If already enabled ESP_WIFI_IRAM_OPT, the other 7.3KB IRAM memory would be taken by this option. - If already enabled ESP_WIFI_RX_IRAM_OPT, the other 1.3KB IRAM memory would be taken by this option. - If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option. - Wi-Fi power-save mode average current would be reduced if this option is enabled. - - config ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME - int "Minimum active time" - range 8 60 - default 50 - depends on ESP_WIFI_SLP_IRAM_OPT - help - The minimum timeout for waiting to receive data, unit: milliseconds. - - config ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME - int "Maximum keep alive time" - range 10 60 - default 10 - depends on ESP_WIFI_SLP_IRAM_OPT - help - The maximum time that wifi keep alive, unit: seconds. - - config ESP_WIFI_FTM_ENABLE - bool "WiFi FTM" - default n - depends on SOC_WIFI_FTM_SUPPORT - help - Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). - - config ESP_WIFI_FTM_INITIATOR_SUPPORT - bool "FTM Initiator support" - default y - depends on ESP_WIFI_FTM_ENABLE - - config ESP_WIFI_FTM_RESPONDER_SUPPORT - bool "FTM Responder support" - default y - depends on ESP_WIFI_FTM_ENABLE - - config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE - bool "Power Management for station at disconnected" - default y - help - Select this option to enable power_management for station when disconnected. - Chip will do modem-sleep when rf module is not in use any more. - - config ESP_WIFI_GCMP_SUPPORT - bool "WiFi GCMP Support(GCMP128 and GCMP256)" - default n - depends on SOC_WIFI_GCMP_SUPPORT - help - Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support. - - config ESP_WIFI_GMAC_SUPPORT - bool "WiFi GMAC Support(GMAC128 and GMAC256)" - default n - help - Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification. - - config ESP_WIFI_SOFTAP_SUPPORT - bool "WiFi SoftAP Support" - default y - help - WiFi module can be compiled without SoftAP to save code size. - - config ESP_WIFI_ENHANCED_LIGHT_SLEEP - bool "WiFi modem automatically receives the beacon" - default n - depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP - help - The wifi modem automatically receives the beacon frame during light sleep. - - config ESP_WIFI_SLP_BEACON_LOST_OPT - bool "Wifi sleep optimize when beacon lost" - help - Enable wifi sleep optimization when beacon loss occurs and immediately enter - sleep mode when the WiFi module detects beacon loss. - - config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT - int "Beacon loss timeout" - range 5 100 - default 10 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT - help - Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. - - config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD - int "Maximum number of consecutive lost beacons allowed" - range 0 8 - default 3 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT - help - Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when - the number of consecutive beacons lost is greater than the given threshold. - - config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME - int "Delta early time for RF PHY on" - range 0 100 - default 2 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW - help - Delta early time for rf phy on, When the beacon is lost, the next rf phy on will - be earlier the time specified by the configuration item, Unit: 32 microsecond. - - config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME - int "Delta timeout time for RF PHY off" - range 0 8 - default 2 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW - help - Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will - be delayed for the time specified by the configuration item. Unit: 1024 microsecond. - - config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM - int "Maximum espnow encrypt peers number" - range 0 4 if IDF_TARGET_ESP32C2 - range 0 17 if (!IDF_TARGET_ESP32C2) - default 2 if IDF_TARGET_ESP32C2 - default 7 if (!IDF_TARGET_ESP32C2) - help - Maximum number of encrypted peers supported by espnow. - The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same - hardware keys. So this configuration will affect the maximum connection number of SoftAP. - Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware keys number. - When using ESP mesh, this value should be set to a maximum of 6. - - config ESP_WIFI_NAN_ENABLE - bool "WiFi Aware" - default n - depends on SOC_WIFI_NAN_SUPPORT - help - Enable WiFi Aware (NAN) feature. - - config ESP_WIFI_ENABLE_WIFI_TX_STATS - bool "Enable Wi-Fi transmission statistics" - depends on SOC_WIFI_HE_SUPPORT - default "y" - help - Enable Wi-Fi transmission statistics. Total support 4 access category. Each access category - will use 346 bytes memory. - - config ESP_WIFI_MBEDTLS_CRYPTO - bool "Use MbedTLS crypto APIs" - default y - select MBEDTLS_AES_C - select MBEDTLS_ECP_C - select MBEDTLS_ECDH_C - select MBEDTLS_ECDSA_C - select MBEDTLS_CMAC_C - select MBEDTLS_ECP_DP_SECP256R1_ENABLED - help - Select this option to enable the use of MbedTLS crypto APIs. - The internal crypto support within the supplicant is limited - and may not suffice for all new security features, including WPA3. - - It is recommended to always keep this option enabled. Additionally, - note that MbedTLS can leverage hardware acceleration if available, - resulting in significantly faster cryptographic operations. - - if ESP_WIFI_MBEDTLS_CRYPTO - config ESP_WIFI_MBEDTLS_TLS_CLIENT - bool "Use MbedTLS TLS client for WiFi Enterprise connection" - depends on ESP_WIFI_ENTERPRISE_SUPPORT + if ESP_WIFI_ENABLED + + config ESP_WIFI_STATIC_RX_BUFFER_NUM + int "Max number of WiFi static RX buffers" + range 2 25 if !SOC_WIFI_HE_SUPPORT + range 2 128 if SOC_WIFI_HE_SUPPORT + default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. + The static rx buffers are allocated when esp_wifi_init is called, they are not freed + until esp_wifi_deinit is called. + + WiFi hardware use these buffers to receive all 802.11 frames. + A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED + is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to + achieve better throughput and compatibility with both stations and APs. + + config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM + int "Max number of WiFi dynamic RX buffers" + range 0 128 if !LWIP_WND_SCALE + range 0 1024 if LWIP_WND_SCALE + default 32 + help + Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated + (provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of + the received data frame. + + For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers + it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has + successfully received the data frame. + + For some applications, WiFi data frames may be received faster than the application can + process them. In these cases we may run out of memory if RX buffer number is unlimited (0). + + If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers. + + choice ESP_WIFI_TX_BUFFER + prompt "Type of WiFi TX buffers" + default ESP_WIFI_DYNAMIC_TX_BUFFER + help + Select type of WiFi TX buffers: + + If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB. + + If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is + delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame + has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length + of each data frame sent by the TCP/IP layer. + + If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers. + If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM. + + config ESP_WIFI_STATIC_TX_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_TX_BUFFER + bool "Dynamic" + depends on !SPIRAM_USE_MALLOC + endchoice + + config ESP_WIFI_TX_BUFFER_TYPE + int + default 0 if ESP_WIFI_STATIC_TX_BUFFER + default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER + + config ESP_WIFI_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on ESP_WIFI_STATIC_TX_BUFFER + range 1 64 + default 16 + help + Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM. + The static RX buffers are allocated when esp_wifi_init() is called, they are not released + until esp_wifi_deinit() is called. + + For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a + copy of it in a TX buffer. For some applications especially UDP applications, the upper + layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out + of TX buffers. + + config ESP_WIFI_CACHE_TX_BUFFER_NUM + int "Max number of WiFi cache TX buffers" + depends on SPIRAM + range 16 128 + default 32 + help + Set the number of WiFi cache TX buffer number. + + For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX + buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer, + it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the + size of the cached TX queue. + + config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM + int "Max number of WiFi dynamic TX buffers" + depends on ESP_WIFI_DYNAMIC_TX_BUFFER + range 1 128 + default 32 + help + Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed, + it depends on the size of each transmitted data frame. + + For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy + of it in a TX buffer. For some applications, especially UDP applications, the upper layer + can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX + buffers. + + choice ESP_WIFI_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP_WIFI_STATIC_RX_MGMT_BUFFER + help + Select type of WiFi RX MGMT buffers: + + If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes. + + If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is + received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver. + + + config ESP_WIFI_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" + endchoice + + config ESP_WIFI_DYNAMIC_RX_MGMT_BUF + int + default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER + default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + + config ESP_WIFI_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 1 10 + default 5 + help + Set the number of WiFi RX_MGMT buffers. + + For Management buffers, the number of dynamic and static management buffers is the same. + In order to prevent memory fragmentation, the management buffer type should be set to static first. + + config ESP_WIFI_CSI_ENABLED + bool "WiFi CSI(Channel State Information)" + depends on SOC_WIFI_CSI_SUPPORT + default n + help + Select this option to enable CSI(Channel State Information) feature. CSI takes about + CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable + this feature in order to save memory. + + config ESP_WIFI_AMPDU_TX_ENABLED + bool "WiFi AMPDU TX" default y - select MBEDTLS_TLS_ENABLED help - Select this option to use MbedTLS TLS client for WPA2 enterprise connection. - Please note that from MbedTLS-3.0 onwards, MbedTLS does not support SSL-3.0 - TLS-v1.0, TLS-v1.1 versions. Incase your server is using one of these version, - it is advisable to update your server. - Please disable this option for compatibilty with older TLS versions. - endif + Select this option to enable AMPDU TX feature - config ESP_WIFI_WAPI_PSK - bool "Enable WAPI PSK support" - depends on SOC_WIFI_WAPI_SUPPORT - default n - help - Select this option to enable WAPI-PSK - which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003). - config ESP_WIFI_SUITE_B_192 - bool "Enable NSA suite B support with 192 bit key" - default n - depends on SOC_WIFI_GCMP_SUPPORT - select ESP_WIFI_GCMP_SUPPORT - select ESP_WIFI_GMAC_SUPPORT - help - Select this option to enable 192 bit NSA suite-B. - This is necessary to support WPA3 192 bit security. + config ESP_WIFI_TX_BA_WIN + int "WiFi AMPDU TX BA window size" + depends on ESP_WIFI_AMPDU_TX_ENABLED + range 2 32 if !SOC_WIFI_HE_SUPPORT + range 2 64 if SOC_WIFI_HE_SUPPORT + default 6 + help + Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but + more memory. Most of time we should NOT change the default value unless special reason, e.g. + test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended + value is 9~12. - config ESP_WIFI_11KV_SUPPORT - bool "Enable 802.11k, 802.11v APIs Support" - default n - help - Select this option to enable 802.11k 802.11v APIs(RRM and BTM support). - Only APIs which are helpful for network assisted roaming - are supported for now. - Enable this option with BTM and RRM enabled in sta config - to make device ready for network assisted roaming. - BTM: BSS transition management enables an AP to request a station to transition - to a specific AP, or to indicate to a station a set of preferred APs. - RRM: Radio measurements enable STAs to understand the radio environment, - it enables STAs to observe and gather data on radio link performance - and on the radio environment. Current implementation adds beacon report, - link measurement, neighbor report. + config ESP_WIFI_AMPDU_RX_ENABLED + bool "WiFi AMPDU RX" + default y + help + Select this option to enable AMPDU RX feature - config ESP_WIFI_SCAN_CACHE - bool "Keep scan results in cache" - depends on ESP_WIFI_11KV_SUPPORT - default n - help - Keep scan results in cache, if not enabled, those - will be flushed immediately. + config ESP_WIFI_RX_BA_WIN + int "WiFi AMPDU RX BA window size" + depends on ESP_WIFI_AMPDU_RX_ENABLED + range 2 32 if !SOC_WIFI_HE_SUPPORT + range 2 64 if SOC_WIFI_HE_SUPPORT + default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better + compatibility but more memory. Most of time we should NOT change the default value unless special + reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the + recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, + the default and minimum value should be 16 to achieve better throughput and compatibility with both + stations and APs. - config ESP_WIFI_MBO_SUPPORT - bool "Enable Multi Band Operation Certification Support" - default n - select ESP_WIFI_11KV_SUPPORT - select ESP_WIFI_SCAN_CACHE - help - Select this option to enable WiFi Multiband operation certification support. - - config ESP_WIFI_DPP_SUPPORT - bool "Enable DPP support" - default n - select ESP_WIFI_MBEDTLS_CRYPTO - help - Select this option to enable WiFi Easy Connect Support. - - config ESP_WIFI_11R_SUPPORT - bool "Enable 802.11R (Fast Transition) Support" - default n - help - Select this option to enable WiFi Fast Transition Support. - - config ESP_WIFI_WPS_SOFTAP_REGISTRAR - bool "Add WPS Registrar support in SoftAP mode" - depends on ESP_WIFI_SOFTAP_SUPPORT - default n - help - Select this option to enable WPS registrar support in softAP mode. - - config ESP_WIFI_ENABLE_WIFI_RX_STATS - bool "Enable Wi-Fi reception statistics" - depends on SOC_WIFI_HE_SUPPORT - default "y" - help - Enable Wi-Fi reception statistics. Total support 2 access category. Each access category - will use 190 bytes memory. - - config ESP_WIFI_ENABLE_WIFI_RX_MU_STATS - bool "Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics" - depends on ESP_WIFI_ENABLE_WIFI_RX_STATS - default "y" - help - Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory. - - menu "WPS Configuration Options" - config ESP_WIFI_WPS_STRICT - bool "Strictly validate all WPS attributes" + config ESP_WIFI_AMSDU_TX_ENABLED + bool "WiFi AMSDU TX" + depends on SPIRAM default n help - Select this option to enable validate each WPS attribute - rigorously. Disabling this add the workaorunds with various APs. - Enabling this may cause inter operability issues with some APs. + Select this option to enable AMSDU TX feature - config ESP_WIFI_WPS_PASSPHRASE - bool "Get WPA2 passphrase in WPS config" + config ESP_WIFI_NVS_ENABLED + bool "WiFi NVS flash" + default y + help + Select this option to enable WiFi NVS flash + + choice ESP_WIFI_TASK_CORE_ID + depends on !FREERTOS_UNICORE + prompt "WiFi Task Core ID" + default ESP_WIFI_TASK_PINNED_TO_CORE_0 + help + Pinned WiFi task to core 0 or core 1. + + config ESP_WIFI_TASK_PINNED_TO_CORE_0 + bool "Core 0" + config ESP_WIFI_TASK_PINNED_TO_CORE_1 + bool "Core 1" + endchoice + + config ESP_WIFI_SOFTAP_BEACON_MAX_LEN + int "Max length of WiFi SoftAP Beacon" + range 752 1256 + default 752 + help + ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However + the default length of a beacon frame can simultaneously hold only five root node identifier structures, + meaning that a root node conflict of up to five nodes can be detected at one time. In the occurence of + more root nodes conflict involving more than five root nodes, the conflict resolution process will + detect five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will + repeat until all root node conflicts are resolved. However this process can generally take a very long + time. + + To counter this situation, the beacon frame length can be increased such that more root nodes can be + detected simultaneously. Each additional root node will require 36 bytes and should be added ontop of + the default beacon frame length of + 752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon + frame length as + 932 (752+36*5). + + Setting a longer beacon length also assists with debugging as the conflicting root nodes can be + identified more quickly. + + config ESP_WIFI_MGMT_SBUF_NUM + int "WiFi mgmt short buffer number" + range 6 32 + default 32 + help + Set the number of WiFi management short buffer. + + config ESP_WIFI_IRAM_OPT + bool "WiFi IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library functions in IRAM. + When this option is disabled, more than 10Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. + + config ESP_WIFI_EXTRA_IRAM_OPT + bool "WiFi EXTRA IRAM speed optimization" + default y if IDF_TARGET_ESP32C6 default n help - Select this option to get passphrase during WPS configuration. - This option fakes the virtual display capabilites to get the - configuration in passphrase mode. - Not recommanded to be used since WPS credentials should not - be shared to other devices, making it in readable format increases - that risk, also passphrase requires pbkdf2 to convert in psk. + Select this option to place additional frequently called Wi-Fi library functions + in IRAM. When this option is disabled, more than 5Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. - endmenu # "WPS Configuration Options" + config ESP_WIFI_RX_IRAM_OPT + bool "WiFi RX IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library RX functions in IRAM. + When this option is disabled, more than 17Kbytes of IRAM memory will be saved + but Wi-Fi performance will be reduced. + + config ESP_WIFI_ENABLE_WPA3_SAE + bool "Enable WPA3-Personal" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_ENABLE_SAE_PK + bool "Enable SAE-PK" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + help + Select this option to enable SAE-PK + + config ESP_WIFI_SOFTAP_SAE_SUPPORT + bool "Enable WPA3 Personal(SAE) SoftAP" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + depends on ESP_WIFI_SOFTAP_SUPPORT + help + Select this option to enable SAE support in softAP mode. + + config ESP_WIFI_ENABLE_WPA3_OWE_STA + bool "Enable OWE STA" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish OWE connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_SLP_IRAM_OPT + bool "WiFi SLP IRAM speed optimization" + select PM_SLP_DEFAULT_PARAMS_OPT + select PERIPH_CTRL_FUNC_IN_IRAM + help + Select this option to place called Wi-Fi library TBTT process and receive beacon functions in IRAM. + Some functions can be put in IRAM either by ESP_WIFI_IRAM_OPT and ESP_WIFI_RX_IRAM_OPT, or this one. + If already enabled ESP_WIFI_IRAM_OPT, the other 7.3KB IRAM memory would be taken by this option. + If already enabled ESP_WIFI_RX_IRAM_OPT, the other 1.3KB IRAM memory would be taken by this option. + If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option. + Wi-Fi power-save mode average current would be reduced if this option is enabled. + + config ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME + int "Minimum active time" + range 8 60 + default 50 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The minimum timeout for waiting to receive data, unit: milliseconds. + + config ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME + int "Maximum keep alive time" + range 10 60 + default 10 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The maximum time that wifi keep alive, unit: seconds. + + config ESP_WIFI_FTM_ENABLE + bool "WiFi FTM" + default n + depends on SOC_WIFI_FTM_SUPPORT + help + Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). + + config ESP_WIFI_FTM_INITIATOR_SUPPORT + bool "FTM Initiator support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_FTM_RESPONDER_SUPPORT + bool "FTM Responder support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + bool "Power Management for station at disconnected" + default y + help + Select this option to enable power_management for station when disconnected. + Chip will do modem-sleep when rf module is not in use any more. + + config ESP_WIFI_GCMP_SUPPORT + bool "WiFi GCMP Support(GCMP128 and GCMP256)" + default n + depends on SOC_WIFI_GCMP_SUPPORT + help + Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support. + + config ESP_WIFI_GMAC_SUPPORT + bool "WiFi GMAC Support(GMAC128 and GMAC256)" + default n + help + Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification. + + config ESP_WIFI_SOFTAP_SUPPORT + bool "WiFi SoftAP Support" + default y + help + WiFi module can be compiled without SoftAP to save code size. + + config ESP_WIFI_ENHANCED_LIGHT_SLEEP + bool "WiFi modem automatically receives the beacon" + default n + depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP + help + The wifi modem automatically receives the beacon frame during light sleep. + + config ESP_WIFI_SLP_BEACON_LOST_OPT + bool "Wifi sleep optimize when beacon lost" + help + Enable wifi sleep optimization when beacon loss occurs and immediately enter + sleep mode when the WiFi module detects beacon loss. + + config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT + int "Beacon loss timeout" + range 5 100 + default 10 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. + + config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD + int "Maximum number of consecutive lost beacons allowed" + range 0 8 + default 3 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when + the number of consecutive beacons lost is greater than the given threshold. + + config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME + int "Delta early time for RF PHY on" + range 0 100 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta early time for rf phy on, When the beacon is lost, the next rf phy on will + be earlier the time specified by the configuration item, Unit: 32 microsecond. + + config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME + int "Delta timeout time for RF PHY off" + range 0 8 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will + be delayed for the time specified by the configuration item. Unit: 1024 microsecond. + + config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM + int "Maximum espnow encrypt peers number" + range 0 4 if IDF_TARGET_ESP32C2 + range 0 17 if (!IDF_TARGET_ESP32C2) + default 2 if IDF_TARGET_ESP32C2 + default 7 if (!IDF_TARGET_ESP32C2) + help + Maximum number of encrypted peers supported by espnow. + The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same + hardware keys. So this configuration will affect the maximum connection number of SoftAP. + Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware + keys number. When using ESP mesh, this value should be set to a maximum of 6. + + config ESP_WIFI_NAN_ENABLE + bool "WiFi Aware" + default n + depends on SOC_WIFI_NAN_SUPPORT + help + Enable WiFi Aware (NAN) feature. + + config ESP_WIFI_ENABLE_WIFI_TX_STATS + bool "Enable Wi-Fi transmission statistics" + depends on SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi transmission statistics. Total support 4 access category. Each access category + will use 346 bytes memory. + + config ESP_WIFI_MBEDTLS_CRYPTO + bool "Use MbedTLS crypto APIs" + default y + select MBEDTLS_AES_C + select MBEDTLS_ECP_C + select MBEDTLS_ECDH_C + select MBEDTLS_ECDSA_C + select MBEDTLS_CMAC_C + select MBEDTLS_ECP_DP_SECP256R1_ENABLED + help + Select this option to enable the use of MbedTLS crypto APIs. + The internal crypto support within the supplicant is limited + and may not suffice for all new security features, including WPA3. + + It is recommended to always keep this option enabled. Additionally, + note that MbedTLS can leverage hardware acceleration if available, + resulting in significantly faster cryptographic operations. + + if ESP_WIFI_MBEDTLS_CRYPTO + config ESP_WIFI_MBEDTLS_TLS_CLIENT + bool "Use MbedTLS TLS client for WiFi Enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y + select MBEDTLS_TLS_ENABLED + help + Select this option to use MbedTLS TLS client for WPA2 enterprise connection. + Please note that from MbedTLS-3.0 onwards, MbedTLS does not support SSL-3.0 + TLS-v1.0, TLS-v1.1 versions. Incase your server is using one of these version, + it is advisable to update your server. + Please disable this option for compatibilty with older TLS versions. + endif + + config ESP_WIFI_WAPI_PSK + bool "Enable WAPI PSK support" + depends on SOC_WIFI_WAPI_SUPPORT + default n + help + Select this option to enable WAPI-PSK + which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003). + + config ESP_WIFI_SUITE_B_192 + bool "Enable NSA suite B support with 192 bit key" + default n + depends on SOC_WIFI_GCMP_SUPPORT + select ESP_WIFI_GCMP_SUPPORT + select ESP_WIFI_GMAC_SUPPORT + help + Select this option to enable 192 bit NSA suite-B. + This is necessary to support WPA3 192 bit security. + + config ESP_WIFI_11KV_SUPPORT + bool "Enable 802.11k, 802.11v APIs Support" + default n + help + Select this option to enable 802.11k 802.11v APIs(RRM and BTM support). + Only APIs which are helpful for network assisted roaming + are supported for now. + Enable this option with BTM and RRM enabled in sta config + to make device ready for network assisted roaming. + BTM: BSS transition management enables an AP to request a station to transition + to a specific AP, or to indicate to a station a set of preferred APs. + RRM: Radio measurements enable STAs to understand the radio environment, + it enables STAs to observe and gather data on radio link performance + and on the radio environment. Current implementation adds beacon report, + link measurement, neighbor report. + + config ESP_WIFI_SCAN_CACHE + bool "Keep scan results in cache" + depends on ESP_WIFI_11KV_SUPPORT + default n + help + Keep scan results in cache, if not enabled, those + will be flushed immediately. + + config ESP_WIFI_MBO_SUPPORT + bool "Enable Multi Band Operation Certification Support" + default n + select ESP_WIFI_11KV_SUPPORT + select ESP_WIFI_SCAN_CACHE + help + Select this option to enable WiFi Multiband operation certification support. + + config ESP_WIFI_DPP_SUPPORT + bool "Enable DPP support" + default n + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to enable WiFi Easy Connect Support. + + config ESP_WIFI_11R_SUPPORT + bool "Enable 802.11R (Fast Transition) Support" + default n + help + Select this option to enable WiFi Fast Transition Support. + + config ESP_WIFI_WPS_SOFTAP_REGISTRAR + bool "Add WPS Registrar support in SoftAP mode" + depends on ESP_WIFI_SOFTAP_SUPPORT + default n + help + Select this option to enable WPS registrar support in softAP mode. + + config ESP_WIFI_ENABLE_WIFI_RX_STATS + bool "Enable Wi-Fi reception statistics" + depends on SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi reception statistics. Total support 2 access category. Each access category + will use 190 bytes memory. + + config ESP_WIFI_ENABLE_WIFI_RX_MU_STATS + bool "Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics" + depends on ESP_WIFI_ENABLE_WIFI_RX_STATS + default "y" + help + Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory. + + menu "WPS Configuration Options" + config ESP_WIFI_WPS_STRICT + bool "Strictly validate all WPS attributes" + default n + help + Select this option to enable validate each WPS attribute + rigorously. Disabling this add the workaorunds with various APs. + Enabling this may cause inter operability issues with some APs. + + config ESP_WIFI_WPS_PASSPHRASE + bool "Get WPA2 passphrase in WPS config" + default n + help + Select this option to get passphrase during WPS configuration. + This option fakes the virtual display capabilites to get the + configuration in passphrase mode. + Not recommanded to be used since WPS credentials should not + be shared to other devices, making it in readable format increases + that risk, also passphrase requires pbkdf2 to convert in psk. + + endmenu # "WPS Configuration Options" - config ESP_WIFI_DEBUG_PRINT - bool "Print debug messages from WPA Supplicant" - default n - help - Select this option to print logging information from WPA supplicant, - this includes handshake information and key hex dumps depending - on the project logging level. + config ESP_WIFI_DEBUG_PRINT + bool "Print debug messages from WPA Supplicant" + default n + help + Select this option to print logging information from WPA supplicant, + this includes handshake information and key hex dumps depending + on the project logging level. - Enabling this could increase the build size ~60kb - depending on the project logging level. + Enabling this could increase the build size ~60kb + depending on the project logging level. - config ESP_WIFI_TESTING_OPTIONS - bool "Add DPP testing code" - default n - help - Select this to enable unity test for DPP. + config ESP_WIFI_TESTING_OPTIONS + bool "Add DPP testing code" + default n + help + Select this to enable unity test for DPP. - config ESP_WIFI_ENTERPRISE_SUPPORT - bool "Enable enterprise option" - default y - help - Select this to enable/disable enterprise connection support. + config ESP_WIFI_ENTERPRISE_SUPPORT + bool "Enable enterprise option" + default y + help + Select this to enable/disable enterprise connection support. - disabling this will reduce binary size. - disabling this will disable the use of any esp_wifi_sta_wpa2_ent_* (as APIs will be meaningless) + disabling this will reduce binary size. + disabling this will disable the use of any esp_wifi_sta_wpa2_ent_* (as APIs will be meaningless) - config ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER - bool "Free dynamic buffers during WiFi enterprise connection" - depends on ESP_WIFI_ENTERPRISE_SUPPORT - default y if IDF_TARGET_ESP32C2 - default n if !IDF_TARGET_ESP32C2 - help - Select this configuration to free dynamic buffers during WiFi enterprise connection. - This will enable chip to reduce heap consumption during WiFi enterprise connection. + config ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER + bool "Free dynamic buffers during WiFi enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y if IDF_TARGET_ESP32C2 + default n if !IDF_TARGET_ESP32C2 + help + Select this configuration to free dynamic buffers during WiFi enterprise connection. + This will enable chip to reduce heap consumption during WiFi enterprise connection. + + endif # wifi enabled endmenu # Wi-Fi diff --git a/components/esp_wifi/include/esp_private/esp_wifi_types_private.h b/components/esp_wifi/include/esp_private/esp_wifi_types_private.h index 55c70c77ca..aaf83b4072 100644 --- a/components/esp_wifi/include/esp_private/esp_wifi_types_private.h +++ b/components/esp_wifi/include/esp_private/esp_wifi_types_private.h @@ -1,16 +1,8 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_WIFI_TYPES_PRIVATE_H #define _ESP_WIFI_TYPES_PRIVATE_H @@ -19,7 +11,6 @@ #include #include "sys/queue.h" #include "esp_err.h" -#include "esp_interface.h" #include "esp_event_base.h" #endif diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index 84ace9fd1b..49d281ffe1 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -26,7 +26,7 @@ extern "C" { #define OSI_QUEUE_SEND_BACK 1 #define OSI_QUEUE_SEND_OVERWRITE 2 -typedef struct { +typedef struct wifi_osi_funcs_t { int32_t _version; bool (* _env_is_chip)(void); void (*_set_intr)(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio); diff --git a/components/esp_wifi/include/esp_private/wifi_types.h b/components/esp_wifi/include/esp_private/wifi_types.h index 4542492c8f..816d06a691 100644 --- a/components/esp_wifi/include/esp_private/wifi_types.h +++ b/components/esp_wifi/include/esp_private/wifi_types.h @@ -1,19 +1,13 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _WIFI_TYPES_H #define _WIFI_TYPES_H +#include +#include #ifdef __cplusplus extern "C" { @@ -47,6 +41,26 @@ typedef struct { } data; /**< Configuration of ioctl command */ } wifi_ioctl_config_t; +/** + * @brief WiFi beacon monitor parameter configuration + * + */ +typedef struct { + bool enable; /**< Enable or disable beacon monitor */ + uint8_t loss_timeout; /**< Beacon lost timeout */ + uint8_t loss_threshold; /**< Maximum number of consecutive lost beacons allowed */ + uint8_t delta_intr_early; /**< Delta early time for RF PHY on */ + uint8_t delta_loss_timeout; /**< Delta timeout time for RF PHY off */ +#if MAC_SUPPORT_PMU_MODEM_STATE + uint8_t beacon_abort: 1, /**< Enable or disable beacon abort */ + broadcast_wakeup: 1, /**< Enable or disable TIM element multicast wakeup */ + reserved: 6; /**< Reserved */ + uint8_t tsf_time_sync_deviation; /**< Deviation range to sync with AP TSF timestamp */ + uint16_t modem_state_consecutive; /**< PMU MODEM state consecutive count limit */ + uint16_t rf_ctrl_wait_cycle; /**< RF on wait time (unit: Modem APB clock cycle) */ +#endif +} wifi_beacon_monitor_config_t; + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index e4ea220cf7..241c18fe52 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -54,7 +54,7 @@ #include "esp_err.h" #include "esp_wifi_types.h" #include "esp_event.h" -#include "esp_private/esp_wifi_private.h" +#include "esp_wifi_crypto_types.h" #include "esp_wifi_default.h" #ifdef __cplusplus @@ -90,6 +90,8 @@ extern "C" { #define ESP_ERR_WIFI_DISCARD (ESP_ERR_WIFI_BASE + 27) /*!< Discard frame */ #define ESP_ERR_WIFI_ROC_IN_PROGRESS (ESP_ERR_WIFI_BASE + 28) /*!< ROC op is in progress */ +typedef struct wifi_osi_funcs_t wifi_osi_funcs_t; + /** * @brief WiFi stack configuration parameters passed to esp_wifi_init call. */ @@ -898,6 +900,12 @@ esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf); */ esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf); +/** + * @brief Forward declare wifi_sta_list_t. The definition depends on the target device + * that implements esp_wifi + */ +typedef struct wifi_sta_list_t wifi_sta_list_t; + /** * @brief Get STAs associated with soft-AP * diff --git a/components/esp_wifi/include/esp_wifi_crypto_types.h b/components/esp_wifi/include/esp_wifi_crypto_types.h index 6b41cc524a..1fae0297e5 100644 --- a/components/esp_wifi/include/esp_wifi_crypto_types.h +++ b/components/esp_wifi/include/esp_wifi_crypto_types.h @@ -393,7 +393,7 @@ typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t le * The structure can be set as software crypto or the crypto optimized by device's * hardware. */ -typedef struct { +typedef struct wpa_crypto_funcs_t { uint32_t size; /**< The crypto callback function structure size */ uint32_t version; /**< The crypto callback function structure version */ esp_aes_wrap_t aes_wrap; /**< The AES wrap callback function used by esp_wifi */ diff --git a/components/esp_wifi/include/esp_wifi_he_types.h b/components/esp_wifi/include/esp_wifi_he_types.h index 41d4424abd..02bc5efef1 100644 --- a/components/esp_wifi/include/esp_wifi_he_types.h +++ b/components/esp_wifi/include/esp_wifi_he_types.h @@ -40,7 +40,7 @@ enum { /** * @brief Channel state information(CSI) configuration type */ -typedef struct { +typedef struct wifi_csi_config_t { uint32_t enable : 1; /**< enable to acquire CSI */ uint32_t acquire_csi_legacy : 1; /**< enable to acquire L-LTF when receiving a 11g PPDU */ uint32_t acquire_csi_ht20 : 1; /**< enable to acquire HT-LTF when receiving an HT20 PPDU */ @@ -56,7 +56,7 @@ typedef struct { uint32_t val_scale_cfg : 2; /**< value 0-3 */ uint32_t dump_ack_en : 1; /**< enable to dump 802.11 ACK frame, default disabled */ uint32_t reserved : 19; /**< reserved */ -} wifi_csi_acquire_config_t; +} wifi_csi_config_t; /** * @brief HE variant HT Control field including UPH(UL power headroom) and OM(Operation mode) @@ -139,7 +139,7 @@ typedef enum { /** * @brief RxControl Info */ -typedef struct { +typedef struct wifi_pkt_rx_ctrl_t { signed rssi : 8; /**< the RSSI of the reception frame */ unsigned rate : 5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */ unsigned : 1; /**< reserved */ @@ -201,7 +201,7 @@ typedef struct { unsigned : 2; /**< reserved */ unsigned rx_state : 8; /**< reception state, 0: successful, others: failure */ unsigned : 24; /**< reserved */ -} __attribute__((packed)) esp_wifi_rxctrl_t; +} __attribute__((packed)) wifi_pkt_rx_ctrl_t; /** Argument structure for WIFI_EVENT_TWT_SET_UP event */ typedef struct { diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 62aca03a4e..e523f94619 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,10 +8,8 @@ #ifndef __ESP_WIFI_TYPES_H__ #define __ESP_WIFI_TYPES_H__ -#include "esp_private/esp_wifi_types_private.h" -#if CONFIG_SOC_WIFI_HE_SUPPORT -#include "esp_wifi_he_types.h" -#endif +#include "esp_event.h" +#include "esp_interface.h" #ifdef __cplusplus extern "C" { @@ -29,7 +27,7 @@ typedef enum { typedef enum { WIFI_IF_STA = ESP_IF_WIFI_STA, WIFI_IF_AP = ESP_IF_WIFI_AP, -#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) +#if CONFIG_SOC_WIFI_NAN_SUPPORT || !CONFIG_SOC_WIFI_ENABLED WIFI_IF_NAN = ESP_IF_WIFI_NAN, #endif WIFI_IF_MAX @@ -376,20 +374,6 @@ typedef struct { uint32_t reserved:26; /**< bit: 6..31 reserved */ } wifi_sta_info_t; -#if CONFIG_IDF_TARGET_ESP32C2 -#define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ -#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 -#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32C3 soft-AP */ -#else -#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ -#endif - -/** @brief List of stations associated with the Soft-AP */ -typedef struct { - wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ - int num; /**< number of stations in the list (other entries are invalid) */ -} wifi_sta_list_t; - typedef enum { WIFI_STORAGE_FLASH, /**< all configuration will store in both memory and flash */ WIFI_STORAGE_RAM, /**< all configuration will only store in the memory */ @@ -446,68 +430,7 @@ typedef struct { uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ } vendor_ie_data_t; -#if CONFIG_SOC_WIFI_HE_SUPPORT -typedef esp_wifi_rxctrl_t wifi_pkt_rx_ctrl_t; -#else -/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */ -typedef struct { - signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ - unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ - unsigned :1; /**< reserved */ - unsigned sig_mode:2; /**< Protocol of the reveived packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ - unsigned :16; /**< reserved */ - unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ - unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ - unsigned :16; /**< reserved */ - unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended. - Set to 0 indicates that only per-carrierindependent (unsmoothed) channel estimate is recommended. */ - unsigned not_sounding:1; /**< Set to 0 indicates that PPDU is a sounding PPDU. Set to 1indicates that the PPDU is not a sounding PPDU. - sounding PPDU is used for channel estimation by the request receiver */ - unsigned :1; /**< reserved */ - unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ - unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ - unsigned fec_coding:1; /**< Forward Error Correction(FEC). Flag is set for 11n packets which are LDPC */ - unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ -#if CONFIG_IDF_TARGET_ESP32 - signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ -#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 - unsigned :8; /**< reserved */ -#endif - unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */ - unsigned channel:4; /**< primary channel on which this packet is received */ - unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ - unsigned :8; /**< reserved */ - 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 */ - unsigned :32; /**< reserved */ -#if CONFIG_IDF_TARGET_ESP32S2 - unsigned :32; /**< reserved */ -#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 - signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ - unsigned :24; /**< reserved */ - unsigned :32; /**< reserved */ -#endif - unsigned :31; /**< reserved */ - unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */ -#if CONFIG_IDF_TARGET_ESP32S2 - signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ - unsigned :24; /**< reserved */ -#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 - unsigned :32; /**< reserved */ - unsigned :32; /**< reserved */ - unsigned :32; /**< reserved */ -#endif - unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */ - unsigned :12; /**< reserved */ - unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ -} wifi_pkt_rx_ctrl_t; -#endif - -/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. - */ -typedef struct { - wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ - 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. */ -} wifi_promiscuous_pkt_t; +typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; /** * @brief Promiscuous frame type @@ -556,36 +479,13 @@ typedef struct { * @brief Channel state information(CSI) configuration type * */ -#if CONFIG_SOC_WIFI_HE_SUPPORT -typedef wifi_csi_acquire_config_t wifi_csi_config_t; -#else -typedef struct { - bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ - bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ - bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */ - 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 */ - 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 */ - 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 */ - uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */ - bool dump_ack_en; /**< enable to dump 802.11 ACK frame, default disabled */ -} wifi_csi_config_t; -#endif +typedef struct wifi_csi_config_t wifi_csi_config_t; /** * @brief CSI data type * */ -typedef struct { - wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ - uint8_t mac[6]; /**< source MAC address of the CSI data */ - uint8_t dmac[6]; /**< destination MAC address of the CSI data */ - bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */ - int8_t *buf; /**< valid buffer of CSI data */ - uint16_t len; /**< valid length of CSI data */ - uint8_t *hdr; /**< header of the wifi packet */ - uint8_t *payload; /**< payload of the wifi packet */ - uint16_t payload_len; /**< payload len of the wifi packet */ -} wifi_csi_info_t; +typedef struct wifi_csi_info_t wifi_csi_info_t; /** * @brief WiFi GPIO configuration for antenna selection @@ -638,7 +538,6 @@ typedef struct { */ typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel); - /** * @brief Action Frame Tx Request * @@ -664,26 +563,6 @@ typedef struct { uint16_t burst_period; /**< Requested time period between consecutive FTM bursts in 100's of milliseconds (0 - No pref) */ } wifi_ftm_initiator_cfg_t; -/** - * @brief WiFi beacon monitor parameter configuration - * - */ -typedef struct { - bool enable; /**< Enable or disable beacon monitor */ - uint8_t loss_timeout; /**< Beacon lost timeout */ - uint8_t loss_threshold; /**< Maximum number of consecutive lost beacons allowed */ - uint8_t delta_intr_early; /**< Delta early time for RF PHY on */ - uint8_t delta_loss_timeout; /**< Delta timeout time for RF PHY off */ -#if MAC_SUPPORT_PMU_MODEM_STATE - uint8_t beacon_abort: 1, /**< Enable or disable beacon abort */ - broadcast_wakeup: 1, /**< Enable or disable TIM element multicast wakeup */ - reserved: 6; /**< Reserved */ - uint8_t tsf_time_sync_deviation; /**< Deviation range to sync with AP TSF timestamp */ - uint16_t modem_state_consecutive; /**< PMU MODEM state consecutive count limit */ - uint16_t rf_ctrl_wait_cycle; /**< RF on wait time (unit: Modem APB clock cycle) */ -#endif -} wifi_beacon_monitor_config_t; - #define ESP_WIFI_NAN_MAX_SVC_SUPPORTED 2 #define ESP_WIFI_NAN_DATAPATH_MAX_PEERS 2 @@ -816,7 +695,7 @@ typedef enum { WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI */ WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI */ WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI */ -#if CONFIG_SOC_WIFI_HE_SUPPORT +#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 with long GI */ WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 with long GI */ #endif @@ -843,7 +722,7 @@ typedef enum { WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI */ WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI */ WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI */ -#if CONFIG_SOC_WIFI_HE_SUPPORT +#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 with short GI */ WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 with short GI */ #endif diff --git a/components/esp_wifi/include/local/esp_wifi_native.h b/components/esp_wifi/include/local/esp_wifi_native.h new file mode 100644 index 0000000000..12d7f1e396 --- /dev/null +++ b/components/esp_wifi/include/local/esp_wifi_native.h @@ -0,0 +1,121 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" +#if CONFIG_SOC_WIFI_HE_SUPPORT +#include "esp_wifi_he_types.h" +#endif + + +#if CONFIG_IDF_TARGET_ESP32C2 +#define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ +#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 +#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32C3 soft-AP */ +#else +#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ +#endif + +/** @brief List of stations associated with the Soft-AP */ +typedef struct wifi_sta_list_t { + wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ + int num; /**< number of stations in the list (other entries are invalid) */ +} wifi_sta_list_t; + +#if !CONFIG_SOC_WIFI_HE_SUPPORT +/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */ +typedef struct wifi_pkt_rx_ctrl_t{ + signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ + unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ + unsigned :1; /**< reserved */ + unsigned sig_mode:2; /**< Protocol of the reveived packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ + unsigned :16; /**< reserved */ + unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ + unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ + unsigned :16; /**< reserved */ + unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended. + Set to 0 indicates that only per-carrierindependent (unsmoothed) channel estimate is recommended. */ + unsigned not_sounding:1; /**< Set to 0 indicates that PPDU is a sounding PPDU. Set to 1indicates that the PPDU is not a sounding PPDU. + sounding PPDU is used for channel estimation by the request receiver */ + unsigned :1; /**< reserved */ + unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ + unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ + unsigned fec_coding:1; /**< Forward Error Correction(FEC). Flag is set for 11n packets which are LDPC */ + unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ +#if CONFIG_IDF_TARGET_ESP32 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ +#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 + unsigned :8; /**< reserved */ +#endif + unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */ + unsigned channel:4; /**< primary channel on which this packet is received */ + unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ + unsigned :8; /**< reserved */ + 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 */ + unsigned :32; /**< reserved */ +#if CONFIG_IDF_TARGET_ESP32S2 + unsigned :32; /**< reserved */ +#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ + unsigned :24; /**< reserved */ + unsigned :32; /**< reserved */ +#endif + unsigned :31; /**< reserved */ + unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */ +#if CONFIG_IDF_TARGET_ESP32S2 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ + unsigned :24; /**< reserved */ +#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 + unsigned :32; /**< reserved */ + unsigned :32; /**< reserved */ + unsigned :32; /**< reserved */ +#endif + unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */ + unsigned :12; /**< reserved */ + unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ +} wifi_pkt_rx_ctrl_t; +#endif + +/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. + */ +typedef struct { + wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ + 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. */ +} wifi_promiscuous_pkt_t; + +/** + * @brief Channel state information(CSI) configuration type + * + */ +#if !CONFIG_SOC_WIFI_HE_SUPPORT +typedef struct wifi_csi_config_t{ + bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ + bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ + bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */ + 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 */ + 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 */ + 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 */ + uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */ + bool dump_ack_en; /**< enable to dump 802.11 ACK frame, default disabled */ +} wifi_csi_config_t; +#endif + +/** + * @brief CSI data type + * + */ +typedef struct wifi_csi_info_t { + wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ + uint8_t mac[6]; /**< source MAC address of the CSI data */ + uint8_t dmac[6]; /**< destination MAC address of the CSI data */ + bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */ + int8_t *buf; /**< valid buffer of CSI data */ + uint16_t len; /**< valid length of CSI data */ + uint8_t *hdr; /**< header of the wifi packet */ + uint8_t *payload; /**< payload of the wifi packet */ + uint16_t payload_len; /**< payload len of the wifi packet */ +} wifi_csi_info_t; diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index a3442fade9..5e95c17fec 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -21,6 +21,7 @@ #include #include "esp_err.h" #include "supplicant_opt.h" +#include "esp_private/esp_wifi_private.h" #include "esp_wifi.h" typedef time_t os_time_t; diff --git a/components/wpa_supplicant/src/utils/includes.h b/components/wpa_supplicant/src/utils/includes.h index 38e7607221..e22c75bb32 100644 --- a/components/wpa_supplicant/src/utils/includes.h +++ b/components/wpa_supplicant/src/utils/includes.h @@ -20,6 +20,7 @@ #define INCLUDES_H #include "supplicant_opt.h" +#include "esp_private/esp_wifi_private.h" #define AES_SMALL_TABLES #define CONFIG_NO_RANDOM_POOL diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 519620bac9..100bce010b 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -483,8 +483,6 @@ components/esp_rom/linux/esp_rom_crc.c components/esp_rom/linux/esp_rom_md5.c components/esp_rom/patches/esp_rom_crc.c components/esp_system/ubsan.c -components/esp_wifi/include/esp_private/esp_wifi_types_private.h -components/esp_wifi/include/esp_private/wifi_types.h components/esp_wifi/src/mesh_event.c components/fatfs/diskio/diskio.c components/fatfs/diskio/diskio_impl.h From 597f2ce001b5eebb4c2ce0d458dc75c440f8ea6a Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 19 Jan 2024 09:11:09 +0100 Subject: [PATCH 3/6] fix(esp_wifi): Split public/native, wifi_types.h -> types_generic.h --- components/esp_wifi/include/esp_wifi_types.h | 1017 +---------------- .../esp_wifi/include/esp_wifi_types_generic.h | 1017 +++++++++++++++++ 2 files changed, 1022 insertions(+), 1012 deletions(-) create mode 100644 components/esp_wifi/include/esp_wifi_types_generic.h diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index e523f94619..f237fbff4a 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -1,1017 +1,10 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ - - -#ifndef __ESP_WIFI_TYPES_H__ -#define __ESP_WIFI_TYPES_H__ - -#include "esp_event.h" -#include "esp_interface.h" - -#ifdef __cplusplus -extern "C" { +#pragma once +#include "esp_wifi_types_generic.h" +#if __has_include("esp_wifi_native.h") +#include "esp_wifi_native.h" #endif - -typedef enum { - WIFI_MODE_NULL = 0, /**< null mode */ - WIFI_MODE_STA, /**< WiFi station mode */ - WIFI_MODE_AP, /**< WiFi soft-AP mode */ - WIFI_MODE_APSTA, /**< WiFi station + soft-AP mode */ - WIFI_MODE_NAN, /**< WiFi NAN mode */ - WIFI_MODE_MAX -} wifi_mode_t; - -typedef enum { - WIFI_IF_STA = ESP_IF_WIFI_STA, - WIFI_IF_AP = ESP_IF_WIFI_AP, -#if CONFIG_SOC_WIFI_NAN_SUPPORT || !CONFIG_SOC_WIFI_ENABLED - WIFI_IF_NAN = ESP_IF_WIFI_NAN, -#endif - WIFI_IF_MAX -} wifi_interface_t; - -#define WIFI_OFFCHAN_TX_REQ 1 -#define WIFI_OFFCHAN_TX_CANCEL 0 - -#define WIFI_ROC_REQ 1 -#define WIFI_ROC_CANCEL 0 - -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 WiFi country-based regional restrictions. */ -typedef struct { - char cc[3]; /**< country code string */ - uint8_t schan; /**< start channel */ - uint8_t nchan; /**< total channel number */ - 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. */ - wifi_country_policy_t policy; /**< country policy */ -} wifi_country_t; - -/* Strength of authmodes */ -/* OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA3_PSK = WPA2_WPA3_PSK < WPA3_EXT_PSK = WPA3_EXT_PSK_MIXED_MODE */ -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 : WiFi EAP security */ - WIFI_AUTH_WPA2_ENTERPRISE = WIFI_AUTH_ENTERPRISE, /**< authenticate mode : WiFi 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, /**< authenticate mode : WPA3_PSK_EXT_KEY */ - WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE, /**< authenticate mode: WPA3_PSK + WPA3_PSK_EXT_KEY */ - WIFI_AUTH_MAX -} wifi_auth_mode_t; - -typedef enum { - WIFI_REASON_UNSPECIFIED = 1, - WIFI_REASON_AUTH_EXPIRE = 2, - WIFI_REASON_AUTH_LEAVE = 3, - WIFI_REASON_ASSOC_EXPIRE = 4, - WIFI_REASON_ASSOC_TOOMANY = 5, - WIFI_REASON_NOT_AUTHED = 6, - WIFI_REASON_NOT_ASSOCED = 7, - WIFI_REASON_ASSOC_LEAVE = 8, - WIFI_REASON_ASSOC_NOT_AUTHED = 9, - WIFI_REASON_DISASSOC_PWRCAP_BAD = 10, - WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11, - WIFI_REASON_BSS_TRANSITION_DISASSOC = 12, - WIFI_REASON_IE_INVALID = 13, - WIFI_REASON_MIC_FAILURE = 14, - WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, - WIFI_REASON_IE_IN_4WAY_DIFFERS = 17, - WIFI_REASON_GROUP_CIPHER_INVALID = 18, - WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19, - WIFI_REASON_AKMP_INVALID = 20, - WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21, - WIFI_REASON_INVALID_RSN_IE_CAP = 22, - WIFI_REASON_802_1X_AUTH_FAILED = 23, - WIFI_REASON_CIPHER_SUITE_REJECTED = 24, - WIFI_REASON_TDLS_PEER_UNREACHABLE = 25, - WIFI_REASON_TDLS_UNSPECIFIED = 26, - WIFI_REASON_SSP_REQUESTED_DISASSOC = 27, - WIFI_REASON_NO_SSP_ROAMING_AGREEMENT = 28, - WIFI_REASON_BAD_CIPHER_OR_AKM = 29, - WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30, - WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS = 31, - WIFI_REASON_UNSPECIFIED_QOS = 32, - WIFI_REASON_NOT_ENOUGH_BANDWIDTH = 33, - WIFI_REASON_MISSING_ACKS = 34, - WIFI_REASON_EXCEEDED_TXOP = 35, - WIFI_REASON_STA_LEAVING = 36, - WIFI_REASON_END_BA = 37, - WIFI_REASON_UNKNOWN_BA = 38, - WIFI_REASON_TIMEOUT = 39, - WIFI_REASON_PEER_INITIATED = 46, - WIFI_REASON_AP_INITIATED = 47, - WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48, - WIFI_REASON_INVALID_PMKID = 49, - WIFI_REASON_INVALID_MDE = 50, - WIFI_REASON_INVALID_FTE = 51, - WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED = 67, - WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED = 68, - - WIFI_REASON_BEACON_TIMEOUT = 200, - WIFI_REASON_NO_AP_FOUND = 201, - WIFI_REASON_AUTH_FAIL = 202, - WIFI_REASON_ASSOC_FAIL = 203, - WIFI_REASON_HANDSHAKE_TIMEOUT = 204, - WIFI_REASON_CONNECTION_FAIL = 205, - WIFI_REASON_AP_TSF_RESET = 206, - WIFI_REASON_ROAMING = 207, - WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG = 208, - WIFI_REASON_SA_QUERY_TIMEOUT = 209, - WIFI_REASON_NO_AP_FOUND_W_COMPATIBLE_SECURITY = 210, - WIFI_REASON_NO_AP_FOUND_IN_AUTHMODE_THRESHOLD = 211, - WIFI_REASON_NO_AP_FOUND_IN_RSSI_THRESHOLD = 212, -} wifi_err_reason_t; - -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; - -typedef enum { - WIFI_SCAN_TYPE_ACTIVE = 0, /**< active scan */ - WIFI_SCAN_TYPE_PASSIVE, /**< passive scan */ -} wifi_scan_type_t; - -/** @brief Range of active scan times per channel */ -typedef struct { - uint32_t min; /**< minimum active scan time per channel, units: millisecond */ - uint32_t max; /**< maximum active scan time per channel, units: millisecond, values above 1500ms may - cause station to disconnect from AP and are not recommended. */ -} wifi_active_scan_time_t; - -/** @brief Aggregate of active & passive scan time per channel */ -typedef struct { - wifi_active_scan_time_t active; /**< active scan time per channel, units: millisecond. */ - uint32_t passive; /**< passive scan time per channel, units: millisecond, values above 1500ms may - cause station to disconnect from AP and are not recommended. */ -} wifi_scan_time_t; - -/** @brief Parameters for an SSID scan. */ -typedef struct { - uint8_t *ssid; /**< SSID of AP */ - uint8_t *bssid; /**< MAC address of AP */ - uint8_t channel; /**< channel, scan the specific channel */ - bool show_hidden; /**< enable to scan AP whose SSID is hidden */ - wifi_scan_type_t scan_type; /**< scan type, active or passive */ - wifi_scan_time_t scan_time; /**< scan time per channel */ - uint8_t home_chan_dwell_time;/**< time spent at home channel between scanning consecutive channels.*/ -} wifi_scan_config_t; - -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 WiFi antenna - * - */ -typedef enum { - WIFI_ANT_ANT0, /**< WiFi antenna 0 */ - WIFI_ANT_ANT1, /**< WiFi antenna 1 */ - WIFI_ANT_MAX, /**< Invalid WiFi antenna */ -} wifi_ant_t; - -/** @brief Description of a WiFi AP HE Info */ -typedef struct { - uint8_t bss_color:6; /**< an unsigned integer whose value is the BSS Color of the BSS corresponding to the AP */ - uint8_t partial_bss_color:1; /**< indicate if an AID assignment rule based on the BSS color */ - uint8_t bss_color_disabled:1; /**< indicate if the use of BSS color is disabled */ - uint8_t bssid_index; /**< in M-BSSID set, identifies the nontransmitted BSSID */ -} wifi_he_ap_info_t; - -/** @brief Description of a WiFi 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; /**< authmode 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_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ - uint32_t wps:1; /**< bit: 5 flag to identify if WPS is supported or not */ - uint32_t ftm_responder:1; /**< bit: 6 flag to identify if FTM is supported in responder mode */ - uint32_t ftm_initiator:1; /**< bit: 7 flag to identify if FTM is supported in initiator mode */ - uint32_t reserved:24; /**< bit: 8..31 reserved */ - wifi_country_t country; /**< country information of AP */ - wifi_he_ap_info_t he_ap; /**< HE AP info */ -} wifi_ap_record_t; - -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; - -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 WiFi fast scan */ -typedef struct { - int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */ - wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode - 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 */ -}wifi_scan_threshold_t; - -typedef enum { - WIFI_PS_NONE, /**< No power save */ - WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. In this mode, station wakes up to receive beacon every DTIM period */ - 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 */ -} wifi_ps_type_t; - -#define WIFI_PROTOCOL_11B 1 -#define WIFI_PROTOCOL_11G 2 -#define WIFI_PROTOCOL_11N 4 -#define WIFI_PROTOCOL_LR 8 -#define WIFI_PROTOCOL_11AX 16 - -typedef enum { - WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */ - WIFI_BW_HT40, /* Bandwidth is HT40 */ -} wifi_bandwidth_t; - -/** Configuration structure for Protected Management Frame */ -typedef struct { - bool capable; /**< Deprecated variable. Device will always connect in PMF mode if other device also advertizes PMF capability. */ - bool required; /**< Advertizes that Protected Management Frame is required. Device will not associate to non-PMF capable devices. */ -} wifi_pmf_config_t; - -/** 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; - -/** 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 */ - 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 -/** @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 */ - uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */ - 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 incase 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 NAN Discovery start configuration - * - */ -typedef struct { - uint8_t op_channel; /**< NAN Discovery operating channel */ - uint8_t master_pref; /**< Device's preference value to serve as NAN Master */ - uint8_t scan_time; /**< Scan time in seconds while searching for a NAN cluster */ - uint16_t warm_up_sec; /**< Warm up time before assuming NAN Anchor Master role */ -} wifi_nan_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_nan_config_t nan; /**< configuration of NAN */ -} wifi_config_t; - -/** @brief Description of STA associated with AP */ -typedef struct { - uint8_t mac[6]; /**< mac address */ - int8_t rssi; /**< current average rssi of sta connected */ - 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_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ - uint32_t is_mesh_child:1;/**< bit: 5 flag to identify mesh child */ - uint32_t reserved:26; /**< bit: 6..31 reserved */ -} wifi_sta_info_t; - -typedef enum { - WIFI_STORAGE_FLASH, /**< all configuration will store in both memory and flash */ - WIFI_STORAGE_RAM, /**< all configuration will only store in the memory */ -} wifi_storage_t; - -/** - * @brief Vendor Information Element type - * - * Determines the frame type that the IE will be associated with. - */ -typedef enum { - WIFI_VND_IE_TYPE_BEACON, - WIFI_VND_IE_TYPE_PROBE_REQ, - WIFI_VND_IE_TYPE_PROBE_RESP, - WIFI_VND_IE_TYPE_ASSOC_REQ, - WIFI_VND_IE_TYPE_ASSOC_RESP, -} wifi_vendor_ie_type_t; - -/** - * @brief Vendor Information Element index - * - * Each IE type can have up to two associated vendor ID elements. - */ -typedef enum { - WIFI_VND_IE_ID_0, - WIFI_VND_IE_ID_1, -} wifi_vendor_ie_id_t; - -#define WIFI_VENDOR_IE_ELEMENT_ID 0xDD - -/** - * @brief Operation Phymode - */ -typedef enum -{ - WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */ - WIFI_PHY_MODE_11B, /**< PHY mode for 11b */ - WIFI_PHY_MODE_11G, /**< PHY mode for 11g */ - WIFI_PHY_MODE_HT20, /**< PHY mode for Bandwidth HT20 */ - WIFI_PHY_MODE_HT40, /**< PHY mode for Bandwidth HT40 */ - WIFI_PHY_MODE_HE20, /**< PHY mode for Bandwidth HE20 */ -} wifi_phy_mode_t; - -/** - * @brief Vendor Information Element header - * - * The first bytes of the Information Element will match this header. Payload follows. - */ -typedef struct { - uint8_t element_id; /**< Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */ - uint8_t length; /**< Length of all bytes in the element data following this field. Minimum 4. */ - uint8_t vendor_oui[3]; /**< Vendor identifier (OUI). */ - uint8_t vendor_oui_type; /**< Vendor-specific OUI type. */ - uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ -} vendor_ie_data_t; - -typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; - -/** - * @brief Promiscuous frame type - * - * Passed to promiscuous mode RX callback to indicate the type of parameter in the buffer. - * - */ -typedef enum { - WIFI_PKT_MGMT, /**< Management frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ - WIFI_PKT_CTRL, /**< Control frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ - WIFI_PKT_DATA, /**< Data frame, indiciates 'buf' argument is wifi_promiscuous_pkt_t */ - WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */ -} wifi_promiscuous_pkt_type_t; - - -#define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */ -#define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */ -#define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */ -#define WIFI_PROMIS_FILTER_MASK_DATA (1<<2) /**< filter the packets with type of WIFI_PKT_DATA */ -#define WIFI_PROMIS_FILTER_MASK_MISC (1<<3) /**< filter the packets with type of WIFI_PKT_MISC */ -#define WIFI_PROMIS_FILTER_MASK_DATA_MPDU (1<<4) /**< filter the MPDU which is a kind of WIFI_PKT_DATA */ -#define WIFI_PROMIS_FILTER_MASK_DATA_AMPDU (1<<5) /**< filter the AMPDU which is a kind of WIFI_PKT_DATA */ -#define WIFI_PROMIS_FILTER_MASK_FCSFAIL (1<<6) /**< filter the FCS failed packets, do not open it in general */ - -#define WIFI_PROMIS_CTRL_FILTER_MASK_ALL (0xFF800000) /**< filter all control packets */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER (1<<23) /**< filter the control packets with subtype of Control Wrapper */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_BAR (1<<24) /**< filter the control packets with subtype of Block Ack Request */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_BA (1<<25) /**< filter the control packets with subtype of Block Ack */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_PSPOLL (1<<26) /**< filter the control packets with subtype of PS-Poll */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_RTS (1<<27) /**< filter the control packets with subtype of RTS */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_CTS (1<<28) /**< filter the control packets with subtype of CTS */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_ACK (1<<29) /**< filter the control packets with subtype of ACK */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_CFEND (1<<30) /**< filter the control packets with subtype of CF-END */ -#define WIFI_PROMIS_CTRL_FILTER_MASK_CFENDACK (1<<31) /**< filter the control packets with subtype of CF-END+CF-ACK */ - -/** @brief Mask for filtering different packet types in promiscuous mode. */ -typedef struct { - uint32_t filter_mask; /**< OR of one or more filter values WIFI_PROMIS_FILTER_* */ -} wifi_promiscuous_filter_t; - -#define WIFI_EVENT_MASK_ALL (0xFFFFFFFF) /**< mask all WiFi events */ -#define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ -#define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ - -/** - * @brief Channel state information(CSI) configuration type - * - */ -typedef struct wifi_csi_config_t wifi_csi_config_t; - -/** - * @brief CSI data type - * - */ -typedef struct wifi_csi_info_t wifi_csi_info_t; - -/** - * @brief WiFi GPIO configuration for antenna selection - * - */ -typedef struct { - uint8_t gpio_select: 1, /**< Whether this GPIO is connected to external antenna switch */ - gpio_num: 7; /**< The GPIO number that connects to external antenna switch */ -} wifi_ant_gpio_t; - -/** - * @brief WiFi GPIOs configuration for antenna selection - * - */ -typedef struct { - wifi_ant_gpio_t gpio_cfg[4]; /**< The configurations of GPIOs that connect to external antenna switch */ -} wifi_ant_gpio_config_t; - -/** - * @brief WiFi antenna mode - * - */ -typedef enum { - WIFI_ANT_MODE_ANT0, /**< Enable WiFi antenna 0 only */ - WIFI_ANT_MODE_ANT1, /**< Enable WiFi antenna 1 only */ - WIFI_ANT_MODE_AUTO, /**< Enable WiFi antenna 0 and 1, automatically select an antenna */ - WIFI_ANT_MODE_MAX, /**< Invalid WiFi enabled antenna */ -} wifi_ant_mode_t; - -/** - * @brief WiFi antenna configuration - * - */ -typedef struct { - wifi_ant_mode_t rx_ant_mode; /**< WiFi antenna mode for receiving */ - wifi_ant_t rx_ant_default; /**< Default antenna mode for receiving, it's ignored if rx_ant_mode is not WIFI_ANT_MODE_AUTO */ - 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 */ - uint8_t enabled_ant0: 4, /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT0 */ - enabled_ant1: 4; /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT1 */ -} wifi_ant_config_t; - -/** - * @brief The Rx callback function of Action Tx operations - * - * @param hdr pointer to the IEEE 802.11 Header structure - * @param payload pointer to the Payload following 802.11 Header - * @param len length of the Payload - * @param channel channel number the frame is received on - * - */ -typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, - size_t len, uint8_t channel); -/** - * @brief Action Frame Tx Request - * - * - */ -typedef struct { - wifi_interface_t ifx; /**< WiFi interface to send request to */ - uint8_t dest_mac[6]; /**< Destination MAC address */ - bool no_ack; /**< Indicates no ack required */ - wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive any response */ - uint32_t data_len; /**< Length of the appended Data */ - uint8_t data[0]; /**< Appended Data payload */ -} wifi_action_tx_req_t; - -/** - * @brief FTM Initiator configuration - * - */ -typedef struct { - uint8_t resp_mac[6]; /**< MAC address of the FTM Responder */ - uint8_t channel; /**< Primary channel of the FTM Responder */ - 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) */ - uint16_t burst_period; /**< Requested time period between consecutive FTM bursts in 100's of milliseconds (0 - No pref) */ -} wifi_ftm_initiator_cfg_t; - -#define ESP_WIFI_NAN_MAX_SVC_SUPPORTED 2 -#define ESP_WIFI_NAN_DATAPATH_MAX_PEERS 2 - -#define ESP_WIFI_NDP_ROLE_INITIATOR 1 -#define ESP_WIFI_NDP_ROLE_RESPONDER 2 - -#define ESP_WIFI_MAX_SVC_NAME_LEN 256 -#define ESP_WIFI_MAX_FILTER_LEN 256 -#define ESP_WIFI_MAX_SVC_INFO_LEN 64 - -/** - * @brief NAN Services types - * - */ -typedef enum { - NAN_PUBLISH_SOLICITED, /**< Send unicast Publish frame to Subscribers that match the requirement */ - NAN_PUBLISH_UNSOLICITED,/**< Send broadcast Publish frames in every Discovery Window(DW) */ - NAN_SUBSCRIBE_ACTIVE, /**< Send broadcast Subscribe frames in every DW */ - NAN_SUBSCRIBE_PASSIVE, /**< Passively listens to Publish frames */ -} wifi_nan_service_type_t; - -/** - * @brief NAN Publish service configuration parameters - * - */ -typedef struct { - char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ - wifi_nan_service_type_t type; /**< Service type */ - char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ - char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Publish frame */ - uint8_t single_replied_event:1; /**< Give single Replied event or every time */ - uint8_t datapath_reqd:1; /**< NAN Datapath required for the service */ - uint8_t reserved:6; /**< Reserved */ -} wifi_nan_publish_cfg_t; - -/** - * @brief NAN Subscribe service configuration parameters - * - */ -typedef struct { - char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ - wifi_nan_service_type_t type; /**< Service type */ - char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ - char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Subscribe frame */ - uint8_t single_match_event:1; /**< Give single Match event or every time */ - uint8_t reserved:7; /**< Reserved */ -} wifi_nan_subscribe_cfg_t; - -/** - * @brief NAN Follow-up parameters - * - */ -typedef struct { - uint8_t inst_id; /**< Own service instance id */ - uint8_t peer_inst_id; /**< Peer's service instance id */ - uint8_t peer_mac[6]; /**< Peer's MAC address */ - char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service info(or message) to be shared */ -} wifi_nan_followup_params_t; - -/** - * @brief NAN Datapath Request parameters - * - */ -typedef struct { - uint8_t pub_id; /**< Publisher's service instance id */ - uint8_t peer_mac[6]; /**< Peer's MAC address */ - bool confirm_required; /**< NDP Confirm frame required */ -} wifi_nan_datapath_req_t; - -/** - * @brief NAN Datapath Response parameters - * - */ -typedef struct { - bool accept; /**< True - Accept incoming NDP, False - Reject it */ - uint8_t ndp_id; /**< NAN Datapath Identifier */ - uint8_t peer_mac[6]; /**< Peer's MAC address */ -} wifi_nan_datapath_resp_t; - -/** - * @brief NAN Datapath End parameters - * - */ -typedef struct { - uint8_t ndp_id; /**< NAN Datapath Identifier */ - uint8_t peer_mac[6]; /**< Peer's MAC address */ -} wifi_nan_datapath_end_req_t; - -/** - * @brief WiFi PHY rate encodings - * - */ -typedef enum { - WIFI_PHY_RATE_1M_L = 0x00, /**< 1 Mbps with long preamble */ - WIFI_PHY_RATE_2M_L = 0x01, /**< 2 Mbps with long preamble */ - WIFI_PHY_RATE_5M_L = 0x02, /**< 5.5 Mbps with long preamble */ - WIFI_PHY_RATE_11M_L = 0x03, /**< 11 Mbps with long preamble */ - WIFI_PHY_RATE_2M_S = 0x05, /**< 2 Mbps with short preamble */ - WIFI_PHY_RATE_5M_S = 0x06, /**< 5.5 Mbps with short preamble */ - WIFI_PHY_RATE_11M_S = 0x07, /**< 11 Mbps with short preamble */ - WIFI_PHY_RATE_48M = 0x08, /**< 48 Mbps */ - WIFI_PHY_RATE_24M = 0x09, /**< 24 Mbps */ - WIFI_PHY_RATE_12M = 0x0A, /**< 12 Mbps */ - WIFI_PHY_RATE_6M = 0x0B, /**< 6 Mbps */ - WIFI_PHY_RATE_54M = 0x0C, /**< 54 Mbps */ - WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */ - WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */ - WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */ - /**< rate table and guard interval information for each MCS rate*/ - /* - ----------------------------------------------------------------------------------------------------------- - MCS RATE | HT20 | HT40 | HE20 | - WIFI_PHY_RATE_MCS0_LGI | 6.5 Mbps (800ns) | 13.5 Mbps (800ns) | 8.1 Mbps (1600ns) | - WIFI_PHY_RATE_MCS1_LGI | 13 Mbps (800ns) | 27 Mbps (800ns) | 16.3 Mbps (1600ns) | - WIFI_PHY_RATE_MCS2_LGI | 19.5 Mbps (800ns) | 40.5 Mbps (800ns) | 24.4 Mbps (1600ns) | - WIFI_PHY_RATE_MCS3_LGI | 26 Mbps (800ns) | 54 Mbps (800ns) | 32.5 Mbps (1600ns) | - WIFI_PHY_RATE_MCS4_LGI | 39 Mbps (800ns) | 81 Mbps (800ns) | 48.8 Mbps (1600ns) | - WIFI_PHY_RATE_MCS5_LGI | 52 Mbps (800ns) | 108 Mbps (800ns) | 65 Mbps (1600ns) | - WIFI_PHY_RATE_MCS6_LGI | 58.5 Mbps (800ns) | 121.5 Mbps (800ns) | 73.1 Mbps (1600ns) | - WIFI_PHY_RATE_MCS7_LGI | 65 Mbps (800ns) | 135 Mbps (800ns) | 81.3 Mbps (1600ns) | - WIFI_PHY_RATE_MCS8_LGI | ----- | ----- | 97.5 Mbps (1600ns) | - WIFI_PHY_RATE_MCS9_LGI | ----- | ----- | 108.3 Mbps (1600ns) | - ----------------------------------------------------------------------------------------------------------- - */ - WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI */ - WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI */ - WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI */ - WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI */ - WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI */ - WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI */ - WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI */ - WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI */ -#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT - WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 with long GI */ - WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 with long GI */ -#endif - /* - ----------------------------------------------------------------------------------------------------------- - MCS RATE | HT20 | HT40 | HE20 | - WIFI_PHY_RATE_MCS0_SGI | 7.2 Mbps (400ns) | 15 Mbps (400ns) | 8.6 Mbps (800ns) | - WIFI_PHY_RATE_MCS1_SGI | 14.4 Mbps (400ns) | 30 Mbps (400ns) | 17.2 Mbps (800ns) | - WIFI_PHY_RATE_MCS2_SGI | 21.7 Mbps (400ns) | 45 Mbps (400ns) | 25.8 Mbps (800ns) | - WIFI_PHY_RATE_MCS3_SGI | 28.9 Mbps (400ns) | 60 Mbps (400ns) | 34.4 Mbps (800ns) | - WIFI_PHY_RATE_MCS4_SGI | 43.3 Mbps (400ns) | 90 Mbps (400ns) | 51.6 Mbps (800ns) | - WIFI_PHY_RATE_MCS5_SGI | 57.8 Mbps (400ns) | 120 Mbps (400ns) | 68.8 Mbps (800ns) | - WIFI_PHY_RATE_MCS6_SGI | 65 Mbps (400ns) | 135 Mbps (400ns) | 77.4 Mbps (800ns) | - WIFI_PHY_RATE_MCS7_SGI | 72.2 Mbps (400ns) | 150 Mbps (400ns) | 86 Mbps (800ns) | - WIFI_PHY_RATE_MCS8_SGI | ----- | ----- | 103.2 Mbps (800ns) | - WIFI_PHY_RATE_MCS9_SGI | ----- | ----- | 114.7 Mbps (800ns) | - ----------------------------------------------------------------------------------------------------------- - */ - WIFI_PHY_RATE_MCS0_SGI, /**< MCS0 with short GI */ - WIFI_PHY_RATE_MCS1_SGI, /**< MCS1 with short GI */ - WIFI_PHY_RATE_MCS2_SGI, /**< MCS2 with short GI */ - WIFI_PHY_RATE_MCS3_SGI, /**< MCS3 with short GI */ - WIFI_PHY_RATE_MCS4_SGI, /**< MCS4 with short GI */ - WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI */ - WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI */ - WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI */ -#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT - WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 with short GI */ - WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 with short GI */ -#endif - WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */ - WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */ - WIFI_PHY_RATE_MAX, -} wifi_phy_rate_t; - -/** WiFi event declarations */ -typedef enum { - WIFI_EVENT_WIFI_READY = 0, /**< WiFi ready */ - WIFI_EVENT_SCAN_DONE, /**< Finished scanning AP */ - WIFI_EVENT_STA_START, /**< Station start */ - WIFI_EVENT_STA_STOP, /**< Station stop */ - WIFI_EVENT_STA_CONNECTED, /**< Station connected to AP */ - WIFI_EVENT_STA_DISCONNECTED, /**< Station disconnected from AP */ - WIFI_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by device's station changed */ - - WIFI_EVENT_STA_WPS_ER_SUCCESS, /**< Station wps succeeds in enrollee mode */ - WIFI_EVENT_STA_WPS_ER_FAILED, /**< Station wps fails in enrollee mode */ - WIFI_EVENT_STA_WPS_ER_TIMEOUT, /**< Station wps timeout in enrollee mode */ - WIFI_EVENT_STA_WPS_ER_PIN, /**< Station wps pin code in enrollee mode */ - WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, /**< Station wps overlap in enrollee mode */ - - WIFI_EVENT_AP_START, /**< Soft-AP start */ - WIFI_EVENT_AP_STOP, /**< Soft-AP stop */ - WIFI_EVENT_AP_STACONNECTED, /**< a station connected to Soft-AP */ - WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from Soft-AP */ - WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */ - - WIFI_EVENT_FTM_REPORT, /**< Receive report of FTM procedure */ - - /* Add next events after this only */ - WIFI_EVENT_STA_BSS_RSSI_LOW, /**< AP's RSSI crossed configured threshold */ - WIFI_EVENT_ACTION_TX_STATUS, /**< Status indication of Action Tx operation */ - WIFI_EVENT_ROC_DONE, /**< Remain-on-Channel operation complete */ - - WIFI_EVENT_STA_BEACON_TIMEOUT, /**< Station beacon timeout */ - - WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START, /**< Connectionless module wake interval start */ - - WIFI_EVENT_AP_WPS_RG_SUCCESS, /**< Soft-AP wps succeeds in registrar mode */ - WIFI_EVENT_AP_WPS_RG_FAILED, /**< Soft-AP wps fails in registrar mode */ - WIFI_EVENT_AP_WPS_RG_TIMEOUT, /**< Soft-AP wps timeout in registrar mode */ - WIFI_EVENT_AP_WPS_RG_PIN, /**< Soft-AP wps pin code in registrar mode */ - WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP, /**< Soft-AP wps overlap in registrar mode */ - - WIFI_EVENT_ITWT_SETUP, /**< iTWT setup */ - WIFI_EVENT_ITWT_TEARDOWN, /**< iTWT teardown */ - WIFI_EVENT_ITWT_PROBE, /**< iTWT probe */ - WIFI_EVENT_ITWT_SUSPEND, /**< iTWT suspend */ - - WIFI_EVENT_NAN_STARTED, /**< NAN Discovery has started */ - WIFI_EVENT_NAN_STOPPED, /**< NAN Discovery has stopped */ - WIFI_EVENT_NAN_SVC_MATCH, /**< NAN Service Discovery match found */ - WIFI_EVENT_NAN_REPLIED, /**< Replied to a NAN peer with Service Discovery match */ - WIFI_EVENT_NAN_RECEIVE, /**< Received a Follow-up message */ - WIFI_EVENT_NDP_INDICATION, /**< Received NDP Request from a NAN Peer */ - WIFI_EVENT_NDP_CONFIRM, /**< NDP Confirm Indication */ - WIFI_EVENT_NDP_TERMINATED, /**< NAN Datapath terminated indication */ - WIFI_EVENT_HOME_CHANNEL_CHANGE, /**< WiFi home channel change,doesn't occur when scanning */ - - WIFI_EVENT_MAX, /**< Invalid WiFi event ID */ -} wifi_event_t; - -/** @cond **/ -/** @brief WiFi event base declaration */ -ESP_EVENT_DECLARE_BASE(WIFI_EVENT); -/** @endcond **/ - -/** Argument structure for WIFI_EVENT_SCAN_DONE event */ -typedef struct { - uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ - uint8_t number; /**< number of scan results */ - uint8_t scan_id; /**< scan sequence number, used for block scan */ -} wifi_event_sta_scan_done_t; - -/** Argument structure for WIFI_EVENT_STA_CONNECTED event */ -typedef struct { - uint8_t ssid[32]; /**< SSID of connected AP */ - uint8_t ssid_len; /**< SSID length of connected AP */ - uint8_t bssid[6]; /**< BSSID of connected AP*/ - uint8_t channel; /**< channel of connected AP*/ - wifi_auth_mode_t authmode;/**< authentication mode used by AP*/ - uint16_t aid; /**< authentication id assigned by the connected AP */ -} wifi_event_sta_connected_t; - -/** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */ -typedef struct { - uint8_t ssid[32]; /**< SSID of disconnected AP */ - uint8_t ssid_len; /**< SSID length of disconnected AP */ - uint8_t bssid[6]; /**< BSSID of disconnected AP */ - uint8_t reason; /**< reason of disconnection */ - int8_t rssi; /**< rssi of disconnection */ -} wifi_event_sta_disconnected_t; - -/** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */ -typedef struct { - wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ - wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ -} wifi_event_sta_authmode_change_t; - -/** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */ -typedef struct { - uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ -} wifi_event_sta_wps_er_pin_t; - -/** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */ -typedef enum { - WPS_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ - WPS_FAIL_REASON_RECV_M2D, /**< WPS receive M2D frame */ - WPS_FAIL_REASON_MAX -} wifi_event_sta_wps_fail_reason_t; - -#define MAX_SSID_LEN 32 -#define MAX_PASSPHRASE_LEN 64 -#define MAX_WPS_AP_CRED 3 - -/** Argument structure for WIFI_EVENT_STA_WPS_ER_SUCCESS event */ -typedef struct { - uint8_t ap_cred_cnt; /**< Number of AP credentials received */ - struct { - uint8_t ssid[MAX_SSID_LEN]; /**< SSID of AP */ - uint8_t passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase for the AP */ - } ap_cred[MAX_WPS_AP_CRED]; /**< All AP credentials received from WPS handshake */ -} wifi_event_sta_wps_er_success_t; - -/** Argument structure for WIFI_EVENT_AP_STACONNECTED event */ -typedef struct { - uint8_t mac[6]; /**< MAC address of the station connected to Soft-AP */ - uint8_t aid; /**< the aid that soft-AP gives to the station connected to */ - bool is_mesh_child; /**< flag to identify mesh child */ -} wifi_event_ap_staconnected_t; - -/** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ -typedef struct { - uint8_t mac[6]; /**< MAC address of the station disconnects to soft-AP */ - uint8_t aid; /**< the aid that soft-AP gave to the station disconnects to */ - bool is_mesh_child; /**< flag to identify mesh child */ - uint8_t reason; /**< reason of disconnection */ -} wifi_event_ap_stadisconnected_t; - -/** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ -typedef struct { - int rssi; /**< Received probe request signal strength */ - uint8_t mac[6]; /**< MAC address of the station which send probe request */ -} wifi_event_ap_probe_req_rx_t; - -/** Argument structure for WIFI_EVENT_STA_BSS_RSSI_LOW event */ -typedef struct { - int32_t rssi; /**< RSSI value of bss */ -} wifi_event_bss_rssi_low_t; - -/** Argument structure for WIFI_EVENT_HOME_CHANNEL_CHANGE event */ -typedef struct { - uint8_t old_chan; /**< old home channel of the device */ - wifi_second_chan_t old_snd; /**< old second channel of the device */ - uint8_t new_chan; /**< new home channel of the device */ - wifi_second_chan_t new_snd; /**< new second channel of the device */ -} wifi_event_home_channel_change_t; - -/** - * @brief FTM operation status types - * - */ -typedef enum { - FTM_STATUS_SUCCESS = 0, /**< FTM exchange is successful */ - FTM_STATUS_UNSUPPORTED, /**< Peer does not support FTM */ - FTM_STATUS_CONF_REJECTED, /**< Peer rejected FTM configuration in FTM Request */ - FTM_STATUS_NO_RESPONSE, /**< Peer did not respond to FTM Requests */ - FTM_STATUS_FAIL, /**< Unknown error during FTM exchange */ -} wifi_ftm_status_t; - -/** Argument structure for */ -typedef struct { - uint8_t dlog_token; /**< Dialog Token of the FTM frame */ - int8_t rssi; /**< RSSI of the FTM frame received */ - uint32_t rtt; /**< Round Trip Time in pSec with a peer */ - uint64_t t1; /**< Time of departure of FTM frame from FTM Responder in pSec */ - uint64_t t2; /**< Time of arrival of FTM frame at FTM Initiator in pSec */ - uint64_t t3; /**< Time of departure of ACK from FTM Initiator in pSec */ - uint64_t t4; /**< Time of arrival of ACK at FTM Responder in pSec */ -} wifi_ftm_report_entry_t; - -/** Argument structure for WIFI_EVENT_FTM_REPORT event */ -typedef struct { - uint8_t peer_mac[6]; /**< MAC address of the FTM Peer */ - wifi_ftm_status_t status; /**< Status of the FTM operation */ - uint32_t rtt_raw; /**< Raw average Round-Trip-Time with peer in Nano-Seconds */ - uint32_t rtt_est; /**< Estimated Round-Trip-Time with peer in Nano-Seconds */ - uint32_t dist_est; /**< Estimated one-way distance in Centi-Meters */ - wifi_ftm_report_entry_t *ftm_report_data; /**< Pointer to FTM Report with multiple entries, should be freed after use */ - uint8_t ftm_report_num_entries; /**< Number of entries in the FTM Report data */ -} wifi_event_ftm_report_t; - -#define WIFI_STATIS_BUFFER (1<<0) -#define WIFI_STATIS_RXTX (1<<1) -#define WIFI_STATIS_HW (1<<2) -#define WIFI_STATIS_DIAG (1<<3) -#define WIFI_STATIS_PS (1<<4) -#define WIFI_STATIS_ALL (-1) - -/** Argument structure for WIFI_EVENT_ACTION_TX_STATUS event */ -typedef struct { - wifi_interface_t ifx; /**< WiFi interface to send request to */ - uint32_t context; /**< Context to identify the request */ - uint8_t da[6]; /**< Destination MAC address */ - uint8_t status; /**< Status of the operation */ -} wifi_event_action_tx_status_t; - -/** Argument structure for WIFI_EVENT_ROC_DONE event */ -typedef struct { - uint32_t context; /**< Context to identify the request */ -} wifi_event_roc_done_t; - -/** Argument structure for WIFI_EVENT_AP_WPS_RG_PIN event */ -typedef struct { - uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ -} wifi_event_ap_wps_rg_pin_t; - -typedef enum { - WPS_AP_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ - WPS_AP_FAIL_REASON_CONFIG, /**< WPS failed due to incorrect config */ - WPS_AP_FAIL_REASON_AUTH, /**< WPS failed during auth */ - WPS_AP_FAIL_REASON_MAX, -} wps_fail_reason_t; - -/** Argument structure for WIFI_EVENT_AP_WPS_RG_FAILED event */ -typedef struct { - wps_fail_reason_t reason; /**< WPS failure reason wps_fail_reason_t */ - uint8_t peer_macaddr[6]; /**< Enrollee mac address */ -} wifi_event_ap_wps_rg_fail_reason_t; - -/** Argument structure for WIFI_EVENT_AP_WPS_RG_SUCCESS event */ -typedef struct { - uint8_t peer_macaddr[6]; /**< Enrollee mac address */ -} wifi_event_ap_wps_rg_success_t; - -/** Argument structure for WIFI_EVENT_NAN_SVC_MATCH event */ -typedef struct { - uint8_t subscribe_id; /**< Subscribe Service Identifier */ - uint8_t publish_id; /**< Publish Service Identifier */ - uint8_t pub_if_mac[6]; /**< NAN Interface MAC of the Publisher */ - bool update_pub_id; /**< Indicates whether publisher's service ID needs to be updated */ -} wifi_event_nan_svc_match_t; - -/** Argument structure for WIFI_EVENT_NAN_REPLIED event */ -typedef struct { - uint8_t publish_id; /**< Publish Service Identifier */ - uint8_t subscribe_id; /**< Subscribe Service Identifier */ - uint8_t sub_if_mac[6]; /**< NAN Interface MAC of the Subscriber */ -} wifi_event_nan_replied_t; - -/** Argument structure for WIFI_EVENT_NAN_RECEIVE event */ -typedef struct { - uint8_t inst_id; /**< Our Service Identifier */ - uint8_t peer_inst_id; /**< Peer's Service Identifier */ - uint8_t peer_if_mac[6]; /**< Peer's NAN Interface MAC */ - uint8_t peer_svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Peer Service Info */ -} wifi_event_nan_receive_t; - -/** Argument structure for WIFI_EVENT_NDP_INDICATION event */ -typedef struct { - uint8_t publish_id; /**< Publish Id for NAN Service */ - uint8_t ndp_id; /**< NDP instance id */ - uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ - uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ - uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ -} wifi_event_ndp_indication_t; - -/** Argument structure for WIFI_EVENT_NDP_CONFIRM event */ -typedef struct { - uint8_t status; /**< NDP status code */ - uint8_t ndp_id; /**< NDP instance id */ - uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ - uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ - uint8_t own_ndi[6]; /**< Own NAN Data Interface MAC */ - uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ -} wifi_event_ndp_confirm_t; - -/** Argument structure for WIFI_EVENT_NDP_TERMINATED event */ -typedef struct { - uint8_t reason; /**< Termination reason code */ - uint8_t ndp_id; /**< NDP instance id */ - uint8_t init_ndi[6]; /**< Initiator's NAN Data Interface MAC */ -} wifi_event_ndp_terminated_t; - -#ifdef __cplusplus -} -#endif - -#endif /* __ESP_WIFI_TYPES_H__ */ diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h new file mode 100644 index 0000000000..e523f94619 --- /dev/null +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -0,0 +1,1017 @@ +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +#ifndef __ESP_WIFI_TYPES_H__ +#define __ESP_WIFI_TYPES_H__ + +#include "esp_event.h" +#include "esp_interface.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + WIFI_MODE_NULL = 0, /**< null mode */ + WIFI_MODE_STA, /**< WiFi station mode */ + WIFI_MODE_AP, /**< WiFi soft-AP mode */ + WIFI_MODE_APSTA, /**< WiFi station + soft-AP mode */ + WIFI_MODE_NAN, /**< WiFi NAN mode */ + WIFI_MODE_MAX +} wifi_mode_t; + +typedef enum { + WIFI_IF_STA = ESP_IF_WIFI_STA, + WIFI_IF_AP = ESP_IF_WIFI_AP, +#if CONFIG_SOC_WIFI_NAN_SUPPORT || !CONFIG_SOC_WIFI_ENABLED + WIFI_IF_NAN = ESP_IF_WIFI_NAN, +#endif + WIFI_IF_MAX +} wifi_interface_t; + +#define WIFI_OFFCHAN_TX_REQ 1 +#define WIFI_OFFCHAN_TX_CANCEL 0 + +#define WIFI_ROC_REQ 1 +#define WIFI_ROC_CANCEL 0 + +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 WiFi country-based regional restrictions. */ +typedef struct { + char cc[3]; /**< country code string */ + uint8_t schan; /**< start channel */ + uint8_t nchan; /**< total channel number */ + 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. */ + wifi_country_policy_t policy; /**< country policy */ +} wifi_country_t; + +/* Strength of authmodes */ +/* OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA3_PSK = WPA2_WPA3_PSK < WPA3_EXT_PSK = WPA3_EXT_PSK_MIXED_MODE */ +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 : WiFi EAP security */ + WIFI_AUTH_WPA2_ENTERPRISE = WIFI_AUTH_ENTERPRISE, /**< authenticate mode : WiFi 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, /**< authenticate mode : WPA3_PSK_EXT_KEY */ + WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE, /**< authenticate mode: WPA3_PSK + WPA3_PSK_EXT_KEY */ + WIFI_AUTH_MAX +} wifi_auth_mode_t; + +typedef enum { + WIFI_REASON_UNSPECIFIED = 1, + WIFI_REASON_AUTH_EXPIRE = 2, + WIFI_REASON_AUTH_LEAVE = 3, + WIFI_REASON_ASSOC_EXPIRE = 4, + WIFI_REASON_ASSOC_TOOMANY = 5, + WIFI_REASON_NOT_AUTHED = 6, + WIFI_REASON_NOT_ASSOCED = 7, + WIFI_REASON_ASSOC_LEAVE = 8, + WIFI_REASON_ASSOC_NOT_AUTHED = 9, + WIFI_REASON_DISASSOC_PWRCAP_BAD = 10, + WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11, + WIFI_REASON_BSS_TRANSITION_DISASSOC = 12, + WIFI_REASON_IE_INVALID = 13, + WIFI_REASON_MIC_FAILURE = 14, + WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, + WIFI_REASON_IE_IN_4WAY_DIFFERS = 17, + WIFI_REASON_GROUP_CIPHER_INVALID = 18, + WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19, + WIFI_REASON_AKMP_INVALID = 20, + WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21, + WIFI_REASON_INVALID_RSN_IE_CAP = 22, + WIFI_REASON_802_1X_AUTH_FAILED = 23, + WIFI_REASON_CIPHER_SUITE_REJECTED = 24, + WIFI_REASON_TDLS_PEER_UNREACHABLE = 25, + WIFI_REASON_TDLS_UNSPECIFIED = 26, + WIFI_REASON_SSP_REQUESTED_DISASSOC = 27, + WIFI_REASON_NO_SSP_ROAMING_AGREEMENT = 28, + WIFI_REASON_BAD_CIPHER_OR_AKM = 29, + WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30, + WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS = 31, + WIFI_REASON_UNSPECIFIED_QOS = 32, + WIFI_REASON_NOT_ENOUGH_BANDWIDTH = 33, + WIFI_REASON_MISSING_ACKS = 34, + WIFI_REASON_EXCEEDED_TXOP = 35, + WIFI_REASON_STA_LEAVING = 36, + WIFI_REASON_END_BA = 37, + WIFI_REASON_UNKNOWN_BA = 38, + WIFI_REASON_TIMEOUT = 39, + WIFI_REASON_PEER_INITIATED = 46, + WIFI_REASON_AP_INITIATED = 47, + WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48, + WIFI_REASON_INVALID_PMKID = 49, + WIFI_REASON_INVALID_MDE = 50, + WIFI_REASON_INVALID_FTE = 51, + WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED = 67, + WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED = 68, + + WIFI_REASON_BEACON_TIMEOUT = 200, + WIFI_REASON_NO_AP_FOUND = 201, + WIFI_REASON_AUTH_FAIL = 202, + WIFI_REASON_ASSOC_FAIL = 203, + WIFI_REASON_HANDSHAKE_TIMEOUT = 204, + WIFI_REASON_CONNECTION_FAIL = 205, + WIFI_REASON_AP_TSF_RESET = 206, + WIFI_REASON_ROAMING = 207, + WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG = 208, + WIFI_REASON_SA_QUERY_TIMEOUT = 209, + WIFI_REASON_NO_AP_FOUND_W_COMPATIBLE_SECURITY = 210, + WIFI_REASON_NO_AP_FOUND_IN_AUTHMODE_THRESHOLD = 211, + WIFI_REASON_NO_AP_FOUND_IN_RSSI_THRESHOLD = 212, +} wifi_err_reason_t; + +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; + +typedef enum { + WIFI_SCAN_TYPE_ACTIVE = 0, /**< active scan */ + WIFI_SCAN_TYPE_PASSIVE, /**< passive scan */ +} wifi_scan_type_t; + +/** @brief Range of active scan times per channel */ +typedef struct { + uint32_t min; /**< minimum active scan time per channel, units: millisecond */ + uint32_t max; /**< maximum active scan time per channel, units: millisecond, values above 1500ms may + cause station to disconnect from AP and are not recommended. */ +} wifi_active_scan_time_t; + +/** @brief Aggregate of active & passive scan time per channel */ +typedef struct { + wifi_active_scan_time_t active; /**< active scan time per channel, units: millisecond. */ + uint32_t passive; /**< passive scan time per channel, units: millisecond, values above 1500ms may + cause station to disconnect from AP and are not recommended. */ +} wifi_scan_time_t; + +/** @brief Parameters for an SSID scan. */ +typedef struct { + uint8_t *ssid; /**< SSID of AP */ + uint8_t *bssid; /**< MAC address of AP */ + uint8_t channel; /**< channel, scan the specific channel */ + bool show_hidden; /**< enable to scan AP whose SSID is hidden */ + wifi_scan_type_t scan_type; /**< scan type, active or passive */ + wifi_scan_time_t scan_time; /**< scan time per channel */ + uint8_t home_chan_dwell_time;/**< time spent at home channel between scanning consecutive channels.*/ +} wifi_scan_config_t; + +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 WiFi antenna + * + */ +typedef enum { + WIFI_ANT_ANT0, /**< WiFi antenna 0 */ + WIFI_ANT_ANT1, /**< WiFi antenna 1 */ + WIFI_ANT_MAX, /**< Invalid WiFi antenna */ +} wifi_ant_t; + +/** @brief Description of a WiFi AP HE Info */ +typedef struct { + uint8_t bss_color:6; /**< an unsigned integer whose value is the BSS Color of the BSS corresponding to the AP */ + uint8_t partial_bss_color:1; /**< indicate if an AID assignment rule based on the BSS color */ + uint8_t bss_color_disabled:1; /**< indicate if the use of BSS color is disabled */ + uint8_t bssid_index; /**< in M-BSSID set, identifies the nontransmitted BSSID */ +} wifi_he_ap_info_t; + +/** @brief Description of a WiFi 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; /**< authmode 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_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ + uint32_t wps:1; /**< bit: 5 flag to identify if WPS is supported or not */ + uint32_t ftm_responder:1; /**< bit: 6 flag to identify if FTM is supported in responder mode */ + uint32_t ftm_initiator:1; /**< bit: 7 flag to identify if FTM is supported in initiator mode */ + uint32_t reserved:24; /**< bit: 8..31 reserved */ + wifi_country_t country; /**< country information of AP */ + wifi_he_ap_info_t he_ap; /**< HE AP info */ +} wifi_ap_record_t; + +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; + +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 WiFi fast scan */ +typedef struct { + int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */ + wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode + 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 */ +}wifi_scan_threshold_t; + +typedef enum { + WIFI_PS_NONE, /**< No power save */ + WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. In this mode, station wakes up to receive beacon every DTIM period */ + 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 */ +} wifi_ps_type_t; + +#define WIFI_PROTOCOL_11B 1 +#define WIFI_PROTOCOL_11G 2 +#define WIFI_PROTOCOL_11N 4 +#define WIFI_PROTOCOL_LR 8 +#define WIFI_PROTOCOL_11AX 16 + +typedef enum { + WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */ + WIFI_BW_HT40, /* Bandwidth is HT40 */ +} wifi_bandwidth_t; + +/** Configuration structure for Protected Management Frame */ +typedef struct { + bool capable; /**< Deprecated variable. Device will always connect in PMF mode if other device also advertizes PMF capability. */ + bool required; /**< Advertizes that Protected Management Frame is required. Device will not associate to non-PMF capable devices. */ +} wifi_pmf_config_t; + +/** 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; + +/** 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 */ + 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 +/** @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 */ + uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */ + 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 incase 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 NAN Discovery start configuration + * + */ +typedef struct { + uint8_t op_channel; /**< NAN Discovery operating channel */ + uint8_t master_pref; /**< Device's preference value to serve as NAN Master */ + uint8_t scan_time; /**< Scan time in seconds while searching for a NAN cluster */ + uint16_t warm_up_sec; /**< Warm up time before assuming NAN Anchor Master role */ +} wifi_nan_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_nan_config_t nan; /**< configuration of NAN */ +} wifi_config_t; + +/** @brief Description of STA associated with AP */ +typedef struct { + uint8_t mac[6]; /**< mac address */ + int8_t rssi; /**< current average rssi of sta connected */ + 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_11ax:1; /**< bit: 4 flag to identify if 11ax mode is enabled or not */ + uint32_t is_mesh_child:1;/**< bit: 5 flag to identify mesh child */ + uint32_t reserved:26; /**< bit: 6..31 reserved */ +} wifi_sta_info_t; + +typedef enum { + WIFI_STORAGE_FLASH, /**< all configuration will store in both memory and flash */ + WIFI_STORAGE_RAM, /**< all configuration will only store in the memory */ +} wifi_storage_t; + +/** + * @brief Vendor Information Element type + * + * Determines the frame type that the IE will be associated with. + */ +typedef enum { + WIFI_VND_IE_TYPE_BEACON, + WIFI_VND_IE_TYPE_PROBE_REQ, + WIFI_VND_IE_TYPE_PROBE_RESP, + WIFI_VND_IE_TYPE_ASSOC_REQ, + WIFI_VND_IE_TYPE_ASSOC_RESP, +} wifi_vendor_ie_type_t; + +/** + * @brief Vendor Information Element index + * + * Each IE type can have up to two associated vendor ID elements. + */ +typedef enum { + WIFI_VND_IE_ID_0, + WIFI_VND_IE_ID_1, +} wifi_vendor_ie_id_t; + +#define WIFI_VENDOR_IE_ELEMENT_ID 0xDD + +/** + * @brief Operation Phymode + */ +typedef enum +{ + WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */ + WIFI_PHY_MODE_11B, /**< PHY mode for 11b */ + WIFI_PHY_MODE_11G, /**< PHY mode for 11g */ + WIFI_PHY_MODE_HT20, /**< PHY mode for Bandwidth HT20 */ + WIFI_PHY_MODE_HT40, /**< PHY mode for Bandwidth HT40 */ + WIFI_PHY_MODE_HE20, /**< PHY mode for Bandwidth HE20 */ +} wifi_phy_mode_t; + +/** + * @brief Vendor Information Element header + * + * The first bytes of the Information Element will match this header. Payload follows. + */ +typedef struct { + uint8_t element_id; /**< Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */ + uint8_t length; /**< Length of all bytes in the element data following this field. Minimum 4. */ + uint8_t vendor_oui[3]; /**< Vendor identifier (OUI). */ + uint8_t vendor_oui_type; /**< Vendor-specific OUI type. */ + uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ +} vendor_ie_data_t; + +typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; + +/** + * @brief Promiscuous frame type + * + * Passed to promiscuous mode RX callback to indicate the type of parameter in the buffer. + * + */ +typedef enum { + WIFI_PKT_MGMT, /**< Management frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ + WIFI_PKT_CTRL, /**< Control frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */ + WIFI_PKT_DATA, /**< Data frame, indiciates 'buf' argument is wifi_promiscuous_pkt_t */ + WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */ +} wifi_promiscuous_pkt_type_t; + + +#define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */ +#define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */ +#define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */ +#define WIFI_PROMIS_FILTER_MASK_DATA (1<<2) /**< filter the packets with type of WIFI_PKT_DATA */ +#define WIFI_PROMIS_FILTER_MASK_MISC (1<<3) /**< filter the packets with type of WIFI_PKT_MISC */ +#define WIFI_PROMIS_FILTER_MASK_DATA_MPDU (1<<4) /**< filter the MPDU which is a kind of WIFI_PKT_DATA */ +#define WIFI_PROMIS_FILTER_MASK_DATA_AMPDU (1<<5) /**< filter the AMPDU which is a kind of WIFI_PKT_DATA */ +#define WIFI_PROMIS_FILTER_MASK_FCSFAIL (1<<6) /**< filter the FCS failed packets, do not open it in general */ + +#define WIFI_PROMIS_CTRL_FILTER_MASK_ALL (0xFF800000) /**< filter all control packets */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER (1<<23) /**< filter the control packets with subtype of Control Wrapper */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_BAR (1<<24) /**< filter the control packets with subtype of Block Ack Request */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_BA (1<<25) /**< filter the control packets with subtype of Block Ack */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_PSPOLL (1<<26) /**< filter the control packets with subtype of PS-Poll */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_RTS (1<<27) /**< filter the control packets with subtype of RTS */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_CTS (1<<28) /**< filter the control packets with subtype of CTS */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_ACK (1<<29) /**< filter the control packets with subtype of ACK */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_CFEND (1<<30) /**< filter the control packets with subtype of CF-END */ +#define WIFI_PROMIS_CTRL_FILTER_MASK_CFENDACK (1<<31) /**< filter the control packets with subtype of CF-END+CF-ACK */ + +/** @brief Mask for filtering different packet types in promiscuous mode. */ +typedef struct { + uint32_t filter_mask; /**< OR of one or more filter values WIFI_PROMIS_FILTER_* */ +} wifi_promiscuous_filter_t; + +#define WIFI_EVENT_MASK_ALL (0xFFFFFFFF) /**< mask all WiFi events */ +#define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ +#define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ + +/** + * @brief Channel state information(CSI) configuration type + * + */ +typedef struct wifi_csi_config_t wifi_csi_config_t; + +/** + * @brief CSI data type + * + */ +typedef struct wifi_csi_info_t wifi_csi_info_t; + +/** + * @brief WiFi GPIO configuration for antenna selection + * + */ +typedef struct { + uint8_t gpio_select: 1, /**< Whether this GPIO is connected to external antenna switch */ + gpio_num: 7; /**< The GPIO number that connects to external antenna switch */ +} wifi_ant_gpio_t; + +/** + * @brief WiFi GPIOs configuration for antenna selection + * + */ +typedef struct { + wifi_ant_gpio_t gpio_cfg[4]; /**< The configurations of GPIOs that connect to external antenna switch */ +} wifi_ant_gpio_config_t; + +/** + * @brief WiFi antenna mode + * + */ +typedef enum { + WIFI_ANT_MODE_ANT0, /**< Enable WiFi antenna 0 only */ + WIFI_ANT_MODE_ANT1, /**< Enable WiFi antenna 1 only */ + WIFI_ANT_MODE_AUTO, /**< Enable WiFi antenna 0 and 1, automatically select an antenna */ + WIFI_ANT_MODE_MAX, /**< Invalid WiFi enabled antenna */ +} wifi_ant_mode_t; + +/** + * @brief WiFi antenna configuration + * + */ +typedef struct { + wifi_ant_mode_t rx_ant_mode; /**< WiFi antenna mode for receiving */ + wifi_ant_t rx_ant_default; /**< Default antenna mode for receiving, it's ignored if rx_ant_mode is not WIFI_ANT_MODE_AUTO */ + 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 */ + uint8_t enabled_ant0: 4, /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT0 */ + enabled_ant1: 4; /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT1 */ +} wifi_ant_config_t; + +/** + * @brief The Rx callback function of Action Tx operations + * + * @param hdr pointer to the IEEE 802.11 Header structure + * @param payload pointer to the Payload following 802.11 Header + * @param len length of the Payload + * @param channel channel number the frame is received on + * + */ +typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, + size_t len, uint8_t channel); +/** + * @brief Action Frame Tx Request + * + * + */ +typedef struct { + wifi_interface_t ifx; /**< WiFi interface to send request to */ + uint8_t dest_mac[6]; /**< Destination MAC address */ + bool no_ack; /**< Indicates no ack required */ + wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive any response */ + uint32_t data_len; /**< Length of the appended Data */ + uint8_t data[0]; /**< Appended Data payload */ +} wifi_action_tx_req_t; + +/** + * @brief FTM Initiator configuration + * + */ +typedef struct { + uint8_t resp_mac[6]; /**< MAC address of the FTM Responder */ + uint8_t channel; /**< Primary channel of the FTM Responder */ + 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) */ + uint16_t burst_period; /**< Requested time period between consecutive FTM bursts in 100's of milliseconds (0 - No pref) */ +} wifi_ftm_initiator_cfg_t; + +#define ESP_WIFI_NAN_MAX_SVC_SUPPORTED 2 +#define ESP_WIFI_NAN_DATAPATH_MAX_PEERS 2 + +#define ESP_WIFI_NDP_ROLE_INITIATOR 1 +#define ESP_WIFI_NDP_ROLE_RESPONDER 2 + +#define ESP_WIFI_MAX_SVC_NAME_LEN 256 +#define ESP_WIFI_MAX_FILTER_LEN 256 +#define ESP_WIFI_MAX_SVC_INFO_LEN 64 + +/** + * @brief NAN Services types + * + */ +typedef enum { + NAN_PUBLISH_SOLICITED, /**< Send unicast Publish frame to Subscribers that match the requirement */ + NAN_PUBLISH_UNSOLICITED,/**< Send broadcast Publish frames in every Discovery Window(DW) */ + NAN_SUBSCRIBE_ACTIVE, /**< Send broadcast Subscribe frames in every DW */ + NAN_SUBSCRIBE_PASSIVE, /**< Passively listens to Publish frames */ +} wifi_nan_service_type_t; + +/** + * @brief NAN Publish service configuration parameters + * + */ +typedef struct { + char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ + wifi_nan_service_type_t type; /**< Service type */ + char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ + char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Publish frame */ + uint8_t single_replied_event:1; /**< Give single Replied event or every time */ + uint8_t datapath_reqd:1; /**< NAN Datapath required for the service */ + uint8_t reserved:6; /**< Reserved */ +} wifi_nan_publish_cfg_t; + +/** + * @brief NAN Subscribe service configuration parameters + * + */ +typedef struct { + char service_name[ESP_WIFI_MAX_SVC_NAME_LEN]; /**< Service name identifier */ + wifi_nan_service_type_t type; /**< Service type */ + char matching_filter[ESP_WIFI_MAX_FILTER_LEN]; /**< Comma separated filters for filtering services */ + char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN]; /**< Service info shared in Subscribe frame */ + uint8_t single_match_event:1; /**< Give single Match event or every time */ + uint8_t reserved:7; /**< Reserved */ +} wifi_nan_subscribe_cfg_t; + +/** + * @brief NAN Follow-up parameters + * + */ +typedef struct { + uint8_t inst_id; /**< Own service instance id */ + uint8_t peer_inst_id; /**< Peer's service instance id */ + uint8_t peer_mac[6]; /**< Peer's MAC address */ + char svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service info(or message) to be shared */ +} wifi_nan_followup_params_t; + +/** + * @brief NAN Datapath Request parameters + * + */ +typedef struct { + uint8_t pub_id; /**< Publisher's service instance id */ + uint8_t peer_mac[6]; /**< Peer's MAC address */ + bool confirm_required; /**< NDP Confirm frame required */ +} wifi_nan_datapath_req_t; + +/** + * @brief NAN Datapath Response parameters + * + */ +typedef struct { + bool accept; /**< True - Accept incoming NDP, False - Reject it */ + uint8_t ndp_id; /**< NAN Datapath Identifier */ + uint8_t peer_mac[6]; /**< Peer's MAC address */ +} wifi_nan_datapath_resp_t; + +/** + * @brief NAN Datapath End parameters + * + */ +typedef struct { + uint8_t ndp_id; /**< NAN Datapath Identifier */ + uint8_t peer_mac[6]; /**< Peer's MAC address */ +} wifi_nan_datapath_end_req_t; + +/** + * @brief WiFi PHY rate encodings + * + */ +typedef enum { + WIFI_PHY_RATE_1M_L = 0x00, /**< 1 Mbps with long preamble */ + WIFI_PHY_RATE_2M_L = 0x01, /**< 2 Mbps with long preamble */ + WIFI_PHY_RATE_5M_L = 0x02, /**< 5.5 Mbps with long preamble */ + WIFI_PHY_RATE_11M_L = 0x03, /**< 11 Mbps with long preamble */ + WIFI_PHY_RATE_2M_S = 0x05, /**< 2 Mbps with short preamble */ + WIFI_PHY_RATE_5M_S = 0x06, /**< 5.5 Mbps with short preamble */ + WIFI_PHY_RATE_11M_S = 0x07, /**< 11 Mbps with short preamble */ + WIFI_PHY_RATE_48M = 0x08, /**< 48 Mbps */ + WIFI_PHY_RATE_24M = 0x09, /**< 24 Mbps */ + WIFI_PHY_RATE_12M = 0x0A, /**< 12 Mbps */ + WIFI_PHY_RATE_6M = 0x0B, /**< 6 Mbps */ + WIFI_PHY_RATE_54M = 0x0C, /**< 54 Mbps */ + WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */ + WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */ + WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */ + /**< rate table and guard interval information for each MCS rate*/ + /* + ----------------------------------------------------------------------------------------------------------- + MCS RATE | HT20 | HT40 | HE20 | + WIFI_PHY_RATE_MCS0_LGI | 6.5 Mbps (800ns) | 13.5 Mbps (800ns) | 8.1 Mbps (1600ns) | + WIFI_PHY_RATE_MCS1_LGI | 13 Mbps (800ns) | 27 Mbps (800ns) | 16.3 Mbps (1600ns) | + WIFI_PHY_RATE_MCS2_LGI | 19.5 Mbps (800ns) | 40.5 Mbps (800ns) | 24.4 Mbps (1600ns) | + WIFI_PHY_RATE_MCS3_LGI | 26 Mbps (800ns) | 54 Mbps (800ns) | 32.5 Mbps (1600ns) | + WIFI_PHY_RATE_MCS4_LGI | 39 Mbps (800ns) | 81 Mbps (800ns) | 48.8 Mbps (1600ns) | + WIFI_PHY_RATE_MCS5_LGI | 52 Mbps (800ns) | 108 Mbps (800ns) | 65 Mbps (1600ns) | + WIFI_PHY_RATE_MCS6_LGI | 58.5 Mbps (800ns) | 121.5 Mbps (800ns) | 73.1 Mbps (1600ns) | + WIFI_PHY_RATE_MCS7_LGI | 65 Mbps (800ns) | 135 Mbps (800ns) | 81.3 Mbps (1600ns) | + WIFI_PHY_RATE_MCS8_LGI | ----- | ----- | 97.5 Mbps (1600ns) | + WIFI_PHY_RATE_MCS9_LGI | ----- | ----- | 108.3 Mbps (1600ns) | + ----------------------------------------------------------------------------------------------------------- + */ + WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI */ + WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI */ + WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI */ + WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI */ + WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI */ + WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI */ + WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI */ + WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI */ +#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT + WIFI_PHY_RATE_MCS8_LGI, /**< MCS8 with long GI */ + WIFI_PHY_RATE_MCS9_LGI, /**< MCS9 with long GI */ +#endif + /* + ----------------------------------------------------------------------------------------------------------- + MCS RATE | HT20 | HT40 | HE20 | + WIFI_PHY_RATE_MCS0_SGI | 7.2 Mbps (400ns) | 15 Mbps (400ns) | 8.6 Mbps (800ns) | + WIFI_PHY_RATE_MCS1_SGI | 14.4 Mbps (400ns) | 30 Mbps (400ns) | 17.2 Mbps (800ns) | + WIFI_PHY_RATE_MCS2_SGI | 21.7 Mbps (400ns) | 45 Mbps (400ns) | 25.8 Mbps (800ns) | + WIFI_PHY_RATE_MCS3_SGI | 28.9 Mbps (400ns) | 60 Mbps (400ns) | 34.4 Mbps (800ns) | + WIFI_PHY_RATE_MCS4_SGI | 43.3 Mbps (400ns) | 90 Mbps (400ns) | 51.6 Mbps (800ns) | + WIFI_PHY_RATE_MCS5_SGI | 57.8 Mbps (400ns) | 120 Mbps (400ns) | 68.8 Mbps (800ns) | + WIFI_PHY_RATE_MCS6_SGI | 65 Mbps (400ns) | 135 Mbps (400ns) | 77.4 Mbps (800ns) | + WIFI_PHY_RATE_MCS7_SGI | 72.2 Mbps (400ns) | 150 Mbps (400ns) | 86 Mbps (800ns) | + WIFI_PHY_RATE_MCS8_SGI | ----- | ----- | 103.2 Mbps (800ns) | + WIFI_PHY_RATE_MCS9_SGI | ----- | ----- | 114.7 Mbps (800ns) | + ----------------------------------------------------------------------------------------------------------- + */ + WIFI_PHY_RATE_MCS0_SGI, /**< MCS0 with short GI */ + WIFI_PHY_RATE_MCS1_SGI, /**< MCS1 with short GI */ + WIFI_PHY_RATE_MCS2_SGI, /**< MCS2 with short GI */ + WIFI_PHY_RATE_MCS3_SGI, /**< MCS3 with short GI */ + WIFI_PHY_RATE_MCS4_SGI, /**< MCS4 with short GI */ + WIFI_PHY_RATE_MCS5_SGI, /**< MCS5 with short GI */ + WIFI_PHY_RATE_MCS6_SGI, /**< MCS6 with short GI */ + WIFI_PHY_RATE_MCS7_SGI, /**< MCS7 with short GI */ +#if CONFIG_SOC_WIFI_HE_SUPPORT || !CONFIG_SOC_WIFI_SUPPORT + WIFI_PHY_RATE_MCS8_SGI, /**< MCS8 with short GI */ + WIFI_PHY_RATE_MCS9_SGI, /**< MCS9 with short GI */ +#endif + WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */ + WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */ + WIFI_PHY_RATE_MAX, +} wifi_phy_rate_t; + +/** WiFi event declarations */ +typedef enum { + WIFI_EVENT_WIFI_READY = 0, /**< WiFi ready */ + WIFI_EVENT_SCAN_DONE, /**< Finished scanning AP */ + WIFI_EVENT_STA_START, /**< Station start */ + WIFI_EVENT_STA_STOP, /**< Station stop */ + WIFI_EVENT_STA_CONNECTED, /**< Station connected to AP */ + WIFI_EVENT_STA_DISCONNECTED, /**< Station disconnected from AP */ + WIFI_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by device's station changed */ + + WIFI_EVENT_STA_WPS_ER_SUCCESS, /**< Station wps succeeds in enrollee mode */ + WIFI_EVENT_STA_WPS_ER_FAILED, /**< Station wps fails in enrollee mode */ + WIFI_EVENT_STA_WPS_ER_TIMEOUT, /**< Station wps timeout in enrollee mode */ + WIFI_EVENT_STA_WPS_ER_PIN, /**< Station wps pin code in enrollee mode */ + WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, /**< Station wps overlap in enrollee mode */ + + WIFI_EVENT_AP_START, /**< Soft-AP start */ + WIFI_EVENT_AP_STOP, /**< Soft-AP stop */ + WIFI_EVENT_AP_STACONNECTED, /**< a station connected to Soft-AP */ + WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from Soft-AP */ + WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */ + + WIFI_EVENT_FTM_REPORT, /**< Receive report of FTM procedure */ + + /* Add next events after this only */ + WIFI_EVENT_STA_BSS_RSSI_LOW, /**< AP's RSSI crossed configured threshold */ + WIFI_EVENT_ACTION_TX_STATUS, /**< Status indication of Action Tx operation */ + WIFI_EVENT_ROC_DONE, /**< Remain-on-Channel operation complete */ + + WIFI_EVENT_STA_BEACON_TIMEOUT, /**< Station beacon timeout */ + + WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START, /**< Connectionless module wake interval start */ + + WIFI_EVENT_AP_WPS_RG_SUCCESS, /**< Soft-AP wps succeeds in registrar mode */ + WIFI_EVENT_AP_WPS_RG_FAILED, /**< Soft-AP wps fails in registrar mode */ + WIFI_EVENT_AP_WPS_RG_TIMEOUT, /**< Soft-AP wps timeout in registrar mode */ + WIFI_EVENT_AP_WPS_RG_PIN, /**< Soft-AP wps pin code in registrar mode */ + WIFI_EVENT_AP_WPS_RG_PBC_OVERLAP, /**< Soft-AP wps overlap in registrar mode */ + + WIFI_EVENT_ITWT_SETUP, /**< iTWT setup */ + WIFI_EVENT_ITWT_TEARDOWN, /**< iTWT teardown */ + WIFI_EVENT_ITWT_PROBE, /**< iTWT probe */ + WIFI_EVENT_ITWT_SUSPEND, /**< iTWT suspend */ + + WIFI_EVENT_NAN_STARTED, /**< NAN Discovery has started */ + WIFI_EVENT_NAN_STOPPED, /**< NAN Discovery has stopped */ + WIFI_EVENT_NAN_SVC_MATCH, /**< NAN Service Discovery match found */ + WIFI_EVENT_NAN_REPLIED, /**< Replied to a NAN peer with Service Discovery match */ + WIFI_EVENT_NAN_RECEIVE, /**< Received a Follow-up message */ + WIFI_EVENT_NDP_INDICATION, /**< Received NDP Request from a NAN Peer */ + WIFI_EVENT_NDP_CONFIRM, /**< NDP Confirm Indication */ + WIFI_EVENT_NDP_TERMINATED, /**< NAN Datapath terminated indication */ + WIFI_EVENT_HOME_CHANNEL_CHANGE, /**< WiFi home channel change,doesn't occur when scanning */ + + WIFI_EVENT_MAX, /**< Invalid WiFi event ID */ +} wifi_event_t; + +/** @cond **/ +/** @brief WiFi event base declaration */ +ESP_EVENT_DECLARE_BASE(WIFI_EVENT); +/** @endcond **/ + +/** Argument structure for WIFI_EVENT_SCAN_DONE event */ +typedef struct { + uint32_t status; /**< status of scanning APs: 0 — success, 1 - failure */ + uint8_t number; /**< number of scan results */ + uint8_t scan_id; /**< scan sequence number, used for block scan */ +} wifi_event_sta_scan_done_t; + +/** Argument structure for WIFI_EVENT_STA_CONNECTED event */ +typedef struct { + uint8_t ssid[32]; /**< SSID of connected AP */ + uint8_t ssid_len; /**< SSID length of connected AP */ + uint8_t bssid[6]; /**< BSSID of connected AP*/ + uint8_t channel; /**< channel of connected AP*/ + wifi_auth_mode_t authmode;/**< authentication mode used by AP*/ + uint16_t aid; /**< authentication id assigned by the connected AP */ +} wifi_event_sta_connected_t; + +/** Argument structure for WIFI_EVENT_STA_DISCONNECTED event */ +typedef struct { + uint8_t ssid[32]; /**< SSID of disconnected AP */ + uint8_t ssid_len; /**< SSID length of disconnected AP */ + uint8_t bssid[6]; /**< BSSID of disconnected AP */ + uint8_t reason; /**< reason of disconnection */ + int8_t rssi; /**< rssi of disconnection */ +} wifi_event_sta_disconnected_t; + +/** Argument structure for WIFI_EVENT_STA_AUTHMODE_CHANGE event */ +typedef struct { + wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ + wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ +} wifi_event_sta_authmode_change_t; + +/** Argument structure for WIFI_EVENT_STA_WPS_ER_PIN event */ +typedef struct { + uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ +} wifi_event_sta_wps_er_pin_t; + +/** Argument structure for WIFI_EVENT_STA_WPS_ER_FAILED event */ +typedef enum { + WPS_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ + WPS_FAIL_REASON_RECV_M2D, /**< WPS receive M2D frame */ + WPS_FAIL_REASON_MAX +} wifi_event_sta_wps_fail_reason_t; + +#define MAX_SSID_LEN 32 +#define MAX_PASSPHRASE_LEN 64 +#define MAX_WPS_AP_CRED 3 + +/** Argument structure for WIFI_EVENT_STA_WPS_ER_SUCCESS event */ +typedef struct { + uint8_t ap_cred_cnt; /**< Number of AP credentials received */ + struct { + uint8_t ssid[MAX_SSID_LEN]; /**< SSID of AP */ + uint8_t passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase for the AP */ + } ap_cred[MAX_WPS_AP_CRED]; /**< All AP credentials received from WPS handshake */ +} wifi_event_sta_wps_er_success_t; + +/** Argument structure for WIFI_EVENT_AP_STACONNECTED event */ +typedef struct { + uint8_t mac[6]; /**< MAC address of the station connected to Soft-AP */ + uint8_t aid; /**< the aid that soft-AP gives to the station connected to */ + bool is_mesh_child; /**< flag to identify mesh child */ +} wifi_event_ap_staconnected_t; + +/** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ +typedef struct { + uint8_t mac[6]; /**< MAC address of the station disconnects to soft-AP */ + uint8_t aid; /**< the aid that soft-AP gave to the station disconnects to */ + bool is_mesh_child; /**< flag to identify mesh child */ + uint8_t reason; /**< reason of disconnection */ +} wifi_event_ap_stadisconnected_t; + +/** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ +typedef struct { + int rssi; /**< Received probe request signal strength */ + uint8_t mac[6]; /**< MAC address of the station which send probe request */ +} wifi_event_ap_probe_req_rx_t; + +/** Argument structure for WIFI_EVENT_STA_BSS_RSSI_LOW event */ +typedef struct { + int32_t rssi; /**< RSSI value of bss */ +} wifi_event_bss_rssi_low_t; + +/** Argument structure for WIFI_EVENT_HOME_CHANNEL_CHANGE event */ +typedef struct { + uint8_t old_chan; /**< old home channel of the device */ + wifi_second_chan_t old_snd; /**< old second channel of the device */ + uint8_t new_chan; /**< new home channel of the device */ + wifi_second_chan_t new_snd; /**< new second channel of the device */ +} wifi_event_home_channel_change_t; + +/** + * @brief FTM operation status types + * + */ +typedef enum { + FTM_STATUS_SUCCESS = 0, /**< FTM exchange is successful */ + FTM_STATUS_UNSUPPORTED, /**< Peer does not support FTM */ + FTM_STATUS_CONF_REJECTED, /**< Peer rejected FTM configuration in FTM Request */ + FTM_STATUS_NO_RESPONSE, /**< Peer did not respond to FTM Requests */ + FTM_STATUS_FAIL, /**< Unknown error during FTM exchange */ +} wifi_ftm_status_t; + +/** Argument structure for */ +typedef struct { + uint8_t dlog_token; /**< Dialog Token of the FTM frame */ + int8_t rssi; /**< RSSI of the FTM frame received */ + uint32_t rtt; /**< Round Trip Time in pSec with a peer */ + uint64_t t1; /**< Time of departure of FTM frame from FTM Responder in pSec */ + uint64_t t2; /**< Time of arrival of FTM frame at FTM Initiator in pSec */ + uint64_t t3; /**< Time of departure of ACK from FTM Initiator in pSec */ + uint64_t t4; /**< Time of arrival of ACK at FTM Responder in pSec */ +} wifi_ftm_report_entry_t; + +/** Argument structure for WIFI_EVENT_FTM_REPORT event */ +typedef struct { + uint8_t peer_mac[6]; /**< MAC address of the FTM Peer */ + wifi_ftm_status_t status; /**< Status of the FTM operation */ + uint32_t rtt_raw; /**< Raw average Round-Trip-Time with peer in Nano-Seconds */ + uint32_t rtt_est; /**< Estimated Round-Trip-Time with peer in Nano-Seconds */ + uint32_t dist_est; /**< Estimated one-way distance in Centi-Meters */ + wifi_ftm_report_entry_t *ftm_report_data; /**< Pointer to FTM Report with multiple entries, should be freed after use */ + uint8_t ftm_report_num_entries; /**< Number of entries in the FTM Report data */ +} wifi_event_ftm_report_t; + +#define WIFI_STATIS_BUFFER (1<<0) +#define WIFI_STATIS_RXTX (1<<1) +#define WIFI_STATIS_HW (1<<2) +#define WIFI_STATIS_DIAG (1<<3) +#define WIFI_STATIS_PS (1<<4) +#define WIFI_STATIS_ALL (-1) + +/** Argument structure for WIFI_EVENT_ACTION_TX_STATUS event */ +typedef struct { + wifi_interface_t ifx; /**< WiFi interface to send request to */ + uint32_t context; /**< Context to identify the request */ + uint8_t da[6]; /**< Destination MAC address */ + uint8_t status; /**< Status of the operation */ +} wifi_event_action_tx_status_t; + +/** Argument structure for WIFI_EVENT_ROC_DONE event */ +typedef struct { + uint32_t context; /**< Context to identify the request */ +} wifi_event_roc_done_t; + +/** Argument structure for WIFI_EVENT_AP_WPS_RG_PIN event */ +typedef struct { + uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ +} wifi_event_ap_wps_rg_pin_t; + +typedef enum { + WPS_AP_FAIL_REASON_NORMAL = 0, /**< WPS normal fail reason */ + WPS_AP_FAIL_REASON_CONFIG, /**< WPS failed due to incorrect config */ + WPS_AP_FAIL_REASON_AUTH, /**< WPS failed during auth */ + WPS_AP_FAIL_REASON_MAX, +} wps_fail_reason_t; + +/** Argument structure for WIFI_EVENT_AP_WPS_RG_FAILED event */ +typedef struct { + wps_fail_reason_t reason; /**< WPS failure reason wps_fail_reason_t */ + uint8_t peer_macaddr[6]; /**< Enrollee mac address */ +} wifi_event_ap_wps_rg_fail_reason_t; + +/** Argument structure for WIFI_EVENT_AP_WPS_RG_SUCCESS event */ +typedef struct { + uint8_t peer_macaddr[6]; /**< Enrollee mac address */ +} wifi_event_ap_wps_rg_success_t; + +/** Argument structure for WIFI_EVENT_NAN_SVC_MATCH event */ +typedef struct { + uint8_t subscribe_id; /**< Subscribe Service Identifier */ + uint8_t publish_id; /**< Publish Service Identifier */ + uint8_t pub_if_mac[6]; /**< NAN Interface MAC of the Publisher */ + bool update_pub_id; /**< Indicates whether publisher's service ID needs to be updated */ +} wifi_event_nan_svc_match_t; + +/** Argument structure for WIFI_EVENT_NAN_REPLIED event */ +typedef struct { + uint8_t publish_id; /**< Publish Service Identifier */ + uint8_t subscribe_id; /**< Subscribe Service Identifier */ + uint8_t sub_if_mac[6]; /**< NAN Interface MAC of the Subscriber */ +} wifi_event_nan_replied_t; + +/** Argument structure for WIFI_EVENT_NAN_RECEIVE event */ +typedef struct { + uint8_t inst_id; /**< Our Service Identifier */ + uint8_t peer_inst_id; /**< Peer's Service Identifier */ + uint8_t peer_if_mac[6]; /**< Peer's NAN Interface MAC */ + uint8_t peer_svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Peer Service Info */ +} wifi_event_nan_receive_t; + +/** Argument structure for WIFI_EVENT_NDP_INDICATION event */ +typedef struct { + uint8_t publish_id; /**< Publish Id for NAN Service */ + uint8_t ndp_id; /**< NDP instance id */ + uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ + uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ + uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ +} wifi_event_ndp_indication_t; + +/** Argument structure for WIFI_EVENT_NDP_CONFIRM event */ +typedef struct { + uint8_t status; /**< NDP status code */ + uint8_t ndp_id; /**< NDP instance id */ + uint8_t peer_nmi[6]; /**< Peer's NAN Management Interface MAC */ + uint8_t peer_ndi[6]; /**< Peer's NAN Data Interface MAC */ + uint8_t own_ndi[6]; /**< Own NAN Data Interface MAC */ + uint8_t svc_info[ESP_WIFI_MAX_SVC_INFO_LEN];/**< Service Specific Info */ +} wifi_event_ndp_confirm_t; + +/** Argument structure for WIFI_EVENT_NDP_TERMINATED event */ +typedef struct { + uint8_t reason; /**< Termination reason code */ + uint8_t ndp_id; /**< NDP instance id */ + uint8_t init_ndi[6]; /**< Initiator's NAN Data Interface MAC */ +} wifi_event_ndp_terminated_t; + +#ifdef __cplusplus +} +#endif + +#endif /* __ESP_WIFI_TYPES_H__ */ From c0b3af2292af4a5b49775aeb48d0115d602ea8b8 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Tue, 17 Oct 2023 11:18:27 +0530 Subject: [PATCH 4/6] fix(esp_wifi): Add md5sum validation checks for new public headers and sync headers Add checks for following public headers: - esp_wifi_types_generic.h - esp_wifi_native.h --- components/esp_wifi/include/esp_wifi_types.h | 1 + components/esp_wifi/include/esp_wifi_types_generic.h | 4 ++-- components/esp_wifi/include/local/esp_wifi_native.h | 4 +++- components/esp_wifi/test_md5/test_md5.sh | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index f237fbff4a..3f0f1ab07a 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #pragma once + #include "esp_wifi_types_generic.h" #if __has_include("esp_wifi_native.h") #include "esp_wifi_native.h" diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index e523f94619..e7b35ef41e 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -8,7 +8,7 @@ #ifndef __ESP_WIFI_TYPES_H__ #define __ESP_WIFI_TYPES_H__ -#include "esp_event.h" +#include "esp_event_base.h" #include "esp_interface.h" #ifdef __cplusplus @@ -430,7 +430,7 @@ typedef struct { uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ } vendor_ie_data_t; -typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; +typedef struct wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; /** * @brief Promiscuous frame type diff --git a/components/esp_wifi/include/local/esp_wifi_native.h b/components/esp_wifi/include/local/esp_wifi_native.h index 12d7f1e396..8edd780364 100644 --- a/components/esp_wifi/include/local/esp_wifi_native.h +++ b/components/esp_wifi/include/local/esp_wifi_native.h @@ -102,7 +102,9 @@ typedef struct wifi_csi_config_t{ uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */ bool dump_ack_en; /**< enable to dump 802.11 ACK frame, default disabled */ } wifi_csi_config_t; -#endif +#endif // !CONFIG_SOC_WIFI_HE_SUPPORT + +typedef wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; /** * @brief CSI data type diff --git a/components/esp_wifi/test_md5/test_md5.sh b/components/esp_wifi/test_md5/test_md5.sh index 115537ce09..8a676b8e33 100755 --- a/components/esp_wifi/test_md5/test_md5.sh +++ b/components/esp_wifi/test_md5/test_md5.sh @@ -39,6 +39,8 @@ ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ -u g_esp_wifi_he_md5 \ -u g_wifi_crypto_funcs_md5 \ -u g_wifi_type_md5 \ + -u g_wifi_types_generic_md5 \ + -u g_wifi_types_native_md5 \ -u g_wifi_he_type_md5 \ -u g_wifi_osi_funcs_md5 \ -u g_wifi_supplicant_funcs_md5 \ @@ -70,6 +72,8 @@ check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_he.h g_esp_wifi_he_md check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h g_wifi_osi_funcs_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h g_wifi_crypto_funcs_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types.h g_wifi_type_md5 +check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types_generic.h g_wifi_types_generic_md5 +check_md5 ${IDF_PATH}/components/esp_wifi/include/local/esp_wifi_native.h g_wifi_types_native_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_he_types.h g_wifi_he_type_md5 check_md5 ${IDF_PATH}/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h g_wifi_supplicant_funcs_md5 From 344cb342b88c8055ab24411ff74eed04d15dd75c Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 24 Nov 2023 16:28:05 +0100 Subject: [PATCH 5/6] fix(esp_wifi): Support for esp_wifi_remote --- components/esp_wifi/CMakeLists.txt | 9 ++++--- .../include/esp_private/esp_wifi_he_private.h | 5 ++++ components/esp_wifi/include/esp_wifi.h | 1 + .../include/esp_wifi_ap_get_sta_list.h | 15 +++++++++++- .../esp_wifi/include/esp_wifi_types_generic.h | 12 ++++++++++ .../esp_wifi/include/local/esp_wifi_native.h | 24 ++++++++++++------- components/wpa_supplicant/CMakeLists.txt | 7 ++++++ examples/protocols/.build-test-rules.yml | 4 ++-- examples/protocols/https_request/README.md | 4 ++-- .../advanced/components/cmd_wifi/cmd_wifi.c | 7 ++++++ examples/wifi/iperf/main/cmd_wifi.c | 1 - 11 files changed, 69 insertions(+), 20 deletions(-) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 97ddaec4ea..61321761e1 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -84,9 +84,8 @@ else() idf_component_get_property(esp_wifi_remote esp_wifi_remote COMPONENT_LIB) target_link_libraries(${COMPONENT_LIB} PUBLIC ${esp_wifi_remote}) endif() - - if(CONFIG_SPIRAM) - idf_component_optional_requires(PRIVATE esp_psram) - endif() - +endif() + +if(CONFIG_SPIRAM) + idf_component_optional_requires(PRIVATE esp_psram) endif() diff --git a/components/esp_wifi/include/esp_private/esp_wifi_he_private.h b/components/esp_wifi/include/esp_private/esp_wifi_he_private.h index ffa191de19..9a3f81b63d 100644 --- a/components/esp_wifi/include/esp_private/esp_wifi_he_private.h +++ b/components/esp_wifi/include/esp_private/esp_wifi_he_private.h @@ -6,6 +6,9 @@ #pragma once +#include "sdkconfig.h" +#if CONFIG_SOC_WIFI_HE_SUPPORT + #include #include #include "esp_err.h" @@ -201,3 +204,5 @@ esp_err_t esp_wifi_sta_set_bss_color_collision_detection(int threshold, int dura #ifdef __cplusplus } #endif + +#endif // CONFIG_SOC_WIFI_HE_SUPPORT diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 241c18fe52..66e9724e11 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -183,6 +183,7 @@ typedef struct { #endif extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; +extern wifi_osi_funcs_t g_wifi_osi_funcs; #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F diff --git a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h index 7a4d167b64..f3c43a4733 100644 --- a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h +++ b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,6 +13,19 @@ extern "C" { #endif + +#ifndef ESP_WIFI_MAX_CONN_NUM +// Number of maximum wifi connection may be undefined if we have no native wifi support on this target +// and at the same time there's no native interface injected by the wifi_remote component. +// In this case, we just let the header compilable, since no wifi API could be used (let's make a sanity check) +#if !CONFIG_SOC_WIFI_SUPPORTED && !CONFIG_ESP_WIFI_REMOTE_ENABLED +#define ESP_WIFI_MAX_CONN_NUM (15) +typedef struct wifi_sta_list_t wifi_sta_list_t; +#else +#error WiFi header mismatch! Please make sure you use the correct version of WiFi API +#endif +#endif // ESP_WIFI_MAX_CONN_NUM + /** * @brief station list structure */ diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index e7b35ef41e..8fa0123881 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -8,6 +8,9 @@ #ifndef __ESP_WIFI_TYPES_H__ #define __ESP_WIFI_TYPES_H__ +#include +#include +#include "sdkconfig.h" #include "esp_event_base.h" #include "esp_interface.h" @@ -430,6 +433,15 @@ typedef struct { uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ } vendor_ie_data_t; +/** + * @brief Forward declare the Rx ctrl packet struct, as it is TARGET dependent and will be defined + * in the "native" wifi types (types tightly coupled to wifi-lib implementation) + */ +typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; + +/** + * @brief Rx Control Packet alias used in wifi-lib implementation + */ typedef struct wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; /** diff --git a/components/esp_wifi/include/local/esp_wifi_native.h b/components/esp_wifi/include/local/esp_wifi_native.h index 8edd780364..326597e4c7 100644 --- a/components/esp_wifi/include/local/esp_wifi_native.h +++ b/components/esp_wifi/include/local/esp_wifi_native.h @@ -7,10 +7,14 @@ #pragma once #include "sdkconfig.h" +#include "esp_wifi_types_generic.h" #if CONFIG_SOC_WIFI_HE_SUPPORT #include "esp_wifi_he_types.h" #endif +#ifdef __cplusplus +extern "C" { +#endif #if CONFIG_IDF_TARGET_ESP32C2 #define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ @@ -78,20 +82,11 @@ typedef struct wifi_pkt_rx_ctrl_t{ unsigned :12; /**< reserved */ unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ } wifi_pkt_rx_ctrl_t; -#endif - -/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. - */ -typedef struct { - wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ - 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. */ -} wifi_promiscuous_pkt_t; /** * @brief Channel state information(CSI) configuration type * */ -#if !CONFIG_SOC_WIFI_HE_SUPPORT typedef struct wifi_csi_config_t{ bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ @@ -106,6 +101,13 @@ typedef struct wifi_csi_config_t{ typedef wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; +/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. + */ +typedef struct { + wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ + 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. */ +} wifi_promiscuous_pkt_t; + /** * @brief CSI data type * @@ -121,3 +123,7 @@ typedef struct wifi_csi_info_t { uint8_t *payload; /**< payload of the wifi packet */ uint16_t payload_len; /**< payload len of the wifi packet */ } wifi_csi_info_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index ea6e78ef9f..9e7d1c042d 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -6,6 +6,13 @@ else() set(linker_fragments linker.lf) endif() +if(NOT CONFIG_ESP_WIFI_ENABLED AND NOT CMAKE_BUILD_EARLY_EXPANSION) + # This component provides only "esp_supplicant" headers if WiFi not enabled + # (implementation supported optionally in a managed component esp_wifi_remote) + idf_component_register(INCLUDE_DIRS esp_supplicant/include) + return() +endif() + set(srcs "port/os_xtensa.c" "port/eloop.c" "src/ap/ap_config.c" diff --git a/examples/protocols/.build-test-rules.yml b/examples/protocols/.build-test-rules.yml index 643365c9c8..43502efc2a 100644 --- a/examples/protocols/.build-test-rules.yml +++ b/examples/protocols/.build-test-rules.yml @@ -114,9 +114,9 @@ examples/protocols/https_mbedtls: examples/protocols/https_request: <<: *default_dependencies disable: - - if: IDF_TARGET == "esp32p4" + - if: IDF_TARGET in ["esp32h2", "esp32p4"] temporary: true - reason: not supported on p4 # TODO: IDF-8076 + reason: not supported on p4 and h2 # TODO: IDF-8076 (P4), IDF-9076 (H2) disable_test: - if: IDF_TARGET != "esp32" reason: only test on esp32 diff --git a/examples/protocols/https_request/README.md b/examples/protocols/https_request/README.md index 55b32b1669..3e2cc244c0 100644 --- a/examples/protocols/https_request/README.md +++ b/examples/protocols/https_request/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | # HTTPS Request Example diff --git a/examples/system/console/advanced/components/cmd_wifi/cmd_wifi.c b/examples/system/console/advanced/components/cmd_wifi/cmd_wifi.c index b8dbaea2c8..8f286ddb5f 100644 --- a/examples/system/console/advanced/components/cmd_wifi/cmd_wifi.c +++ b/examples/system/console/advanced/components/cmd_wifi/cmd_wifi.c @@ -24,6 +24,11 @@ #include "esp_event.h" #include "cmd_wifi.h" +/** + * This component will be supported using esp_wifi_remote + */ +#if CONFIG_SOC_WIFI_SUPPORTED + #define JOIN_TIMEOUT_MS (10000) static EventGroupHandle_t wifi_event_group; @@ -134,3 +139,5 @@ void register_wifi(void) ESP_ERROR_CHECK( esp_console_cmd_register(&join_cmd) ); } + +#endif // CONFIG_SOC_WIFI_SUPPORTED diff --git a/examples/wifi/iperf/main/cmd_wifi.c b/examples/wifi/iperf/main/cmd_wifi.c index c5c110b677..88b862d1fc 100644 --- a/examples/wifi/iperf/main/cmd_wifi.c +++ b/examples/wifi/iperf/main/cmd_wifi.c @@ -23,7 +23,6 @@ #include "iperf.h" #include "esp_coexist.h" #include "wifi_cmd.h" -#include "esp_wifi_he.h" typedef struct { struct arg_str *ip; From 0154e81d87c81e6cb6ea5db4cd1516a1f2b15097 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Tue, 23 Jan 2024 16:08:14 +0530 Subject: [PATCH 6/6] feat(wifi): Sync public header files between ESP-IDF and Wi-Fi driver - Updated WiFi libraries based on the IDF changes - Renamed esp_wifi_native.h to esp_wifi_types_native.h - Reverted forward declarations of native wifi types and HE types - Forward declare as opaque structs only if we don't have native types (csi and ctrl_packet types) --- .../esp_wifi/include/esp_wifi_he_types.h | 10 ++++----- components/esp_wifi/include/esp_wifi_types.h | 22 +++++++++++++++++-- .../esp_wifi/include/esp_wifi_types_generic.h | 17 -------------- ..._wifi_native.h => esp_wifi_types_native.h} | 15 ++++++++----- components/esp_wifi/lib | 2 +- components/esp_wifi/test_md5/test_md5.sh | 2 +- tools/mocks/esp_wifi/CMakeLists.txt | 2 +- tools/mocks/esp_wifi/global_symbols_mock.c | 1 + 8 files changed, 39 insertions(+), 32 deletions(-) rename components/esp_wifi/include/local/{esp_wifi_native.h => esp_wifi_types_native.h} (96%) diff --git a/components/esp_wifi/include/esp_wifi_he_types.h b/components/esp_wifi/include/esp_wifi_he_types.h index 02bc5efef1..868c73b5b0 100644 --- a/components/esp_wifi/include/esp_wifi_he_types.h +++ b/components/esp_wifi/include/esp_wifi_he_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -40,7 +40,7 @@ enum { /** * @brief Channel state information(CSI) configuration type */ -typedef struct wifi_csi_config_t { +typedef struct { uint32_t enable : 1; /**< enable to acquire CSI */ uint32_t acquire_csi_legacy : 1; /**< enable to acquire L-LTF when receiving a 11g PPDU */ uint32_t acquire_csi_ht20 : 1; /**< enable to acquire HT-LTF when receiving an HT20 PPDU */ @@ -56,7 +56,7 @@ typedef struct wifi_csi_config_t { uint32_t val_scale_cfg : 2; /**< value 0-3 */ uint32_t dump_ack_en : 1; /**< enable to dump 802.11 ACK frame, default disabled */ uint32_t reserved : 19; /**< reserved */ -} wifi_csi_config_t; +} wifi_csi_acquire_config_t; /** * @brief HE variant HT Control field including UPH(UL power headroom) and OM(Operation mode) @@ -139,7 +139,7 @@ typedef enum { /** * @brief RxControl Info */ -typedef struct wifi_pkt_rx_ctrl_t { +typedef struct { signed rssi : 8; /**< the RSSI of the reception frame */ unsigned rate : 5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */ unsigned : 1; /**< reserved */ @@ -201,7 +201,7 @@ typedef struct wifi_pkt_rx_ctrl_t { unsigned : 2; /**< reserved */ unsigned rx_state : 8; /**< reception state, 0: successful, others: failure */ unsigned : 24; /**< reserved */ -} __attribute__((packed)) wifi_pkt_rx_ctrl_t; +} __attribute__((packed)) esp_wifi_rxctrl_t; /** Argument structure for WIFI_EVENT_TWT_SET_UP event */ typedef struct { diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 3f0f1ab07a..ef9f09cdab 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -6,6 +6,24 @@ #pragma once #include "esp_wifi_types_generic.h" -#if __has_include("esp_wifi_native.h") -#include "esp_wifi_native.h" +#if __has_include("esp_wifi_types_native.h") +#include "esp_wifi_types_native.h" +#else + +#ifdef __cplusplus +extern "C" { #endif + +/* + * In case we have no native types, we can still provide opaque structs, + * so the most common APIs could work and others would compile. + * This could happen for chipsets with no wifi, yet without local esp_wifi_remote. + */ +typedef struct wifi_csi_config_t wifi_csi_config_t; +typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; + +#ifdef __cplusplus +} +#endif + +#endif // __has_include("esp_wifi_types_native.h") diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index 8fa0123881..682f133a7c 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -433,17 +433,6 @@ typedef struct { uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */ } vendor_ie_data_t; -/** - * @brief Forward declare the Rx ctrl packet struct, as it is TARGET dependent and will be defined - * in the "native" wifi types (types tightly coupled to wifi-lib implementation) - */ -typedef struct wifi_pkt_rx_ctrl_t wifi_pkt_rx_ctrl_t; - -/** - * @brief Rx Control Packet alias used in wifi-lib implementation - */ -typedef struct wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; - /** * @brief Promiscuous frame type * @@ -487,12 +476,6 @@ typedef struct { #define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ #define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ -/** - * @brief Channel state information(CSI) configuration type - * - */ -typedef struct wifi_csi_config_t wifi_csi_config_t; - /** * @brief CSI data type * diff --git a/components/esp_wifi/include/local/esp_wifi_native.h b/components/esp_wifi/include/local/esp_wifi_types_native.h similarity index 96% rename from components/esp_wifi/include/local/esp_wifi_native.h rename to components/esp_wifi/include/local/esp_wifi_types_native.h index 326597e4c7..8103ddac29 100644 --- a/components/esp_wifi/include/local/esp_wifi_native.h +++ b/components/esp_wifi/include/local/esp_wifi_types_native.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -30,9 +30,11 @@ typedef struct wifi_sta_list_t { int num; /**< number of stations in the list (other entries are invalid) */ } wifi_sta_list_t; -#if !CONFIG_SOC_WIFI_HE_SUPPORT +#if CONFIG_SOC_WIFI_HE_SUPPORT +typedef esp_wifi_rxctrl_t wifi_pkt_rx_ctrl_t; +#else /** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */ -typedef struct wifi_pkt_rx_ctrl_t{ +typedef struct { signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ unsigned :1; /**< reserved */ @@ -82,12 +84,16 @@ typedef struct wifi_pkt_rx_ctrl_t{ unsigned :12; /**< reserved */ unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ } wifi_pkt_rx_ctrl_t; +#endif /** * @brief Channel state information(CSI) configuration type * */ -typedef struct wifi_csi_config_t{ +#if CONFIG_SOC_WIFI_HE_SUPPORT +typedef wifi_csi_acquire_config_t wifi_csi_config_t; +#else +typedef struct { bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */ @@ -99,7 +105,6 @@ typedef struct wifi_csi_config_t{ } wifi_csi_config_t; #endif // !CONFIG_SOC_WIFI_HE_SUPPORT -typedef wifi_pkt_rx_ctrl_t esp_wifi_rxctrl_t; /** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 4457ec627e..51ec8e854e 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 4457ec627eeabfaf38fa1f3d986917dbdf0849a7 +Subproject commit 51ec8e854ea9ae78ef66952afecd050020a7ac8e diff --git a/components/esp_wifi/test_md5/test_md5.sh b/components/esp_wifi/test_md5/test_md5.sh index 8a676b8e33..98c29f7732 100755 --- a/components/esp_wifi/test_md5/test_md5.sh +++ b/components/esp_wifi/test_md5/test_md5.sh @@ -73,7 +73,7 @@ check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h g_wifi_crypto_funcs_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types.h g_wifi_type_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types_generic.h g_wifi_types_generic_md5 -check_md5 ${IDF_PATH}/components/esp_wifi/include/local/esp_wifi_native.h g_wifi_types_native_md5 +check_md5 ${IDF_PATH}/components/esp_wifi/include/local/esp_wifi_types_native.h g_wifi_types_native_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_he_types.h g_wifi_he_type_md5 check_md5 ${IDF_PATH}/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h g_wifi_supplicant_funcs_md5 diff --git a/tools/mocks/esp_wifi/CMakeLists.txt b/tools/mocks/esp_wifi/CMakeLists.txt index 5be6f93641..42a58e496e 100644 --- a/tools/mocks/esp_wifi/CMakeLists.txt +++ b/tools/mocks/esp_wifi/CMakeLists.txt @@ -5,7 +5,7 @@ message(STATUS "building ESP WIFI MOCKS") idf_component_get_property(original_esp_wifi_dir esp_wifi COMPONENT_OVERRIDEN_DIR) set(include_dirs - "${original_esp_wifi_dir}/include") + "${original_esp_wifi_dir}/include" "${original_esp_wifi_dir}/include/local") idf_component_mock(INCLUDE_DIRS ${include_dirs} REQUIRES esp_event esp_netif lwip diff --git a/tools/mocks/esp_wifi/global_symbols_mock.c b/tools/mocks/esp_wifi/global_symbols_mock.c index 3a00a43317..3df7caa617 100644 --- a/tools/mocks/esp_wifi/global_symbols_mock.c +++ b/tools/mocks/esp_wifi/global_symbols_mock.c @@ -5,6 +5,7 @@ */ #include "esp_wifi.h" +#include "esp_private/wifi_os_adapter.h" /** * The following global objects are defined when WiFi is mocked.