Merge branch 'refactor/remove_redundant_var_related_to_bandwidth' into 'master'

refactor(wifi): remove enum values WIFI_BW_HT20 and WIFI_BW_HT40

See merge request espressif/esp-idf!43152
This commit is contained in:
Jiang Jiang Jian
2025-12-25 12:01:37 +08:00
11 changed files with 37 additions and 27 deletions

View File

@@ -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
*

View File

@@ -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 */

View File

@@ -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::

View File

@@ -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
----------------------------

View File

@@ -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 MHz5 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::

View File

@@ -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``
已修改的函数和类型
------------------

View File

@@ -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

View File

@@ -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:

View File

@@ -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);

View File

@@ -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."