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.