From 53a526e52dc5ab314f9ba0896fee6dfedfdc09de Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Tue, 3 Dec 2024 17:15:00 +0800 Subject: [PATCH 1/2] feat(wifi): wifi support 80211tx using 11ax rate --- components/esp_wifi/include/esp_now.h | 10 ++-------- components/esp_wifi/include/esp_wifi.h | 18 +++++++++++++++++- components/esp_wifi/include/esp_wifi_types.h | 13 ++++++++++++- components/esp_wifi/lib | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 1d9a8dd71f..2b2f37079d 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -93,14 +93,8 @@ typedef struct esp_now_recv_info { /** * @brief ESPNOW rate config - * */ -typedef struct esp_now_rate_config { - wifi_phy_mode_t phymode; /**< ESPNOW phymode of specified interface */ - wifi_phy_rate_t rate; /**< ESPNOW rate of specified interface*/ - bool ersu; /**< ESPNOW using ersu send frame*/ - bool dcm; /**< ESPNOW using dcm rate to send frame*/ -} esp_now_rate_config_t; +typedef wifi_tx_rate_config_t esp_now_rate_config_t; /** * @brief Callback function of receiving ESPNOW data diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 9f1f35dfb5..640e0d082b 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1452,6 +1452,7 @@ esp_err_t esp_wifi_get_country_code(char *country); * @brief Config 80211 tx rate of specified interface * * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). + * @attention 2. Can not set 80211 tx rate under 11AX protocol, you can use esp_wifi_config_80211_tx instead. * * @param ifx Interface to be configured. * @param rate Phy rate to be configured. @@ -1462,6 +1463,21 @@ esp_err_t esp_wifi_get_country_code(char *country); */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Config 80211 tx rate and phymode of specified interface + * + * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). + + * + * @param ifx Interface to be configured. + * @param config rate_config to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_config_80211_tx(wifi_interface_t ifx, wifi_tx_rate_config_t *config); + /** * @brief Disable PMF configuration for specified interface * diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 586376f992..58748a403b 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-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1147,6 +1147,17 @@ typedef struct { uint8_t init_ndi[6]; /**< Initiator's NAN Data Interface MAC */ } wifi_event_ndp_terminated_t; +/** + * @brief Argument structure for wifi_tx_rate_config + */ +typedef struct { + wifi_phy_mode_t phymode; /**< Phymode of specified interface */ + wifi_phy_rate_t rate; /**< Rate of specified interface */ + bool ersu; /**< Using ERSU to send frame, ERSU is a transmission mode related to 802.11 ax. + ERSU is always used in long distance transmission, and its frame has lower rate compared with SU mode */ + bool dcm; /**< Using dcm rate to send frame */ +} wifi_tx_rate_config_t; + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 84c4760cbb..130c3b5438 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 84c4760cbb72109ea01cfdb1f282bef29fcb4b06 +Subproject commit 130c3b543846223544aed82d00c7e18c87d0e000 From 44fd1e0d3aa16ce274171bf85f901f797521a68f Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Wed, 8 Jan 2025 15:40:42 +0800 Subject: [PATCH 2/2] feat(wifi): avoid compiling components related to wifi when wifi is not supported --- components/esp_wifi/CMakeLists.txt | 14 ++++++++++++++ components/esp_wifi/Kconfig | 4 ++-- components/wifi_provisioning/CMakeLists.txt | 7 +++++++ components/wifi_provisioning/Kconfig | 2 ++ components/wpa_supplicant/CMakeLists.txt | 9 +++++++++ .../advanced/components/cmd_wifi/CMakeLists.txt | 8 +++++++- .../console/advanced/main/console_example_main.c | 2 +- .../console/basic/main/console_example_main.c | 2 +- 8 files changed, 43 insertions(+), 5 deletions(-) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 8605bed5df..bedbeca5d9 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -4,6 +4,20 @@ if(${idf_target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator endif() +if( NOT CONFIG_ESP_WIFI_ENABLED AND NOT CMAKE_BUILD_EARLY_EXPANSION ) + # No local wifi: provide only netif bindings + set(srcs + "src/wifi_default.c" + "src/wifi_netif.c" + "src/wifi_default_ap.c") + + # This component provides "esp_wifi" "wifi_apps" headers if WiFi not enabled + # (implementation supported optionally in a managed component esp_wifi_remote) + idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS "include" "wifi_apps/include") + return() +endif() + if(CONFIG_ESP_WIFI_ENABLED) if(CONFIG_APP_NO_BLOBS) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index d77ae6aa9c..7d315d5205 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -1,7 +1,7 @@ menu "Wi-Fi" - # TODO: Disable WIFI support on ESP32-H2 (WIFI-5796) - # visible if SOC_WIFI_SUPPORTED + + visible if SOC_WIFI_SUPPORTED config ESP_WIFI_ENABLED bool diff --git a/components/wifi_provisioning/CMakeLists.txt b/components/wifi_provisioning/CMakeLists.txt index 96cfdd5665..7b9348644a 100644 --- a/components/wifi_provisioning/CMakeLists.txt +++ b/components/wifi_provisioning/CMakeLists.txt @@ -4,6 +4,13 @@ if(${target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator endif() +if( NOT CONFIG_ESP_WIFI_ENABLED AND NOT CMAKE_BUILD_EARLY_EXPANSION ) + # This component provides only "esp_provisioning" headers if WiFi not enabled + # (implementation supported optionally in a managed component esp_wifi_remote) + idf_component_register(INCLUDE_DIRS include) + return() +endif() + set(srcs "src/wifi_config.c" "src/wifi_scan.c" "src/wifi_ctrl.c" diff --git a/components/wifi_provisioning/Kconfig b/components/wifi_provisioning/Kconfig index d5a7d7aa36..61954e3129 100644 --- a/components/wifi_provisioning/Kconfig +++ b/components/wifi_provisioning/Kconfig @@ -1,5 +1,7 @@ menu "Wi-Fi Provisioning Manager" + visible if SOC_WIFI_SUPPORTED + config WIFI_PROV_SCAN_MAX_ENTRIES int "Max Wi-Fi Scan Result Entries" default 16 diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index ea6e78ef9f..2627c8cb3d 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -6,6 +6,15 @@ else() set(linker_fragments linker.lf) endif() +if( NOT CONFIG_ESP_WIFI_ENABLED + AND NOT CONFIG_ESP_HOST_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 include port/include esp_supplicant/include) + return() +endif() + set(srcs "port/os_xtensa.c" "port/eloop.c" "src/ap/ap_config.c" diff --git a/examples/system/console/advanced/components/cmd_wifi/CMakeLists.txt b/examples/system/console/advanced/components/cmd_wifi/CMakeLists.txt index ca51905567..b529d0328a 100644 --- a/examples/system/console/advanced/components/cmd_wifi/CMakeLists.txt +++ b/examples/system/console/advanced/components/cmd_wifi/CMakeLists.txt @@ -1,3 +1,9 @@ -idf_component_register(SRCS "cmd_wifi.c" +if(CONFIG_ESP_WIFI_ENABLED) + set(srcs "cmd_wifi.c") +else() + set(srcs) +endif() + +idf_component_register(SRCS "${srcs}" INCLUDE_DIRS . REQUIRES console esp_wifi) diff --git a/examples/system/console/advanced/main/console_example_main.c b/examples/system/console/advanced/main/console_example_main.c index dba157f544..989fc945d9 100644 --- a/examples/system/console/advanced/main/console_example_main.c +++ b/examples/system/console/advanced/main/console_example_main.c @@ -168,7 +168,7 @@ void app_main(void) esp_console_register_help_command(); register_system_common(); register_system_sleep(); -#if SOC_WIFI_SUPPORTED +#if CONFIG_ESP_WIFI_ENABLED register_wifi(); #endif register_nvs(); diff --git a/examples/system/console/basic/main/console_example_main.c b/examples/system/console/basic/main/console_example_main.c index 5ff13f33a2..3e544d70f0 100644 --- a/examples/system/console/basic/main/console_example_main.c +++ b/examples/system/console/basic/main/console_example_main.c @@ -92,7 +92,7 @@ void app_main(void) esp_console_register_help_command(); register_system_common(); register_system_sleep(); -#if SOC_WIFI_SUPPORTED +#if CONFIG_ESP_WIFI_ENABLED register_wifi(); #endif register_nvs();