From a6b2eb6ad0a170593cb8f9db87ddf37ad12ec922 Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Thu, 18 Dec 2025 10:52:30 +0800 Subject: [PATCH] refactor(wifi): remove enum values WIFI_BW_HT20 and WIFI_BW_HT40 --- components/esp_wifi/include/esp_wifi.h | 8 ++++---- components/esp_wifi/include/esp_wifi_types_generic.h | 6 ++---- components/esp_wifi/lib | 2 +- docs/en/api-guides/wifi-driver/overview.rst | 10 +++++----- docs/en/migration-guides/release-6.x/6.0/wifi.rst | 2 ++ docs/zh_CN/api-guides/wifi-driver/overview.rst | 10 +++++----- docs/zh_CN/migration-guides/release-6.x/6.0/wifi.rst | 2 ++ examples/wifi/ftm/main/ftm_main.c | 8 ++++---- examples/wifi/iperf/main/idf_component.yml | 2 +- examples/wifi/itwt/main/itwt_main.c | 6 +++--- tools/idf_py_actions/hints.yml | 8 ++++++++ 11 files changed, 37 insertions(+), 27 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 2a15b9506c..9152c68d27 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -730,8 +730,8 @@ esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); /** * @brief Set the bandwidth of specified interface * - * @attention 1. WIFI_BW_HT40 is supported only when the interface support 11N - * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW_HT20. + * @attention 1. WIFI_BW40 is supported only when the interface support 11N + * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW20. * @attention 3. Can not set WiFi bandwidth under band mode 2.4G + 5G (WIFI_BAND_MODE_AUTO), you can use esp_wifi_set_bandwidths instead * @attention 4. API return ESP_ERR_NOT_SUPPORTED if the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * @@ -1740,8 +1740,8 @@ esp_err_t esp_wifi_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protoco /** * @brief Set the bandwidth of specified interface and specified band * - * @attention 1. WIFI_BW_HT40 is supported only when the interface support 11N - * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW_HT20. + * @attention 1. WIFI_BW40 is supported only when the interface support 11N + * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW20. * @attention 3. When the WiFi band mode is set to 2.4G only, it will not set 5G bandwidth * @attention 4. When the WiFi band mode is set to 5G only, it will not set 2.4G bandwidth * diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index f5694c19cf..15a978cc1c 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -276,10 +276,8 @@ typedef enum { * @brief Wi-Fi bandwidth type */ typedef enum { - WIFI_BW_HT20 = 1, /**< Bandwidth is HT20 */ - WIFI_BW20 = WIFI_BW_HT20, /**< Bandwidth is 20 MHz */ - WIFI_BW_HT40 = 2, /**< Bandwidth is HT40 */ - WIFI_BW40 = WIFI_BW_HT40, /**< Bandwidth is 40 MHz */ + WIFI_BW20 = 1, /**< Bandwidth is 20 MHz */ + WIFI_BW40 = 2, /**< Bandwidth is 40 MHz */ WIFI_BW80 = 3, /**< Bandwidth is 80 MHz */ WIFI_BW160 = 4, /**< Bandwidth is 160 MHz */ WIFI_BW80_BW80 = 5, /**< Bandwidth is 80 + 80 MHz */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 13cacb91df..d4479387a6 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 13cacb91dfbbc0332498c7f6f0eabb0b801d328b +Subproject commit d4479387a667f106a6b5442d5d2b4a5c50fba5e6 diff --git a/docs/en/api-guides/wifi-driver/overview.rst b/docs/en/api-guides/wifi-driver/overview.rst index 14ed5e01a5..e3fba0d2ff 100644 --- a/docs/en/api-guides/wifi-driver/overview.rst +++ b/docs/en/api-guides/wifi-driver/overview.rst @@ -723,7 +723,7 @@ Wi-Fi Bandwidth Mode esp_wifi_set_protocol(WIFI_IF_STA, protocol); // Set STA interface bandwidth to 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. only:: esp32c6 @@ -748,7 +748,7 @@ Wi-Fi Bandwidth Mode esp_wifi_set_protocol(WIFI_IF_STA, protocol); // Set bandwidth of station to 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. only:: esp32c5 @@ -777,8 +777,8 @@ Wi-Fi Bandwidth Mode // Set bandwidth to 20 MHz for 2.4 GHz band and 40 MHz for 5 GHz band wifi_bandwidths_t bw = { - .ghz_2g = WIFI_BW_HT20, - .ghz_5g = WIFI_BW_HT40 + .ghz_2g = WIFI_BW20, + .ghz_5g = WIFI_BW40 }; esp_wifi_set_bandwidths(WIFI_IF_STA, &bw); @@ -801,7 +801,7 @@ Wi-Fi Bandwidth Mode esp_wifi_set_protocol(WIFI_IF_STA, protocol); // Set bandwidth of the station interface to 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. note:: diff --git a/docs/en/migration-guides/release-6.x/6.0/wifi.rst b/docs/en/migration-guides/release-6.x/6.0/wifi.rst index 1cdb5d2ec6..9763214135 100644 --- a/docs/en/migration-guides/release-6.x/6.0/wifi.rst +++ b/docs/en/migration-guides/release-6.x/6.0/wifi.rst @@ -37,6 +37,8 @@ Removed Variables, Macros and Enum Values - **FTM:** Field ``use_get_report_api`` from structure ``wifi_ftm_initiator_cfg_t`` and field ``ftm_report_data`` from structure ``wifi_event_ftm_report_t`` has been removed. Please use ``esp_wifi_ftm_get_report`` to fetch raw FTM report data instead. +- **Wi-Fi Bandwidth:** The enum values ``WIFI_BW_HT20`` and ``WIFI_BW_HT40`` have been removed. Please use the enum values ``WIFI_BW20`` and ``WIFI_BW40`` directly. + Modified Functions and Types ---------------------------- diff --git a/docs/zh_CN/api-guides/wifi-driver/overview.rst b/docs/zh_CN/api-guides/wifi-driver/overview.rst index c81a776cfa..1d13b5af76 100644 --- a/docs/zh_CN/api-guides/wifi-driver/overview.rst +++ b/docs/zh_CN/api-guides/wifi-driver/overview.rst @@ -723,7 +723,7 @@ Wi-Fi 带宽模式 esp_wifi_set_protocol(WIFI_IF_STA, protocol); // 设置 STA 的带宽为 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. only:: esp32c6 @@ -748,7 +748,7 @@ Wi-Fi 带宽模式 esp_wifi_set_protocol(WIFI_IF_STA, protocol); // 设置 STA 的带宽为 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. only:: esp32c5 @@ -777,8 +777,8 @@ Wi-Fi 带宽模式 // 设置 2.4 GHz 带宽为 20 MHz,5 GHz 带宽为 40 MHz wifi_bandwidths_t bw = { - .ghz_2g = WIFI_BW_HT20, - .ghz_5g = WIFI_BW_HT40 + .ghz_2g = WIFI_BW20, + .ghz_5g = WIFI_BW40 }; esp_wifi_set_bandwidths(WIFI_IF_STA, &bw); @@ -801,7 +801,7 @@ Wi-Fi 带宽模式 esp_wifi_set_protocol(WIFI_IF_STA, protocol); // 设置 STA 的带宽为 40 MHz - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT40); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW40); .. note:: diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/wifi.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/wifi.rst index c1547b1af6..cd7fef2ac4 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/wifi.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/wifi.rst @@ -37,6 +37,8 @@ Wi-Fi - **FTM:** 结构体 ``wifi_ftm_initiator_cfg_t`` 中的字段 ``use_get_report_api`` 和结构体 ``wifi_event_ftm_report_t`` 中的字段 ``ftm_report_data`` 已被移除。请改用 ``esp_wifi_ftm_get_report`` 获取原始 FTM 报告数据。 +- **Wi-Fi 接口宏:** 枚举值 ``WIFI_BW_HT20`` 和 ``WIFI_BW_HT40`` 已被移除。请直接使用枚举值 ``WIFI_BW20`` 和 ``WIFI_BW40``。 + 已修改的函数和类型 ------------------ diff --git a/examples/wifi/ftm/main/ftm_main.c b/examples/wifi/ftm/main/ftm_main.c index 9f6b1c0ee2..b7797a07bb 100644 --- a/examples/wifi/ftm/main/ftm_main.c +++ b/examples/wifi/ftm/main/ftm_main.c @@ -437,10 +437,10 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, proto.ghz_2g = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N; proto.ghz_5g = 0; esp_wifi_set_protocols(WIFI_IF_AP, &proto); - bws.ghz_2g = WIFI_BW_HT40; + bws.ghz_2g = WIFI_BW40; esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } else { - bws.ghz_2g = WIFI_BW_HT20; + bws.ghz_2g = WIFI_BW20; esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } } else { @@ -449,13 +449,13 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, proto.ghz_2g = 0; proto.ghz_5g = WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11A; esp_wifi_set_protocols(WIFI_IF_AP, &proto); - bws.ghz_5g=WIFI_BW_HT40; + bws.ghz_5g=WIFI_BW40; esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } else { proto.ghz_2g = 0; proto.ghz_5g = WIFI_PROTOCOL_11AC | WIFI_PROTOCOL_11A | WIFI_PROTOCOL_11AX; esp_wifi_set_protocols(WIFI_IF_AP, &proto); - bws.ghz_5g = WIFI_BW_HT20; + bws.ghz_5g = WIFI_BW20; esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } #endif diff --git a/examples/wifi/iperf/main/idf_component.yml b/examples/wifi/iperf/main/idf_component.yml index 95a1010aa7..35dc881596 100644 --- a/examples/wifi/iperf/main/idf_component.yml +++ b/examples/wifi/iperf/main/idf_component.yml @@ -4,7 +4,7 @@ dependencies: espressif/iperf-cmd: version: "~0.1.3" esp-qa/wifi-cmd: - version: "~0.2.0" + version: "~0.2.7" esp-qa/ping-cmd: version: "~1.0.0" espressif/esp_wifi_remote: diff --git a/examples/wifi/itwt/main/itwt_main.c b/examples/wifi/itwt/main/itwt_main.c index ec1bdc29e4..ae4914067c 100644 --- a/examples/wifi/itwt/main/itwt_main.c +++ b/examples/wifi/itwt/main/itwt_main.c @@ -277,8 +277,8 @@ static void wifi_itwt(void) ESP_ERROR_CHECK(esp_wifi_sta_twt_config(&wifi_twt_config)); #if CONFIG_SOC_WIFI_SUPPORT_5G wifi_bandwidths_t bw = { - .ghz_2g = WIFI_BW_HT20, - .ghz_5g = WIFI_BW_HT20, + .ghz_2g = WIFI_BW20, + .ghz_5g = WIFI_BW20, }; esp_wifi_set_bandwidths(WIFI_IF_STA, &bw); @@ -288,7 +288,7 @@ static void wifi_itwt(void) }; esp_wifi_set_protocols(WIFI_IF_STA, &protocol); #else - esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT20); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW20); esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11AX); #endif esp_wifi_set_ps(WIFI_PS_MIN_MODEM); diff --git a/tools/idf_py_actions/hints.yml b/tools/idf_py_actions/hints.yml index 99c8681b44..e2cbbe5d50 100644 --- a/tools/idf_py_actions/hints.yml +++ b/tools/idf_py_actions/hints.yml @@ -749,3 +749,11 @@ - re: "error: 'MALLOC_CAP_EXEC' undeclared \\(first use in this function\\)" hint: "MALLOC_CAP_EXEC capability cannot be used if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT or CONFIG_ESP_SYSTEM_MEMPROT_FEATURE is enabled. \nFor further information about those configurations, run 'idf.py docs -sp api-reference/kconfig-reference.html#memory-protection'" + +- + re: "error: 'WIFI_BW_HT20' undeclared \\(first use in this function\\)" + hint: "The enum value 'WIFI_BW_HT20' has been removed. Use 'WIFI_BW20' instead." + +- + re: "error: 'WIFI_BW_HT40' undeclared \\(first use in this function\\)" + hint: "The enum value 'WIFI_BW_HT40' has been removed. Use 'WIFI_BW40' instead."