From a481b6c78d5d2389e159b9a25ce1596a1e6f2ab2 Mon Sep 17 00:00:00 2001 From: xuxiao Date: Thu, 18 Jul 2024 16:02:13 +0800 Subject: [PATCH] fix(wifi): fix code comments --- components/esp_wifi/include/esp_wifi.h | 42 +++++++++++-------- components/esp_wifi/include/esp_wifi_he.h | 5 +-- .../esp_wifi/include/esp_wifi_types_generic.h | 30 +++++++++---- .../mqtt/custom_outbox/sdkconfig.defaults | 1 + examples/provisioning/.build-test-rules.yml | 1 - examples/provisioning/wifi_prov_mgr/README.md | 4 +- tools/test_apps/system/.build-test-rules.yml | 2 +- .../system/clang_build_test/README.md | 4 +- 8 files changed, 54 insertions(+), 35 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index a033b1a4bb..c5ce72e1fa 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -676,10 +676,12 @@ esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type); /** * @brief Set protocol type of specified interface * The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N). - * if CONFIG_SOC_WIFI_HE_SUPPORT, the default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AX). + * if CONFIG_SOC_WIFI_HE_SUPPORT and band is 2.4G, the default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AX). + * if CONFIG_SOC_WIFI_HE_SUPPORT and band is 5G, the default protocol is (WIFI_PROTOCOL_11A|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AC|WIFI_PROTOCOL_11AX). * * @attention 2.4G: Support 802.11b or 802.11bg or 802.11bgn or 802.11bgnax or LR mode - * @attention only support set band 2.4G protocol + * 5G: Support 802.11a or 802.11an or 802.11anac or 802.11anacax + * @attention can not set wifi protocol under band 2.4G + 5G mode * * @param ifx interfaces * @param protocol_bitmap WiFi protocol bitmap @@ -695,6 +697,8 @@ esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); /** * @brief Get the current protocol bitmap of the specified interface * + * @attention can not get wifi protocol under band 2.4G + 5G mode + * * @param ifx interface * @param[out] protocol_bitmap store current WiFi protocol bitmap of interface ifx * @@ -712,6 +716,7 @@ esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); * * @attention 1. API return false if try to configure an interface that is not enabled * @attention 2. WIFI_BW_HT40 is supported only when the interface support 11N + * @attention 3. can not get wifi bandwidth under band 2.4G + 5G mode * * @param ifx interface to be configured * @param bw bandwidth @@ -729,6 +734,7 @@ esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); * @brief Get the bandwidth of specified interface * * @attention 1. API return false if try to get a interface that is not enable + * @attention 2. can not get wifi bandwidth under band 2.4G + 5G mode * * @param ifx interface to be configured * @param[out] bw store bandwidth of interface ifx @@ -1625,6 +1631,18 @@ esp_err_t esp_wifi_set_band(wifi_band_t band); * - ESP_ERR_INVALID_ARG: invalid argument */ esp_err_t esp_wifi_get_band(wifi_band_t* band); + +/** + * @brief Get wifi current band. + * + * @param[in] band store the current band of wifi + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_INVALID_ARG: invalid argument + */ +esp_err_t esp_wifi_get_current_band(wifi_band_t* band); #endif /* SOC_WIFI_HE_SUPPORT_5G */ #if CONFIG_ESP_COEX_POWER_MANAGEMENT @@ -1643,15 +1661,8 @@ esp_err_t esp_wifi_coex_pwr_configure(bool enabled); #endif /** - * @brief Set protocol type of specified interface and specified band - * The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N). - * if CONFIG_SOC_WIFI_HE_SUPPORT and band is 2.4G, the default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AX). - * if CONFIG_SOC_WIFI_HE_SUPPORT and band is 5G, the default protocol is (WIFI_PROTOCOL_11A|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AC|WIFI_PROTOCOL_11AX). + * @brief Set the supported WiFi protocols for the specified interface. * - * @attention 2.4G: Support 802.11b or 802.11bg or 802.11bgn or 802.11bgnax or LR mode - * 5G: Support 802.11a or 802.11an or 802.11anac or 802.11anacax - * - * @param band wifi band 2.4G / 5G * @param ifx interfaces * @param bitmap WiFi protocol bitmap * @@ -1661,12 +1672,11 @@ esp_err_t esp_wifi_coex_pwr_configure(bool enabled); * - ESP_ERR_WIFI_IF: invalid interface * - others: refer to error codes in esp_err.h */ -esp_err_t esp_wifi_band_set_protocol(wifi_band_t band, wifi_interface_t ifx, uint32_t bitmap); +esp_err_t esp_wifi_set_protocols(wifi_interface_t ifx, wifi_protocol_bitmap_t *bitmap); /** * @brief Get the current protocol bitmap of the specified interface and specified band * - * @param band wifi band 2.4G / 5G * @param ifx interface * @param[out] bitmap store current WiFi protocol bitmap of interface ifx * @@ -1677,7 +1687,7 @@ esp_err_t esp_wifi_band_set_protocol(wifi_band_t band, wifi_interface_t ifx, uin * - ESP_ERR_INVALID_ARG: invalid argument * - others: refer to error codes in esp_err.h */ -esp_err_t esp_wifi_band_get_protocol(wifi_band_t band, wifi_interface_t ifx, uint32_t *bitmap); +esp_err_t esp_wifi_get_protocols(wifi_interface_t ifx, wifi_protocol_bitmap_t *bitmap); /** * @brief Set the bandwidth of specified interface and specified band @@ -1685,7 +1695,6 @@ esp_err_t esp_wifi_band_get_protocol(wifi_band_t band, wifi_interface_t ifx, uin * @attention 1. API return false if try to configure an interface that is not enabled * @attention 2. WIFI_BW_HT40 is supported only when the interface support 11N * - * @param band wifi band 2.4G / 5G * @param ifx interface to be configured * @param bw bandwidth * @@ -1696,14 +1705,13 @@ esp_err_t esp_wifi_band_get_protocol(wifi_band_t band, wifi_interface_t ifx, uin * - ESP_ERR_INVALID_ARG: invalid argument * - others: refer to error codes in esp_err.h */ -esp_err_t esp_wifi_band_set_bandwidth(wifi_band_t band, wifi_interface_t ifx, wifi_bandwidth_t bw); +esp_err_t esp_wifi_set_bandwidths(wifi_interface_t ifx, wifi_band_bw_t* bw); /** * @brief Get the bandwidth of specified interface and specified band * * @attention 1. API return false if try to get a interface that is not enable * - * @param band wifi band 2.4G / 5G * @param ifx interface to be configured * @param[out] bw store bandwidth of interface ifx * @@ -1713,7 +1721,7 @@ esp_err_t esp_wifi_band_set_bandwidth(wifi_band_t band, wifi_interface_t ifx, wi * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument */ -esp_err_t esp_wifi_band_get_bandwidth(wifi_band_t band, wifi_interface_t ifx, wifi_bandwidth_t *bw); +esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_band_bw_t *bw); #ifdef __cplusplus } diff --git a/components/esp_wifi/include/esp_wifi_he.h b/components/esp_wifi/include/esp_wifi_he.h index d7a8a4079d..bea400ae6e 100644 --- a/components/esp_wifi/include/esp_wifi_he.h +++ b/components/esp_wifi/include/esp_wifi_he.h @@ -151,7 +151,7 @@ esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats); * @attention Support at most 32 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned. * Support sleep time up to (1 << 35) us. * - * @param[in,out] setup_config pointer to btwt setup config structure. + * @param[in,out] config pointer to btwt setup config structure. * * @return * - ESP_OK: succeed @@ -196,8 +196,7 @@ esp_err_t esp_wifi_sta_get_btwt_num(uint8_t *btwt_number); /** * @brief Get broadcast TWT information * - * @param[inout] btwt_number As input param, it stores max btwt number AP supported. - * As output param, it receives the actual btwt numbers AP supported. + * @param[in] btwt_number As input param, it stores max btwt number AP supported. * @param[in] btwt_info array to hold the btwt information supported by AP * * @return diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index b9069f409e..5b8e14403a 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -291,6 +291,13 @@ typedef enum { 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; +/** Argument structure for wifi band */ +typedef enum { + WIFI_BAND_2G = 1, /* Band is 2.4G */ + WIFI_BAND_5G = 2, /* Band is 5G */ + WIFI_BAND_2G_5G = 3, /* Band is 2,4G + 5G */ +} wifi_band_t; + #define WIFI_PROTOCOL_11B 0x1 #define WIFI_PROTOCOL_11G 0x2 #define WIFI_PROTOCOL_11N 0x4 @@ -299,6 +306,12 @@ typedef enum { #define WIFI_PROTOCOL_11AC 0x20 #define WIFI_PROTOCOL_11AX 0x40 +/** @brief Description of a WiFi protocol bitmap */ +typedef struct { + int ghz_2g_protocol; /**< Represents 2.4 GHz protocol bitmap */ + int ghz_5g_protocol; /**< Represents 5 GHz protocol bitmap */ +} wifi_protocol_bitmap_t; + typedef enum { WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */ WIFI_BW20 = WIFI_BW_HT20, /* Bandwidth is 20 MHz */ @@ -309,6 +322,12 @@ typedef enum { WIFI_BW80_BW80 = 5, /* Bandwidth is 80+80 MHz */ } wifi_bandwidth_t; +/** @brief Description of a WiFi band bandwidths */ +typedef struct { + wifi_bandwidth_t ghz_2g; /* Represents 2.4 GHz bandwidth */ + wifi_bandwidth_t ghz_5g; /* Represents 5 GHz bandwidth */ +} wifi_band_bw_t; + /** Configuration structure for Protected Management Frame */ typedef struct { bool capable; /**< Deprecated variable. Device will always connect in PMF mode if other device also advertises PMF capability. */ @@ -335,7 +354,7 @@ 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 */ + uint8_t channel; /**< 2G 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 */ @@ -357,7 +376,7 @@ typedef struct { 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.*/ + uint8_t channel; /**< channel of target AP. For 2G AP, set to 1~13 to scan starting from the specified channel before connecting to AP. For 5G AP, set to 36~177 (36, 40, 44 ... 177) 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. */ @@ -1068,13 +1087,6 @@ typedef struct { uint16_t report_len; /**< Length of the report*/ } wifi_event_neighbor_report_t; -/** Argument structure for wifi band */ -typedef enum { - WIFI_BAND_2G = 1, /* Band is 2.4G */ - WIFI_BAND_5G = 2, /* Band is 5G */ - WIFI_BAND_2G_5G = 3, /* Band is 2,4G + 5G */ -} wifi_band_t; - #ifdef __cplusplus } #endif diff --git a/examples/protocols/mqtt/custom_outbox/sdkconfig.defaults b/examples/protocols/mqtt/custom_outbox/sdkconfig.defaults index 385da31baf..11f90ceacf 100644 --- a/examples/protocols/mqtt/custom_outbox/sdkconfig.defaults +++ b/examples/protocols/mqtt/custom_outbox/sdkconfig.defaults @@ -1,2 +1,3 @@ CONFIG_MQTT_CUSTOM_OUTBOX=y CONFIG_COMPILER_CXX_EXCEPTIONS=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/provisioning/.build-test-rules.yml b/examples/provisioning/.build-test-rules.yml index 5c3aa40a22..550cd82588 100644 --- a/examples/provisioning/.build-test-rules.yml +++ b/examples/provisioning/.build-test-rules.yml @@ -3,7 +3,6 @@ examples/provisioning/wifi_prov_mgr: disable: - if: SOC_WIFI_SUPPORTED != 1 - - if: SOC_BT_SUPPORTED != 1 disable_test: - if: IDF_TARGET != "esp32" temporary: true diff --git a/examples/provisioning/wifi_prov_mgr/README.md b/examples/provisioning/wifi_prov_mgr/README.md index 56ac5b6cbd..7648e58670 100644 --- a/examples/provisioning/wifi_prov_mgr/README.md +++ b/examples/provisioning/wifi_prov_mgr/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | # Wi-Fi Provisioning Manager Example diff --git a/tools/test_apps/system/.build-test-rules.yml b/tools/test_apps/system/.build-test-rules.yml index 83cb588244..b11db03fab 100644 --- a/tools/test_apps/system/.build-test-rules.yml +++ b/tools/test_apps/system/.build-test-rules.yml @@ -13,7 +13,7 @@ tools/test_apps/system/build_test: tools/test_apps/system/clang_build_test: enable: - - if: IDF_TARGET in ["esp32", "esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"] + - if: IDF_TARGET in ["esp32", "esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"] temporary: true reason: the other targets are not supported yet diff --git a/tools/test_apps/system/clang_build_test/README.md b/tools/test_apps/system/clang_build_test/README.md index 5b165ee322..c410436a3a 100644 --- a/tools/test_apps/system/clang_build_test/README.md +++ b/tools/test_apps/system/clang_build_test/README.md @@ -1,4 +1,4 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | This project is for testing if the application can be built with Clang toolchain.