From baeed9fb6a30293c9ee0ce1961b952488bd18601 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 17 Oct 2023 17:55:54 +0800 Subject: [PATCH 01/15] fix(wifi): update scan example for scan get ap records --- examples/wifi/scan/main/scan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/wifi/scan/main/scan.c b/examples/wifi/scan/main/scan.c index 1067bdd32a5..5dcf9efe08f 100644 --- a/examples/wifi/scan/main/scan.c +++ b/examples/wifi/scan/main/scan.c @@ -152,10 +152,11 @@ static void wifi_scan(void) ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_start()); esp_wifi_scan_start(NULL, true); + ESP_LOGI(TAG, "Max AP number ap_info can hold = %u", number); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info)); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count)); - ESP_LOGI(TAG, "Total APs scanned = %u", ap_count); - for (int i = 0; (i < DEFAULT_SCAN_LIST_SIZE) && (i < ap_count); i++) { + ESP_LOGI(TAG, "Total APs scanned = %u, actual AP number ap_info holds = %u", ap_count, number); + for (int i = 0; i < number; i++) { ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid); ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi); print_auth_mode(ap_info[i].authmode); From e321e8b6406b211d062c877e39be98886bb88c46 Mon Sep 17 00:00:00 2001 From: xuxiao Date: Mon, 23 Oct 2023 13:49:36 +0800 Subject: [PATCH 02/15] fix(wifi): fix esp32c6 rxctrl info is not correct --- components/esp_wifi/include/esp_now.h | 1 + components/esp_wifi/include/esp_wifi_he_types.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 728c69ba5e5..3e8e8e299d3 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -97,6 +97,7 @@ 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; /** diff --git a/components/esp_wifi/include/esp_wifi_he_types.h b/components/esp_wifi/include/esp_wifi_he_types.h index 01f753dddb1..507367e53a3 100644 --- a/components/esp_wifi/include/esp_wifi_he_types.h +++ b/components/esp_wifi/include/esp_wifi_he_types.h @@ -157,7 +157,7 @@ typedef struct { unsigned : 15; /**< reserved */ unsigned : 15; /**< reserved */ unsigned : 2; /**< reserved */ - unsigned noise_floor : 8; /**< the noise floor of the reception frame */ + signed noise_floor : 8; /**< the noise floor of the reception frame */ unsigned channel : 4; /**< the primary channel */ unsigned second : 4; /**< the second channel if in HT40 */ unsigned : 8; /**< reserved */ From 5960284022e837346e1f6e62757189ba3e989052 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 4 Apr 2023 11:59:30 +0800 Subject: [PATCH 03/15] esp_supplicant: remove wpa supplicant ROM source code copyrights --- docs/en/COPYRIGHT.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/en/COPYRIGHT.rst b/docs/en/COPYRIGHT.rst index 38c14897ca3..321ef13e971 100644 --- a/docs/en/COPYRIGHT.rst +++ b/docs/en/COPYRIGHT.rst @@ -85,8 +85,6 @@ ESP32, ESP32-S and ESP32-C Series SoCs mask ROM hardware includes binaries compi * miniz_, by Rich Geldreich - placed into the public domain. -* `wpa_supplicant`_ Copyright (c) 2003-2022 Jouni Malinen and contributors and licensed under the BSD license. - * TJpgDec_ Copyright (C) 2011, ChaN, all right reserved. See below for license. .. only:: CONFIG_ESP_ROM_HAS_MBEDTLS_CRYPTO_LIB From 7b3cee0dd8a6fb619a22936eeff230d603ccca1d Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 1 Aug 2023 14:37:58 +0800 Subject: [PATCH 04/15] update(esp_coexist): update esp coexist header file --- components/esp_coex/esp32/esp_coex_adapter.c | 2 +- components/esp_coex/esp32c2/esp_coex_adapter.c | 2 +- components/esp_coex/esp32c3/esp_coex_adapter.c | 2 +- components/esp_coex/esp32c6/esp_coex_adapter.c | 2 +- components/esp_coex/esp32h2/esp_coex_adapter.c | 2 +- components/esp_coex/esp32s2/esp_coex_adapter.c | 2 +- components/esp_coex/esp32s3/esp_coex_adapter.c | 2 +- components/esp_coex/include/esp_coexist_internal.h | 2 +- .../esp_coex/include/{ => private}/esp_coexist_adapter.h | 0 components/esp_coex/test_md5/test_md5.sh | 2 +- components/esp_wifi/include/esp_wifi_ap_get_sta_list.h | 4 ---- docs/doxygen/Doxyfile | 3 +++ tools/ci/check_public_headers_exceptions.txt | 2 +- 13 files changed, 13 insertions(+), 14 deletions(-) rename components/esp_coex/include/{ => private}/esp_coexist_adapter.h (100%) diff --git a/components/esp_coex/esp32/esp_coex_adapter.c b/components/esp_coex/esp32/esp_coex_adapter.c index a120e11d538..d3b297036da 100644 --- a/components/esp_coex/esp32/esp_coex_adapter.c +++ b/components/esp_coex/esp32/esp_coex_adapter.c @@ -18,7 +18,7 @@ #include "freertos/portmacro.h" #include "esp_heap_caps.h" #include "esp_timer.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32/rom/ets_sys.h" #define TAG "esp_coex_adapter" diff --git a/components/esp_coex/esp32c2/esp_coex_adapter.c b/components/esp_coex/esp32c2/esp_coex_adapter.c index 84adc6f088c..25805bc7ed1 100644 --- a/components/esp_coex/esp32c2/esp_coex_adapter.c +++ b/components/esp_coex/esp32c2/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32c2/rom/ets_sys.h" #define TAG "esp_coex_adapter" diff --git a/components/esp_coex/esp32c3/esp_coex_adapter.c b/components/esp_coex/esp32c3/esp_coex_adapter.c index 005b858f4b4..9dd290e5afd 100644 --- a/components/esp_coex/esp32c3/esp_coex_adapter.c +++ b/components/esp_coex/esp32c3/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32c3/rom/ets_sys.h" #include "soc/system_reg.h" diff --git a/components/esp_coex/esp32c6/esp_coex_adapter.c b/components/esp_coex/esp32c6/esp_coex_adapter.c index e792c0ebad3..1fde5726f86 100644 --- a/components/esp_coex/esp32c6/esp_coex_adapter.c +++ b/components/esp_coex/esp32c6/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32c6/rom/ets_sys.h" #define TAG "esp_coex_adapter" diff --git a/components/esp_coex/esp32h2/esp_coex_adapter.c b/components/esp_coex/esp32h2/esp_coex_adapter.c index 630d4745add..6cdfdd9bd99 100644 --- a/components/esp_coex/esp32h2/esp_coex_adapter.c +++ b/components/esp_coex/esp32h2/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32c6/rom/ets_sys.h" #define TAG "esp_coex_adapter" diff --git a/components/esp_coex/esp32s2/esp_coex_adapter.c b/components/esp_coex/esp32s2/esp_coex_adapter.c index 9100bfabe0e..c8d50258bfa 100644 --- a/components/esp_coex/esp32s2/esp_coex_adapter.c +++ b/components/esp_coex/esp32s2/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32s2/rom/ets_sys.h" #define TAG "esp_coex_adapter" diff --git a/components/esp_coex/esp32s3/esp_coex_adapter.c b/components/esp_coex/esp32s3/esp_coex_adapter.c index bf277eb7898..6aa42b1a98a 100644 --- a/components/esp_coex/esp32s3/esp_coex_adapter.c +++ b/components/esp_coex/esp32s3/esp_coex_adapter.c @@ -20,7 +20,7 @@ #include "esp_timer.h" #include "soc/rtc.h" #include "esp_private/esp_clk.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #include "esp32s3/rom/ets_sys.h" #include "soc/system_reg.h" diff --git a/components/esp_coex/include/esp_coexist_internal.h b/components/esp_coex/include/esp_coexist_internal.h index b8c8992d327..b7c45affa15 100644 --- a/components/esp_coex/include/esp_coexist_internal.h +++ b/components/esp_coex/include/esp_coexist_internal.h @@ -9,7 +9,7 @@ #include #include "esp_coexist.h" -#include "esp_coexist_adapter.h" +#include "private/esp_coexist_adapter.h" #ifdef __cplusplus extern "C" { diff --git a/components/esp_coex/include/esp_coexist_adapter.h b/components/esp_coex/include/private/esp_coexist_adapter.h similarity index 100% rename from components/esp_coex/include/esp_coexist_adapter.h rename to components/esp_coex/include/private/esp_coexist_adapter.h diff --git a/components/esp_coex/test_md5/test_md5.sh b/components/esp_coex/test_md5/test_md5.sh index 0b62e8e3e6c..65a32ebb49c 100755 --- a/components/esp_coex/test_md5/test_md5.sh +++ b/components/esp_coex/test_md5/test_md5.sh @@ -58,7 +58,7 @@ function check_md5() } echo "Checking libraries for target ${IDF_TARGET}..." -check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 +check_md5 ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5 case $IDF_TARGET in esp32c6|esp32h2) diff --git a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h index c804ad15366..3b21ad8d9be 100644 --- a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h +++ b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h @@ -38,10 +38,6 @@ typedef struct { */ esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list); -/** - * @} - */ - #ifdef __cplusplus } #endif diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 3202f77804b..aa94c838e90 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -27,6 +27,9 @@ INPUT = \ $(PROJECT_PATH)/components/bootloader_support/include/bootloader_random.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_app_format.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_flash_encrypt.h \ + $(PROJECT_PATH)/components/esp_coex/include/esp_coexist_internal.h \ + $(PROJECT_PATH)/components/esp_coex/include/esp_coexist.h \ + $(PROJECT_PATH)/components/esp_coex/include/esp_modem_wrapper.h \ $(PROJECT_PATH)/components/bt/common/api/include/api/esp_blufi_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h \ diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 25cbc39b67e..86b2eaa2d09 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -98,7 +98,7 @@ components/esp_hw_support/include/esp_private/esp_memprot_internal.h ### Here are the files that use CONFIG_XXX values but don't include sdkconfig.h # components/esp_wifi/include/esp_private/wifi_os_adapter.h -components/esp_coex/include/esp_coexist_adapter.h +components/esp_coex/include/private/esp_coexist_adapter.h components/esp_coex/include/esp_coex_i154.h ### To be fixed: headers that rely on implicit inclusion # From 7d5eaa8b79bdc44f9bfd197d20ca516cce52a7ba Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 1 Aug 2023 15:14:53 +0800 Subject: [PATCH 05/15] update(wifi): update esp_wifi_crypto_types.h --- .../esp_wifi/include/esp_wifi_crypto_types.h | 242 +++++++++--------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_crypto_types.h b/components/esp_wifi/include/esp_wifi_crypto_types.h index 9eded75a766..dfe44bec6f2 100644 --- a/components/esp_wifi/include/esp_wifi_crypto_types.h +++ b/components/esp_wifi/include/esp_wifi_crypto_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -129,11 +129,11 @@ typedef int (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const cha /** * @brief HMAC-MD5 over data buffer (RFC 2104)' * - * @key: Key for HMAC operations - * @key_len: Length of the key in bytes - * @data: Pointers to the data area - * @data_len: Length of the data area - * @mac: Buffer for the hash (16 bytes) + * @param key Key for HMAC operations + * @param key_len Length of the key in bytes + * @param data Pointers to the data area + * @param data_len Length of the data area + * @param mac Buffer for the hash (16 bytes) * Returns: 0 on success, -1 on failure */ typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, @@ -142,12 +142,12 @@ typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, co /** * @brief HMAC-MD5 over data vector (RFC 2104) * - * @key: Key for HMAC operations - * @key_len: Length of the key in bytes - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash (16 bytes) + * @param key Key for HMAC operations + * @param key_len Length of the key in bytes + * @param num_elem Number of elements in the data vector + * @param addr Pointers to the data areas + * @param len Lengths of the data blocks + * @param mac Buffer for the hash (16 bytes) * Returns: 0 on success, -1 on failure */ typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, @@ -156,11 +156,11 @@ typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_ /** * @brief HMAC-SHA1 over data buffer (RFC 2104) * - * @key: Key for HMAC operations - * @key_len: Length of the key in bytes - * @data: Pointers to the data area - * @data_len: Length of the data area - * @mac: Buffer for the hash (20 bytes) + * @param key Key for HMAC operations + * @param key_len Length of the key in bytes + * @param data Pointers to the data area + * @param data_len Length of the data area + * @param mac Buffer for the hash (20 bytes) * Returns: 0 on success, -1 of failure */ typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, @@ -169,12 +169,12 @@ typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, c /** * @brief HMAC-SHA1 over data vector (RFC 2104) * - * @key: Key for HMAC operations - * @key_len: Length of the key in bytes - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash (20 bytes) + * @param key Key for HMAC operations + * @param key_len Length of the key in bytes + * @param num_elem Number of elements in the data vector + * @param addr Pointers to the data areas + * @param len Lengths of the data blocks + * @param mac Buffer for the hash (20 bytes) * Returns: 0 on success, -1 on failure */ typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, @@ -183,13 +183,13 @@ typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key /** * @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) * - * @key: Key for PRF - * @key_len: Length of the key in bytes - * @label: A unique label for each purpose of the PRF - * @data: Extra data to bind into the key - * @data_len: Length of the data - * @buf: Buffer for the generated pseudo-random key - * @buf_len: Number of bytes of key to generate + * @param key Key for PRF + * @param key_len Length of the key in bytes + * @param label A unique label for each purpose of the PRF + * @param data Extra data to bind into the key + * @param data_len Length of the data + * @param buf Buffer for the generated pseudo-random key + * @param buf_len Number of bytes of key to generate * Returns: 0 on success, -1 of failure * * This function is used to derive new, cryptographically separate keys from a @@ -201,10 +201,10 @@ typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, co /** * @brief SHA-1 hash for data vector * - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash + * @param num_elem Number of elements in the data vector + * @param addr Pointers to the data areas + * @param len Lengths of the data blocks + * @param mac Buffer for the hash * Returns: 0 on success, -1 on failure */ typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, @@ -213,12 +213,12 @@ typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *add /** * @brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i * - * @passphrase: ASCII passphrase - * @ssid: SSID - * @ssid_len: SSID length in bytes - * @iterations: Number of iterations to run - * @buf: Buffer for the generated key - * @buflen: Length of the buffer in bytes + * @param passphrase ASCII passphrase + * @param ssid SSID + * @param ssid_len SSID length in bytes + * @param iterations Number of iterations to run + * @param buf Buffer for the generated key + * @param buflen Length of the buffer in bytes * Returns: 0 on success, -1 of failure * * This function is used to derive PSK for WPA-PSK. For this protocol, @@ -231,11 +231,11 @@ typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsig /** * @brief XOR RC4 stream to given data with skip-stream-start * - * @key: RC4 key - * @keylen: RC4 key length - * @skip: number of bytes to skip from the beginning of the RC4 stream - * @data: data to be XOR'ed with RC4 stream - * @data_len: buf length + * @param key RC4 key + * @param keylen RC4 key length + * @param skip number of bytes to skip from the beginning of the RC4 stream + * @param data data to be XOR'ed with RC4 stream + * @param data_len buf length * Returns: 0 on success, -1 on failure * * Generate RC4 pseudo random stream for the given key, skip beginning of the @@ -248,10 +248,10 @@ typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, uns /** * @brief MD5 hash for data vector * - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash + * @param num_elem Number of elements in the data vector + * @param addr Pointers to the data areas + * @param len Lengths of the data blocks + * @param mac Buffer for the hash * Returns: 0 on success, -1 on failure */ typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, @@ -260,17 +260,17 @@ typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr /** * @brief Encrypt one AES block * - * @ctx: Context pointer from aes_encrypt_init() - * @plain: Plaintext data to be encrypted (16 bytes) - * @crypt: Buffer for the encrypted data (16 bytes) + * @param ctx Context pointer from aes_encrypt_init() + * @param plain Plaintext data to be encrypted (16 bytes) + * @param crypt Buffer for the encrypted data (16 bytes) */ typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt); /** * @brief Initialize AES for encryption * - * @key: Encryption key - * @len: Key length in bytes (usually 16, i.e., 128 bits) + * @param key Encryption key + * @param len Key length in bytes (usually 16, i.e., 128 bits) * Returns: Pointer to context data or %NULL on failure */ typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len); @@ -278,24 +278,24 @@ typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int /** * @brief Deinitialize AES encryption * - * @ctx: Context pointer from aes_encrypt_init() + * @param ctx Context pointer from aes_encrypt_init() */ typedef void (*esp_aes_encrypt_deinit_t)(void *ctx); /** * @brief Decrypt one AES block * - * @ctx: Context pointer from aes_encrypt_init() - * @crypt: Encrypted data (16 bytes) - * @plain: Buffer for the decrypted data (16 bytes) + * @param ctx Context pointer from aes_encrypt_init() + * @param crypt Encrypted data (16 bytes) + * @param plain Buffer for the decrypted data (16 bytes) */ typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain); /** * @brief Initialize AES for decryption * - * @key: Decryption key - * @len: Key length in bytes (usually 16, i.e., 128 bits) + * @param key Decryption key + * @param len Key length in bytes (usually 16, i.e., 128 bits) * Returns: Pointer to context data or %NULL on failure */ typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len); @@ -303,17 +303,17 @@ typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int /** * @brief Deinitialize AES decryption * - * @ctx: Context pointer from aes_encrypt_init() + * @param ctx Context pointer from aes_encrypt_init() */ typedef void (*esp_aes_decrypt_deinit_t)(void *ctx); /** * @brief One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation * - * @key: 128-bit key for the hash operation - * @data: Data buffer for which a MIC is computed - * @data_len: Length of data buffer in bytes - * @mic: Buffer for MIC (128 bits, i.e., 16 bytes) + * @param key 128-bit key for the hash operation + * @param data Data buffer for which a MIC is computed + * @param data_len Length of data buffer in bytes + * @param mic Buffer for MIC (128 bits, i.e., 16 bytes) * Returns: 0 on success, -1 on failure */ typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size_t data_len, @@ -323,12 +323,12 @@ typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size * @brief Decrypt data using CCMP (Counter Mode CBC-MAC Protocol OR * Counter Mode Cipher Block Chaining Message Authentication * Code Protocol) which is used in IEEE 802.11i RSN standard. - * @tk: 128-bit Temporal Key for obtained during 4-way handshake - * @hdr: Pointer to IEEE802.11 frame headeri needed for AAD - * @data: Pointer to encrypted data buffer - * @data_len: Encrypted data length in bytes - * @decrypted_len: Length of decrypted data - * @espnow_pkt: Indicates if it's an ESPNOW packet + * @param tk 128-bit Temporal Key for obtained during 4-way handshake + * @param ieee80211_hdr Pointer to IEEE802.11 frame headeri needed for AAD + * @param data Pointer to encrypted data buffer + * @param data_len Encrypted data length in bytes + * @param decrypted_len Length of decrypted data + * @param espnow_pkt Indicates if it's an ESPNOW packet * Returns: Pointer to decrypted data on success, NULL on failure */ typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80211_hdr, @@ -339,13 +339,13 @@ typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80 * @brief Encrypt data using CCMP (Counter Mode CBC-MAC Protocol OR * Counter Mode Cipher Block Chaining Message Authentication * Code Protocol) which is used in IEEE 802.11i RSN standard. - * @tk: 128-bit Temporal Key for obtained during 4-way handshake - * @frame: Pointer to IEEE802.11 frame including header - * @len: Length of the frame including header - * @hdrlen: Length of the header - * @pn: Packet Number counter - * @keyid: Key ID to be mentioned in CCMP Vector - * @encrypted_len: Length of the encrypted frame including header + * @param tk 128-bit Temporal Key for obtained during 4-way handshake + * @param frame Pointer to IEEE802.11 frame including header + * @param len Length of the frame including header + * @param hdrlen Length of the header + * @param pn Packet Number counter + * @param keyid Key ID to be mentioned in CCMP Vector + * @param encrypted_len Length of the encrypted frame including header */ typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_t len, size_t hdrlen, uint8_t *pn, int keyid, size_t *encrypted_len); @@ -353,13 +353,13 @@ typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_ /** * @brief One-Key GMAC hash with AES for MIC computation * - * @key: key for the hash operation - * @keylen: key length - * @iv: initialization vector - * @iv_len: initialization vector length - * @aad: aad - * @aad_len: aad length - * @mic: Buffer for MIC (128 bits, i.e., 16 bytes) + * @param key key for the hash operation + * @param keylen key length + * @param iv initialization vector + * @param iv_len initialization vector length + * @param aad aad + * @param aad_len aad length + * @param mic Buffer for MIC (128 bits, i.e., 16 bytes) * Returns: 0 on success, -1 on failure */ typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t *iv, size_t iv_len, @@ -367,10 +367,10 @@ typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t * /** * @brief SHA256 hash for data vector - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash + * @param num_elem Number of elements in the data vector + * @param addr Pointers to the data areas + * @param len Lengths of the data blocks + * @param buf Buffer for the hash * Returns: 0 on success, -1 on failure */ typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *buf); @@ -378,9 +378,9 @@ typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const /** * @brief CRC32 value in little endian. * - * @param crc: Initial CRC value (result of last calculation or 0 for the first time) - * @param buf: Data buffer that used to calculate the CRC value - * @param len: Length of the data buffer + * @param crc Initial CRC value (result of last calculation or 0 for the first time) + * @param buf Data buffer that used to calculate the CRC value + * @param len Length of the data buffer * @return CRC32 value */ typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t len); @@ -391,35 +391,35 @@ typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t le * hardware. */ typedef struct { - uint32_t size; - uint32_t version; - esp_aes_wrap_t aes_wrap; /**< station connect function used when send EAPOL frame */ - esp_aes_unwrap_t aes_unwrap; /**< station connect function used when decrypt key data */ - esp_hmac_sha256_vector_t hmac_sha256_vector; /**< station connect function used when check MIC */ - esp_sha256_prf_t sha256_prf; /**< station connect function used when check MIC */ - esp_hmac_md5_t hmac_md5; - esp_hmac_md5_vector_t hamc_md5_vector; - esp_hmac_sha1_t hmac_sha1; - esp_hmac_sha1_vector_t hmac_sha1_vector; - esp_sha1_prf_t sha1_prf; - esp_sha1_vector_t sha1_vector; - esp_pbkdf2_sha1_t pbkdf2_sha1; - esp_rc4_skip_t rc4_skip; - esp_md5_vector_t md5_vector; - esp_aes_encrypt_t aes_encrypt; - esp_aes_encrypt_init_t aes_encrypt_init; - esp_aes_encrypt_deinit_t aes_encrypt_deinit; - esp_aes_decrypt_t aes_decrypt; - esp_aes_decrypt_init_t aes_decrypt_init; - esp_aes_decrypt_deinit_t aes_decrypt_deinit; - esp_aes_128_encrypt_t aes_128_encrypt; - esp_aes_128_decrypt_t aes_128_decrypt; - esp_omac1_aes_128_t omac1_aes_128; - esp_ccmp_decrypt_t ccmp_decrypt; - esp_ccmp_encrypt_t ccmp_encrypt; - esp_aes_gmac_t aes_gmac; - esp_sha256_vector_t sha256_vector; - esp_crc32_le_t crc32; + uint32_t size; /**< The crypto callback function structure size */ + uint32_t version; /**< The crypto callback function structure version */ + esp_aes_wrap_t aes_wrap; /**< The AES callback function when do STA connect */ + esp_aes_unwrap_t aes_unwrap; /**< The AES callback function when do STA connect */ + esp_hmac_sha256_vector_t hmac_sha256_vector; /**< The SHA256 callback function when do WPS connect */ + esp_sha256_prf_t sha256_prf; /**< The AES callback function when do STA connect */ + esp_hmac_md5_t hmac_md5; /**< HMAC-MD5 over data buffer (RFC 2104) */ + esp_hmac_md5_vector_t hamc_md5_vector; /**< HMAC-MD5 over data vector (RFC 2104) */ + esp_hmac_sha1_t hmac_sha1; /**< HMAC-SHA1 over data buffer (RFC 2104) */ + esp_hmac_sha1_vector_t hmac_sha1_vector; /**< HMAC-SHA1 over data vector (RFC 2104) */ + esp_sha1_prf_t sha1_prf; /**< SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) */ + esp_sha1_vector_t sha1_vector; /**< SHA-1 hash for data vector */ + esp_pbkdf2_sha1_t pbkdf2_sha1; /**< SHA1-based key derivation function (PBKDF2) for IEEE 802.11i */ + esp_rc4_skip_t rc4_skip; /**< XOR RC4 stream to given data with skip-stream-start */ + esp_md5_vector_t md5_vector; /**< MD5 hash for data vector */ + esp_aes_encrypt_t aes_encrypt; /**< Encrypt one AES block */ + esp_aes_encrypt_init_t aes_encrypt_init; /**< Initialize AES for encryption */ + esp_aes_encrypt_deinit_t aes_encrypt_deinit; /**< Deinitialize AES encryption */ + esp_aes_decrypt_t aes_decrypt; /**< Decrypt one AES block */ + esp_aes_decrypt_init_t aes_decrypt_init; /**< Initialize AES for decryption */ + esp_aes_decrypt_deinit_t aes_decrypt_deinit; /**< Deinitialize AES decryption */ + esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES callback function when do WPS connect */ + esp_aes_128_decrypt_t aes_128_decrypt; /**< The AES callback function when do WPS connect */ + esp_omac1_aes_128_t omac1_aes_128; /**< One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation */ + esp_ccmp_decrypt_t ccmp_decrypt; /**< Decrypt data using CCMP */ + esp_ccmp_encrypt_t ccmp_encrypt; /**< encrypt data using CCMP */ + esp_aes_gmac_t aes_gmac; /**< One-Key GMAC hash with AES for MIC computation */ + esp_sha256_vector_t sha256_vector; /**< SHA256 hash for data vector */ + esp_crc32_le_t crc32; /**< CRC32 value in little endian */ }wpa_crypto_funcs_t; /** From 0573c44f32f5447b25e5105d2dcfeef1c83f6cfe Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 1 Aug 2023 15:27:56 +0800 Subject: [PATCH 06/15] docs(esp_mesh): update esp_mesh_internal.h --- .../esp_coex/include/esp_coexist_internal.h | 3 +- .../esp_wifi/include/esp_mesh_internal.h | 65 ++++++++++++------- .../include/esp_wifi_ap_get_sta_list.h | 2 +- components/esp_wifi/include/esp_wifi_he.h | 2 +- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/components/esp_coex/include/esp_coexist_internal.h b/components/esp_coex/include/esp_coexist_internal.h index b7c45affa15..7aee0c05333 100644 --- a/components/esp_coex/include/esp_coexist_internal.h +++ b/components/esp_coex/include/esp_coexist_internal.h @@ -173,7 +173,6 @@ int coex_register_bt_cb(coex_func_cb_t callback); * @brief To acquire the spin-lock used in resetting Bluetooth baseband. * This function is only used to workaround ESP32 hardware issue. * - * @param callback: callback function registered to coexistence module * @return : value of the spinlock to be restored */ uint32_t coex_bb_reset_lock(void); @@ -268,7 +267,7 @@ void * coex_schm_curr_phase_get(void); /** * @brief Set current coexistence scheme phase index. * - * @param interval : Coexistence scheme phase index + * @param idx : Coexistence scheme phase index * @return : 0 - success, other - failed */ int coex_schm_curr_phase_idx_set(int idx); diff --git a/components/esp_wifi/include/esp_mesh_internal.h b/components/esp_wifi/include/esp_mesh_internal.h index ad54ce87038..371e1e60640 100644 --- a/components/esp_wifi/include/esp_mesh_internal.h +++ b/components/esp_wifi/include/esp_mesh_internal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,6 +25,9 @@ extern "C" { /******************************************************* * Structures *******************************************************/ +/** + * @brief Mesh attempts + */ typedef struct { int scan; /**< minimum scan times before being a root, default:10 */ int vote; /**< max vote times in self-healing, default:1000 */ @@ -33,20 +36,26 @@ typedef struct { int monitor_ie; /**< acceptable times of parent networking IE change before update its own networking IE. default:3 */ } mesh_attempts_t; +/** + * @brief Mesh switch parent + */ typedef struct { - int duration_ms; /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms, + int duration_ms; /**< parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms, device will search for a new parent. */ - int cnx_rssi; /* RSSI threshold for keeping a good connection with parent. + int cnx_rssi; /**< RSSI threshold for keeping a good connection with parent. If set a value greater than -120 dBm, a timer will be armed to monitor parent RSSI at a period time of duration_ms. */ - int select_rssi; /* RSSI threshold for parent selection. It should be a value greater than switch_rssi. */ - int switch_rssi; /* Disassociate with current parent and switch to a new parent when the RSSI is greater than this set threshold. */ - int backoff_rssi; /* RSSI threshold for connecting to the root */ + int select_rssi; /**< RSSI threshold for parent selection. It should be a value greater than switch_rssi. */ + int switch_rssi; /**< Disassociate with current parent and switch to a new parent when the RSSI is greater than this set threshold. */ + int backoff_rssi; /**< RSSI threshold for connecting to the root */ } mesh_switch_parent_t; +/** + * @brief Mesh rssi threshold + */ typedef struct { - int high; - int medium; - int low; + int high; /**< high rssi threshold */ + int medium; /**< medium rssi threshold */ + int low; /**< low rssi threshold */ } mesh_rssi_threshold_t; /** @@ -58,7 +67,7 @@ typedef struct { uint8_t len; /**< element length */ uint8_t oui[3]; /**< organization identifier */ /**< mesh networking IE content */ - uint8_t type; /** ESP defined IE type */ + uint8_t type; /**< ESP defined IE type */ uint8_t encrypted : 1; /**< whether mesh networking IE is encrypted */ uint8_t version : 7; /**< mesh networking IE version */ /**< content */ @@ -89,14 +98,20 @@ typedef struct { uint8_t toDS; /**< toDS state */ } __attribute__((packed)) mesh_assoc_t; +/** + * @brief Mesh chain layer + */ typedef struct { - uint16_t layer_cap; - uint16_t layer; + uint16_t layer_cap; /**< max layer */ + uint16_t layer; /**< current layer */ } mesh_chain_layer_t; +/** + * @brief Mesh chain assoc + */ typedef struct { - mesh_assoc_t tree; - mesh_chain_layer_t chain; + mesh_assoc_t tree; /**< tree top, mesh_assoc IE */ + mesh_chain_layer_t chain; /**< chain top, mesh_assoc IE*/ } __attribute__((packed)) mesh_chain_assoc_t; /* mesh max connections */ @@ -106,13 +121,13 @@ typedef struct { * @brief Mesh PS duties */ typedef struct { - uint8_t device; - uint8_t parent; + uint8_t device; /**< device power save duty*/ + uint8_t parent; /**< parent power save duty*/ struct { - bool used; - uint8_t duty; - uint8_t mac[6]; - } child[MESH_MAX_CONNECTIONS]; + bool used; /**< used */ + uint8_t duty; /**< duty */ + uint8_t mac[6]; /**< mac */ + } child[MESH_MAX_CONNECTIONS]; /**< child */ } esp_mesh_ps_duties_t; /******************************************************* @@ -121,7 +136,7 @@ typedef struct { /** * @brief Set mesh softAP beacon interval * - * @param[in] interval beacon interval (msecs) (100 msecs ~ 60000 msecs) + * @param[in] interval_ms beacon interval (msecs) (100 msecs ~ 60000 msecs) * * @return * - ESP_OK @@ -133,7 +148,7 @@ esp_err_t esp_mesh_set_beacon_interval(int interval_ms); /** * @brief Get mesh softAP beacon interval * - * @param[out] interval beacon interval (msecs) + * @param[out] interval_ms beacon interval (msecs) * * @return * - ESP_OK @@ -242,7 +257,7 @@ esp_err_t esp_mesh_print_rxQ_waiting(void); /** * @brief Set passive scan time * - * @param[in] interval_ms passive scan time (msecs) + * @param[in] time_ms passive scan time (msecs) * * @return * - ESP_OK @@ -283,7 +298,9 @@ esp_err_t esp_mesh_set_announce_interval(int short_ms, int long_ms); esp_err_t esp_mesh_get_announce_interval(int *short_ms, int *long_ms); /** - * @brief Get the running duties of device, parent and children + * @brief Get the running duties of device, parent and children + * + * @param[out] ps_duties ps duties * * @return * - ESP_OK diff --git a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h index 3b21ad8d9be..7a4d167b644 100644 --- a/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h +++ b/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h @@ -29,7 +29,7 @@ typedef struct { * @warning This API works only for the default Wi-Fi AP interface, i.e. esp-netif with key="WIFI_AP_DEF" * * @param[in] wifi_sta_list Wi-Fi station info list, returned from esp_wifi_ap_get_sta_list() - * @param[out] netif_sta_list IP layer station info list, corresponding to MAC addresses provided in wifi_sta_list + * @param[out] wifi_sta_ip_mac_list IP layer station info list, corresponding to MAC addresses provided in wifi_sta_list * * @return * - ESP_OK diff --git a/components/esp_wifi/include/esp_wifi_he.h b/components/esp_wifi/include/esp_wifi_he.h index a318d36d2b0..67880654ab4 100644 --- a/components/esp_wifi/include/esp_wifi_he.h +++ b/components/esp_wifi/include/esp_wifi_he.h @@ -25,7 +25,7 @@ extern "C" { * @attention Support at most 8 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 itwt setup config structure. + * @param[in,out] setup_config pointer to itwt setup config structure. * * @return * - ESP_OK: succeed From 13094f2216dc725ba714d87c51f4040e44726927 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Wed, 9 Aug 2023 17:41:27 +0800 Subject: [PATCH 07/15] change(wifi): update esp_coexist_internal.h and esp_modem_wrapper.h --- components/bt/controller/esp32/bt.c | 2 +- components/bt/controller/esp32c2/bt.c | 2 +- components/bt/controller/esp32c3/bt.c | 2 +- components/bt/controller/esp32c6/bt.c | 2 +- components/bt/controller/esp32h2/bt.c | 2 +- .../{ => private}/esp_coexist_internal.h | 0 .../include/{ => private}/esp_modem_wrapper.h | 0 components/esp_coex/src/coexist.c | 2 +- components/esp_system/startup.c | 2 +- components/esp_wifi/esp32/esp_adapter.c | 4 +- components/esp_wifi/esp32c2/esp_adapter.c | 4 +- components/esp_wifi/esp32c3/esp_adapter.c | 4 +- components/esp_wifi/esp32c6/esp_adapter.c | 4 +- components/esp_wifi/esp32s2/esp_adapter.c | 4 +- components/esp_wifi/esp32s3/esp_adapter.c | 4 +- .../esp_wifi/include/esp_wifi_crypto_types.h | 114 +++++++++--------- components/esp_wifi/src/wifi_init.c | 2 +- docs/doxygen/Doxyfile | 2 - 18 files changed, 77 insertions(+), 79 deletions(-) rename components/esp_coex/include/{ => private}/esp_coexist_internal.h (100%) rename components/esp_coex/include/{ => private}/esp_modem_wrapper.h (100%) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 30378b7eb7c..7b2b391a8cf 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -35,7 +35,7 @@ #include "soc/rtc.h" #include "soc/soc_memory_layout.h" #include "soc/dport_reg.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp_timer.h" #if !CONFIG_FREERTOS_UNICORE #include "esp_ipc.h" diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index a22ff39d25a..e06655269ea 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -24,7 +24,7 @@ #endif #if CONFIG_SW_COEXIST_ENABLE -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #endif #include "nimble/nimble_npl_os.h" diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index cc6037abab8..b9af3e36d41 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -34,7 +34,7 @@ #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" #include "soc/soc_memory_layout.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp_timer.h" #include "esp_sleep.h" #include "esp_rom_sys.h" diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index c0a15e7c6a3..c189f2c824a 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -24,7 +24,7 @@ #endif // ESP_PLATFORM #if CONFIG_SW_COEXIST_ENABLE -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #endif // CONFIG_SW_COEXIST_ENABLE #include "nimble/nimble_npl_os.h" diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 5cbce36508a..43a4ba0199e 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -24,7 +24,7 @@ #endif // ESP_PLATFORM #if CONFIG_SW_COEXIST_ENABLE -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #endif // CONFIG_SW_COEXIST_ENABLE #include "nimble/nimble_npl_os.h" diff --git a/components/esp_coex/include/esp_coexist_internal.h b/components/esp_coex/include/private/esp_coexist_internal.h similarity index 100% rename from components/esp_coex/include/esp_coexist_internal.h rename to components/esp_coex/include/private/esp_coexist_internal.h diff --git a/components/esp_coex/include/esp_modem_wrapper.h b/components/esp_coex/include/private/esp_modem_wrapper.h similarity index 100% rename from components/esp_coex/include/esp_modem_wrapper.h rename to components/esp_coex/include/private/esp_modem_wrapper.h diff --git a/components/esp_coex/src/coexist.c b/components/esp_coex/src/coexist.c index e11982b5d4b..e5d14779339 100644 --- a/components/esp_coex/src/coexist.c +++ b/components/esp_coex/src/coexist.c @@ -5,7 +5,7 @@ */ #include "esp_coexist.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #if CONFIG_EXTERNAL_COEX_ENABLE #include "esp_log.h" diff --git a/components/esp_system/startup.c b/components/esp_system/startup.c index f78433f9928..ccfdbea111c 100644 --- a/components/esp_system/startup.c +++ b/components/esp_system/startup.c @@ -38,7 +38,7 @@ /***********************************************/ // Headers for other components init functions #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #endif #if __has_include("esp_app_desc.h") diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 62d44c53bcd..a1d6914a877 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -39,11 +39,11 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "dport_access.h" #include "esp_rom_sys.h" #include "esp32/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #define TAG "esp_adapter" diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index d5e1772f8b0..70a8dbf9245 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -40,9 +40,9 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp32c2/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #define TAG "esp_adapter" diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index 18fefbcea14..d48431ab324 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -41,9 +41,9 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp32c3/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #define TAG "esp_adapter" diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index 8c55440ffa0..f61e946f2f5 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -40,9 +40,9 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp32c6/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #include "esp_private/esp_modem_clock.h" #if SOC_PM_MODEM_RETENTION_BY_REGDMA diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 4eb6db306ee..b0672498cc7 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -41,10 +41,10 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp_rom_sys.h" #include "esp32s2/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #define TAG "esp_adapter" diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index 3fbb3d5ec1e..e6ca995af7f 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -42,10 +42,10 @@ #include "nvs.h" #include "os.h" #include "esp_smartconfig.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp_rom_sys.h" #include "esp32s3/rom/ets_sys.h" -#include "esp_modem_wrapper.h" +#include "private/esp_modem_wrapper.h" #define TAG "esp_adapter" diff --git a/components/esp_wifi/include/esp_wifi_crypto_types.h b/components/esp_wifi/include/esp_wifi_crypto_types.h index dfe44bec6f2..e6934e1f683 100644 --- a/components/esp_wifi/include/esp_wifi_crypto_types.h +++ b/components/esp_wifi/include/esp_wifi_crypto_types.h @@ -55,7 +55,7 @@ typedef struct crypto_hash esp_crypto_hash_t; typedef struct crypto_cipher esp_crypto_cipher_t; /** - * @brief The AES callback function when do WPS connect. + * @brief The AES 128 encrypt callback function used by esp_wifi. * * @param key Encryption key. * @param iv Encryption IV for CBC mode (16 bytes). @@ -65,7 +65,7 @@ typedef struct crypto_cipher esp_crypto_cipher_t; typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); /** - * @brief The AES callback function when do WPS connect. + * @brief The AES 128 decrypt callback function used by esp_wifi. * * @param key Decryption key. * @param iv Decryption IV for CBC mode (16 bytes). @@ -76,7 +76,7 @@ typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned ch typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); /** - * @brief The AES callback function when do STA connect. + * @brief The AES wrap callback function used by esp_wifi. * * @param kek 16-octet Key encryption key (KEK). * @param n Length of the plaintext key in 64-bit units; @@ -87,7 +87,7 @@ typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned ch typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned char *plain, unsigned char *cipher); /** - * @brief The AES callback function when do STA connect. + * @brief The AES unwrap callback function used by esp_wifi. * * @param kek 16-octet Key decryption key (KEK). * @param n Length of the plaintext key in 64-bit units; @@ -98,7 +98,7 @@ typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned ch typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned char *cipher, unsigned char *plain); /** - * @brief The SHA256 callback function when do WPS connect. + * @brief The SHA256 callback function used by esp_wifi. * * @param key Key for HMAC operations. * @param key_len Length of the key in bytes. @@ -112,7 +112,7 @@ typedef int (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, i const unsigned char *addr[], const int *len, unsigned char *mac); /** - * @brief The AES callback function when do STA connect. + * @brief The SHA256 PRF callback function used by esp_wifi. * * @param key Key for PRF. * @param key_len Length of the key in bytes. @@ -127,7 +127,7 @@ typedef int (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const cha const unsigned char *data, int data_len, unsigned char *buf, int buf_len); /** - * @brief HMAC-MD5 over data buffer (RFC 2104)' + * @brief HMAC-MD5 callback function over data buffer (RFC 2104)' * * @param key Key for HMAC operations * @param key_len Length of the key in bytes @@ -140,7 +140,7 @@ typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, co unsigned int data_len, unsigned char *mac); /** - * @brief HMAC-MD5 over data vector (RFC 2104) + * @brief HMAC-MD5 callback function over data vector (RFC 2104) * * @param key Key for HMAC operations * @param key_len Length of the key in bytes @@ -154,7 +154,7 @@ typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_ const unsigned char *addr[], const unsigned int *len, unsigned char *mac); /** - * @brief HMAC-SHA1 over data buffer (RFC 2104) + * @brief HMAC-SHA1 callback function over data buffer (RFC 2104) * * @param key Key for HMAC operations * @param key_len Length of the key in bytes @@ -167,7 +167,7 @@ typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, c unsigned int data_len, unsigned char *mac); /** - * @brief HMAC-SHA1 over data vector (RFC 2104) + * @brief HMAC-SHA1 callback function over data vector (RFC 2104) * * @param key Key for HMAC operations * @param key_len Length of the key in bytes @@ -181,7 +181,7 @@ typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key const unsigned char *addr[], const unsigned int *len, unsigned char *mac); /** - * @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) + * @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) callback function * * @param key Key for PRF * @param key_len Length of the key in bytes @@ -199,7 +199,7 @@ typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, co const unsigned char *data, unsigned int data_len, unsigned char *buf, unsigned int buf_len); /** - * @brief SHA-1 hash for data vector + * @brief SHA-1 hash callback function for data vector * * @param num_elem Number of elements in the data vector * @param addr Pointers to the data areas @@ -211,7 +211,7 @@ typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *add unsigned char *mac); /** - * @brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i + * @brief SHA1-based key derivation function (PBKDF2) callback function for IEEE 802.11i * * @param passphrase ASCII passphrase * @param ssid SSID @@ -229,7 +229,7 @@ typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsig int iterations, unsigned char *buf, unsigned int buflen); /** - * @brief XOR RC4 stream to given data with skip-stream-start + * @brief XOR RC4 stream callback function to given data with skip-stream-start * * @param key RC4 key * @param keylen RC4 key length @@ -246,7 +246,7 @@ typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, uns unsigned char *data, unsigned int data_len); /** - * @brief MD5 hash for data vector + * @brief MD5 hash callback function for data vector * * @param num_elem Number of elements in the data vector * @param addr Pointers to the data areas @@ -258,7 +258,7 @@ typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr unsigned char *mac); /** - * @brief Encrypt one AES block + * @brief Encrypt one AES block callback function * * @param ctx Context pointer from aes_encrypt_init() * @param plain Plaintext data to be encrypted (16 bytes) @@ -267,7 +267,7 @@ typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt); /** - * @brief Initialize AES for encryption + * @brief Initialize AES callback function for encryption * * @param key Encryption key * @param len Key length in bytes (usually 16, i.e., 128 bits) @@ -276,14 +276,14 @@ typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigne typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len); /** - * @brief Deinitialize AES encryption + * @brief Deinitialize AES encryption callback function * * @param ctx Context pointer from aes_encrypt_init() */ typedef void (*esp_aes_encrypt_deinit_t)(void *ctx); /** - * @brief Decrypt one AES block + * @brief Decrypt one AES block callback function * * @param ctx Context pointer from aes_encrypt_init() * @param crypt Encrypted data (16 bytes) @@ -292,7 +292,7 @@ typedef void (*esp_aes_encrypt_deinit_t)(void *ctx); typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain); /** - * @brief Initialize AES for decryption + * @brief Initialize AES callback function for decryption * * @param key Decryption key * @param len Key length in bytes (usually 16, i.e., 128 bits) @@ -301,14 +301,14 @@ typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigne typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len); /** - * @brief Deinitialize AES decryption + * @brief Deinitialize AES decryption callback function * * @param ctx Context pointer from aes_encrypt_init() */ typedef void (*esp_aes_decrypt_deinit_t)(void *ctx); /** - * @brief One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation + * @brief One-Key CBC MAC (OMAC1) hash with AES-128 callback function for MIC computation * * @param key 128-bit key for the hash operation * @param data Data buffer for which a MIC is computed @@ -320,7 +320,7 @@ typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size uint8_t *mic); /** - * @brief Decrypt data using CCMP (Counter Mode CBC-MAC Protocol OR + * @brief Decrypt data callback function using CCMP (Counter Mode CBC-MAC Protocol OR * Counter Mode Cipher Block Chaining Message Authentication * Code Protocol) which is used in IEEE 802.11i RSN standard. * @param tk 128-bit Temporal Key for obtained during 4-way handshake @@ -336,7 +336,7 @@ typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80 size_t *decrypted_len, bool espnow_pkt); /** - * @brief Encrypt data using CCMP (Counter Mode CBC-MAC Protocol OR + * @brief Encrypt data callback function using CCMP (Counter Mode CBC-MAC Protocol OR * Counter Mode Cipher Block Chaining Message Authentication * Code Protocol) which is used in IEEE 802.11i RSN standard. * @param tk 128-bit Temporal Key for obtained during 4-way handshake @@ -351,7 +351,7 @@ typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_ uint8_t *pn, int keyid, size_t *encrypted_len); /** - * @brief One-Key GMAC hash with AES for MIC computation + * @brief One-Key GMAC hash callback function with AES for MIC computation * * @param key key for the hash operation * @param keylen key length @@ -366,7 +366,7 @@ typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t * const uint8_t *aad, size_t aad_len, uint8_t *mic); /** - * @brief SHA256 hash for data vector + * @brief SHA256 hash callback function for data vector * @param num_elem Number of elements in the data vector * @param addr Pointers to the data areas * @param len Lengths of the data blocks @@ -376,7 +376,7 @@ typedef int (*esp_aes_gmac_t)(const uint8_t *key, size_t keylen, const uint8_t * typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t *buf); /** - * @brief CRC32 value in little endian. + * @brief CRC32 value callback function in little endian. * * @param crc Initial CRC value (result of last calculation or 0 for the first time) * @param buf Data buffer that used to calculate the CRC value @@ -386,40 +386,40 @@ typedef int (*esp_sha256_vector_t)(size_t num_elem, const uint8_t *addr[], const typedef uint32_t (*esp_crc32_le_t)(uint32_t crc, uint8_t const *buf, uint32_t len); /** - * @brief The crypto callback function structure used when do station security connect. + * @brief The crypto callback function structure used by esp_wifi. * The structure can be set as software crypto or the crypto optimized by device's * hardware. */ typedef struct { uint32_t size; /**< The crypto callback function structure size */ uint32_t version; /**< The crypto callback function structure version */ - esp_aes_wrap_t aes_wrap; /**< The AES callback function when do STA connect */ - esp_aes_unwrap_t aes_unwrap; /**< The AES callback function when do STA connect */ - esp_hmac_sha256_vector_t hmac_sha256_vector; /**< The SHA256 callback function when do WPS connect */ - esp_sha256_prf_t sha256_prf; /**< The AES callback function when do STA connect */ - esp_hmac_md5_t hmac_md5; /**< HMAC-MD5 over data buffer (RFC 2104) */ - esp_hmac_md5_vector_t hamc_md5_vector; /**< HMAC-MD5 over data vector (RFC 2104) */ - esp_hmac_sha1_t hmac_sha1; /**< HMAC-SHA1 over data buffer (RFC 2104) */ - esp_hmac_sha1_vector_t hmac_sha1_vector; /**< HMAC-SHA1 over data vector (RFC 2104) */ - esp_sha1_prf_t sha1_prf; /**< SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) */ - esp_sha1_vector_t sha1_vector; /**< SHA-1 hash for data vector */ - esp_pbkdf2_sha1_t pbkdf2_sha1; /**< SHA1-based key derivation function (PBKDF2) for IEEE 802.11i */ - esp_rc4_skip_t rc4_skip; /**< XOR RC4 stream to given data with skip-stream-start */ - esp_md5_vector_t md5_vector; /**< MD5 hash for data vector */ - esp_aes_encrypt_t aes_encrypt; /**< Encrypt one AES block */ - esp_aes_encrypt_init_t aes_encrypt_init; /**< Initialize AES for encryption */ - esp_aes_encrypt_deinit_t aes_encrypt_deinit; /**< Deinitialize AES encryption */ - esp_aes_decrypt_t aes_decrypt; /**< Decrypt one AES block */ - esp_aes_decrypt_init_t aes_decrypt_init; /**< Initialize AES for decryption */ - esp_aes_decrypt_deinit_t aes_decrypt_deinit; /**< Deinitialize AES decryption */ - esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES callback function when do WPS connect */ - esp_aes_128_decrypt_t aes_128_decrypt; /**< The AES callback function when do WPS connect */ - esp_omac1_aes_128_t omac1_aes_128; /**< One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation */ - esp_ccmp_decrypt_t ccmp_decrypt; /**< Decrypt data using CCMP */ - esp_ccmp_encrypt_t ccmp_encrypt; /**< encrypt data using CCMP */ - esp_aes_gmac_t aes_gmac; /**< One-Key GMAC hash with AES for MIC computation */ - esp_sha256_vector_t sha256_vector; /**< SHA256 hash for data vector */ - esp_crc32_le_t crc32; /**< CRC32 value in little endian */ + esp_aes_wrap_t aes_wrap; /**< The AES wrap callback function used by esp_wifi */ + esp_aes_unwrap_t aes_unwrap; /**< The AES unwrap callback function used by esp_wifi */ + esp_hmac_sha256_vector_t hmac_sha256_vector; /**< The SHA256 callback function used by esp_wifi */ + esp_sha256_prf_t sha256_prf; /**< The SHA256 PRF callback function used by esp_wifi */ + esp_hmac_md5_t hmac_md5; /**< HMAC-MD5 callback function over data buffer (RFC 2104) */ + esp_hmac_md5_vector_t hamc_md5_vector; /**< HMAC-MD5 callback function over data vector (RFC 2104) */ + esp_hmac_sha1_t hmac_sha1; /**< HMAC-SHA1 callback function over data buffer (RFC 2104) */ + esp_hmac_sha1_vector_t hmac_sha1_vector; /**< HMAC-SHA1 callback function over data vector (RFC 2104) */ + esp_sha1_prf_t sha1_prf; /**< SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) callback function */ + esp_sha1_vector_t sha1_vector; /**< SHA-1 hash callback function for data vector */ + esp_pbkdf2_sha1_t pbkdf2_sha1; /**< SHA1-based key derivation function (PBKDF2) callback function for IEEE 802.11i */ + esp_rc4_skip_t rc4_skip; /**< XOR RC4 stream callback function to given data with skip-stream-start */ + esp_md5_vector_t md5_vector; /**< MD5 hash callback function for data vector */ + esp_aes_encrypt_t aes_encrypt; /**< Encrypt one AES block callback function */ + esp_aes_encrypt_init_t aes_encrypt_init; /**< Initialize AES callback function for encryption */ + esp_aes_encrypt_deinit_t aes_encrypt_deinit; /**< Deinitialize AES encryption callback function */ + esp_aes_decrypt_t aes_decrypt; /**< Decrypt one AES block callback function */ + esp_aes_decrypt_init_t aes_decrypt_init; /**< Initialize AES callback function for decryption */ + esp_aes_decrypt_deinit_t aes_decrypt_deinit; /**< Deinitialize AES decryption callback function */ + esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES 128 encrypt callback function used by esp_wifi */ + esp_aes_128_decrypt_t aes_128_decrypt; /**< The AES 128 decrypt callback function used by esp_wifi */ + esp_omac1_aes_128_t omac1_aes_128; /**< One-Key CBC MAC (OMAC1) hash with AES-128 callback function for MIC computation */ + esp_ccmp_decrypt_t ccmp_decrypt; /**< Decrypt data callback function using CCMP */ + esp_ccmp_encrypt_t ccmp_encrypt; /**< Encrypt data callback function using CCMP */ + esp_aes_gmac_t aes_gmac; /**< One-Key GMAC hash callback function with AES for MIC computation */ + esp_sha256_vector_t sha256_vector; /**< SHA256 hash callback function for data vector */ + esp_crc32_le_t crc32; /**< CRC32 value callback function in little endian */ }wpa_crypto_funcs_t; /** @@ -428,8 +428,8 @@ typedef struct { * hardware. */ typedef struct{ - esp_aes_128_encrypt_t aes_128_encrypt; /**< function used in mesh vendor IE encryption */ - esp_aes_128_decrypt_t aes_128_decrypt; /**< function used in mesh vendor IE decryption */ + esp_aes_128_encrypt_t aes_128_encrypt; /**< Callback function used in mesh vendor IE encryption */ + esp_aes_128_decrypt_t aes_128_decrypt; /**< Callback function used in mesh vendor IE decryption */ } mesh_crypto_funcs_t; #ifdef __cplusplus diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index fbe2be440e6..1f4f3d32da6 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -16,7 +16,7 @@ #include "esp_private/esp_clk.h" #include "esp_wpa.h" #include "esp_netif.h" -#include "esp_coexist_internal.h" +#include "private/esp_coexist_internal.h" #include "esp_phy_init.h" #include "esp_private/phy.h" #ifdef CONFIG_ESP_WIFI_NAN_ENABLE diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index aa94c838e90..69185331f60 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -27,9 +27,7 @@ INPUT = \ $(PROJECT_PATH)/components/bootloader_support/include/bootloader_random.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_app_format.h \ $(PROJECT_PATH)/components/bootloader_support/include/esp_flash_encrypt.h \ - $(PROJECT_PATH)/components/esp_coex/include/esp_coexist_internal.h \ $(PROJECT_PATH)/components/esp_coex/include/esp_coexist.h \ - $(PROJECT_PATH)/components/esp_coex/include/esp_modem_wrapper.h \ $(PROJECT_PATH)/components/bt/common/api/include/api/esp_blufi_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h \ $(PROJECT_PATH)/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h \ From 61ae9bd8e2d158bcb772ded290f1c3b58396a344 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 10 Aug 2023 19:35:43 +0800 Subject: [PATCH 08/15] fix(wifi/mesh): fix the IE crypto disable error and update doc --- components/esp_wifi/include/esp_mesh.h | 13 +-- .../esp_wifi/include/esp_mesh_internal.h | 90 ++++++++++--------- .../esp_wifi/include/esp_wifi_crypto_types.h | 2 +- .../mesh/manual_networking/main/mesh_main.c | 21 ++--- .../main/esp_zigbee_gateway.c | 5 +- 5 files changed, 68 insertions(+), 63 deletions(-) diff --git a/components/esp_wifi/include/esp_mesh.h b/components/esp_wifi/include/esp_mesh.h index 9118fcda440..d5de2eed110 100644 --- a/components/esp_wifi/include/esp_mesh.h +++ b/components/esp_wifi/include/esp_mesh.h @@ -136,10 +136,13 @@ extern "C" { /** * @brief Flag of mesh networking IE */ -#define MESH_ASSOC_FLAG_VOTE_IN_PROGRESS (0x02) /**< vote in progress */ +#define MESH_ASSOC_FLAG_MAP_ASSOC (0x01) /**< Mesh AP doesn't detect children leave yet */ +#define MESH_ASSOC_FLAG_VOTE_IN_PROGRESS (0x02) /**< station in vote, set when root vote start, clear when connect to router or when root switch*/ +#define MESH_ASSOC_FLAG_STA_VOTED (0x04) /**< station vote done, set when connect to router */ #define MESH_ASSOC_FLAG_NETWORK_FREE (0x08) /**< no root in current network */ -#define MESH_ASSOC_FLAG_ROOTS_FOUND (0x20) /**< root conflict is found */ -#define MESH_ASSOC_FLAG_ROOT_FIXED (0x40) /**< fixed root */ +#define MESH_ASSOC_FLAG_STA_VOTE_EXPIRE (0x10) /**< the voted address is expired, means the voted device lose the chance to be root */ +#define MESH_ASSOC_FLAG_ROOTS_FOUND (0x20) /**< roots conflict is found, means that thre are at least two roots in the mesh network */ +#define MESH_ASSOC_FLAG_ROOT_FIXED (0x40) /**< the root is fixed in the mesh network */ /** @@ -1291,7 +1294,7 @@ int esp_mesh_get_capacity_num(void); /** * @brief Set mesh IE crypto functions * - * @attention This API can be called at any time after mesh is initialized. + * @attention This API can be called at any time after mesh is configured. * * @param[in] crypto_funcs crypto functions for mesh IE * - If crypto_funcs is set to NULL, mesh IE is no longer encrypted. @@ -1303,7 +1306,7 @@ esp_err_t esp_mesh_set_ie_crypto_funcs(const mesh_crypto_funcs_t *crypto_funcs); /** * @brief Set mesh IE crypto key * - * @attention This API can be called at any time after mesh is initialized. + * @attention This API can be called at any time after mesh is configured. * * @param[in] key ASCII crypto key * @param[in] len length in bytes, range:8~64 diff --git a/components/esp_wifi/include/esp_mesh_internal.h b/components/esp_wifi/include/esp_mesh_internal.h index 371e1e60640..4c6a998ecc8 100644 --- a/components/esp_wifi/include/esp_mesh_internal.h +++ b/components/esp_wifi/include/esp_mesh_internal.h @@ -50,12 +50,14 @@ typedef struct { } mesh_switch_parent_t; /** - * @brief Mesh rssi threshold + * @brief Mesh RSSI threshold */ typedef struct { - int high; /**< high rssi threshold */ - int medium; /**< medium rssi threshold */ - int low; /**< low rssi threshold */ + int high; /**< high RSSI threshold, used to determine whether the new parent and the current parent are in the same RSSI range */ + int medium; /**< medium RSSI threshold, used to determine whether the new parent and the current parent are in the same RSSI range */ + int low; /**< low RSSI threshold. If the parent's RSSI is lower than low for a period time of duration_ms, + then the mesh node will post MESH_WEAK_RSSI event. + Also used to determine whether the new parent and the current parent are in the same RSSI range */ } mesh_rssi_threshold_t; /** @@ -63,47 +65,47 @@ typedef struct { */ typedef struct { /**< mesh networking IE head */ - uint8_t eid; /**< element ID */ - uint8_t len; /**< element length */ - uint8_t oui[3]; /**< organization identifier */ - /**< mesh networking IE content */ - uint8_t type; /**< ESP defined IE type */ + uint8_t eid; /**< element ID, vendor specific, 221 */ + uint8_t len; /**< element length, the length after this member */ + uint8_t oui[3]; /**< organization identifier, 0x18fe34 */ + uint8_t type; /**< ESP defined IE type, include Assoc IE, SSID IE, Ext Assoc IE, Roots IE, etc. */ uint8_t encrypted : 1; /**< whether mesh networking IE is encrypted */ - uint8_t version : 7; /**< mesh networking IE version */ + uint8_t version : 7; /**< mesh networking IE version, equal to 2 if mesh PS is enabled, equal to 1 otherwise */ /**< content */ - uint8_t mesh_type; /**< mesh device type */ - uint8_t mesh_id[6]; /**< mesh ID */ - uint8_t layer_cap; /**< max layer */ - uint8_t layer; /**< current layer */ - uint8_t assoc_cap; /**< max connections of mesh AP */ - uint8_t assoc; /**< current connections */ - uint8_t leaf_cap; /**< leaf capacity */ - uint8_t leaf_assoc; /**< the number of current connected leaf */ - uint16_t root_cap; /**< root capacity */ - uint16_t self_cap; /**< self capacity */ - uint16_t layer2_cap; /**< layer2 capacity */ - uint16_t scan_ap_num; /**< the number of scanning APs */ - int8_t rssi; /**< RSSI of the parent */ - int8_t router_rssi; /**< RSSI of the router */ - uint8_t flag; /**< flag of networking */ - uint8_t rc_addr[6]; /**< root address */ - int8_t rc_rssi; /**< root RSSI */ - uint8_t vote_addr[6]; /**< voter address */ - int8_t vote_rssi; /**< vote RSSI of the router */ - uint8_t vote_ttl; /**< vote ttl */ - uint16_t votes; /**< votes */ - uint16_t my_votes; /**< my votes */ - uint8_t reason; /**< reason */ - uint8_t child[6]; /**< child address */ - uint8_t toDS; /**< toDS state */ + uint8_t mesh_type; /**< mesh device type, include idle, root, node, etc, refer to mesh_type_t */ + uint8_t mesh_id[6]; /**< mesh ID, only the same mesh id can form a unified mesh network */ + uint8_t layer_cap; /**< layer_cap = max_layer - layer, indicates the number of remaining available layers of the mesh network */ + uint8_t layer; /**< the current layer of this node */ + uint8_t assoc_cap; /**< the maximum connections of this mesh AP */ + uint8_t assoc; /**< current connections of this mesh AP */ + uint8_t leaf_cap; /**< the maximum number of leaves in the mesh network */ + uint8_t leaf_assoc; /**< the number of current connected leaves */ + uint16_t root_cap; /**< the capacity of the root, equal to the total child numbers plus 1, root node updates root_cap and self_cap */ + uint16_t self_cap; /**< the capacity of myself, total child numbers plus 1, all nodes update this member */ + uint16_t layer2_cap; /**< the capacity of layer2 node, total child numbers plus 1, layer2 node updates layer2_cap and self_cap, root sets this to 0 */ + uint16_t scan_ap_num; /**< the number of mesh APs around */ + int8_t rssi; /**< RSSI of the connected parent, default value is -120, root node will not update this */ + int8_t router_rssi; /**< RSSI of the router, default value is -120 */ + uint8_t flag; /**< flag of networking, indicates the status of the network, refer to MESH_ASSOC_FLAG_XXX */ + /**< vote related */ + uint8_t rc_addr[6]; /**< the address of the root candidate, i.e. the voted addesss before connection, root node will update this with self address */ + int8_t rc_rssi; /**< the router RSSI of the root candidate */ + uint8_t vote_addr[6]; /**< the voted address after connection */ + int8_t vote_rssi; /**< the router RSSI of the voted address */ + uint8_t vote_ttl; /**< vote ttl, indicate the voting is from myself or from other nodes */ + uint16_t votes; /**< the number of all voting nodes */ + uint16_t my_votes; /**< the number of nodes that voted for me */ + uint8_t reason; /**< the reason why the voting happens, root initiated or child initiated, refer to mesh_vote_reason_t */ + uint8_t child[6]; /**< child address, not used currently */ + uint8_t toDS; /**< state represents whether the root is able to access external IP network */ } __attribute__((packed)) mesh_assoc_t; /** * @brief Mesh chain layer */ typedef struct { - uint16_t layer_cap; /**< max layer */ - uint16_t layer; /**< current layer */ + uint16_t layer_cap; /**< max layer of the network */ + uint16_t layer; /**< current layer of this node */ } mesh_chain_layer_t; /** @@ -111,22 +113,22 @@ typedef struct { */ typedef struct { mesh_assoc_t tree; /**< tree top, mesh_assoc IE */ - mesh_chain_layer_t chain; /**< chain top, mesh_assoc IE*/ + mesh_chain_layer_t chain; /**< chain top, mesh_assoc IE */ } __attribute__((packed)) mesh_chain_assoc_t; /* mesh max connections */ #define MESH_MAX_CONNECTIONS (10) /** - * @brief Mesh PS duties + * @brief Mesh power save duties */ typedef struct { uint8_t device; /**< device power save duty*/ uint8_t parent; /**< parent power save duty*/ struct { - bool used; /**< used */ - uint8_t duty; /**< duty */ - uint8_t mac[6]; /**< mac */ + bool used; /**< whether the child is joined */ + uint8_t duty; /**< power save duty of the child */ + uint8_t mac[6]; /**< mac address of the child */ } child[MESH_MAX_CONNECTIONS]; /**< child */ } esp_mesh_ps_duties_t; @@ -200,7 +202,7 @@ esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras); esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras); /** - * @brief Set RSSI threshold + * @brief Set RSSI threshold of current parent * - The default high RSSI threshold value is -78 dBm. * - The default medium RSSI threshold value is -82 dBm. * - The default low RSSI threshold value is -85 dBm. @@ -214,7 +216,7 @@ esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras); esp_err_t esp_mesh_set_rssi_threshold(const mesh_rssi_threshold_t *threshold); /** - * @brief Get RSSI threshold + * @brief Get RSSI threshold of current parent * * @param[out] threshold RSSI threshold * diff --git a/components/esp_wifi/include/esp_wifi_crypto_types.h b/components/esp_wifi/include/esp_wifi_crypto_types.h index e6934e1f683..689668101db 100644 --- a/components/esp_wifi/include/esp_wifi_crypto_types.h +++ b/components/esp_wifi/include/esp_wifi_crypto_types.h @@ -412,7 +412,7 @@ typedef struct { esp_aes_decrypt_t aes_decrypt; /**< Decrypt one AES block callback function */ esp_aes_decrypt_init_t aes_decrypt_init; /**< Initialize AES callback function for decryption */ esp_aes_decrypt_deinit_t aes_decrypt_deinit; /**< Deinitialize AES decryption callback function */ - esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES 128 encrypt callback function used by esp_wifi */ + esp_aes_128_encrypt_t aes_128_encrypt; /**< The AES 128 encrypt callback function used by esp_wifi */ esp_aes_128_decrypt_t aes_128_decrypt; /**< The AES 128 decrypt callback function used by esp_wifi */ esp_omac1_aes_128_t omac1_aes_128; /**< One-Key CBC MAC (OMAC1) hash with AES-128 callback function for MIC computation */ esp_ccmp_decrypt_t ccmp_decrypt; /**< Decrypt data callback function using CCMP */ diff --git a/examples/mesh/manual_networking/main/mesh_main.c b/examples/mesh/manual_networking/main/mesh_main.c index 33958a768d8..13f1190fec7 100644 --- a/examples/mesh/manual_networking/main/mesh_main.c +++ b/examples/mesh/manual_networking/main/mesh_main.c @@ -301,17 +301,8 @@ void app_main(void) /* mesh initialization */ ESP_ERROR_CHECK(esp_mesh_init()); ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL)); - /* mesh enable IE crypto */ + /* mesh config */ mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT(); -#if CONFIG_MESH_IE_CRYPTO_FUNCS - /* modify IE crypto key */ - ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(&g_wifi_default_mesh_crypto_funcs)); - ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_key(CONFIG_MESH_IE_CRYPTO_KEY, strlen(CONFIG_MESH_IE_CRYPTO_KEY))); -#else - /* disable IE crypto */ - ESP_LOGI(MESH_TAG, "disable IE crypto"); - ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(NULL)); -#endif /* mesh ID */ memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6); /* router */ @@ -327,6 +318,16 @@ void app_main(void) memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD, strlen(CONFIG_MESH_AP_PASSWD)); ESP_ERROR_CHECK(esp_mesh_set_config(&cfg)); + /* mesh enable IE crypto */ +#if CONFIG_MESH_IE_CRYPTO_FUNCS + /* modify IE crypto key */ + ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(&g_wifi_default_mesh_crypto_funcs)); + ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_key(CONFIG_MESH_IE_CRYPTO_KEY, strlen(CONFIG_MESH_IE_CRYPTO_KEY))); +#else + /* disable IE crypto */ + ESP_LOGI(MESH_TAG, "disable IE crypto"); + ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(NULL)); +#endif /* mesh start */ ESP_ERROR_CHECK(esp_mesh_start()); ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%" PRId32 "\n", esp_get_free_heap_size()); diff --git a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c index 52d61945b81..4c034b2e058 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c @@ -39,7 +39,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/usb_serial_jtag.h" -#include "esp_coexist_internal.h" +#include "esp_coexist.h" #include "esp_log.h" #include "esp_netif.h" #include "esp_spiffs.h" @@ -173,8 +173,7 @@ void app_main(void) ESP_ERROR_CHECK(example_connect()); #if CONFIG_ESP_COEX_SW_COEXIST_ENABLE ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM)); - coex_enable(); - coex_schm_status_bit_set(1, 1); + esp_coex_wifi_i154_enable(); #else ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); #endif From 1881900781692733f2389570d4a833f09cb0f014 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Thu, 16 Nov 2023 20:20:08 +0800 Subject: [PATCH 09/15] fix(wifi): allow some special igtk keyindx to workaround faulty APs --- components/wpa_supplicant/src/rsn_supp/wpa.c | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index 688f4cec4f5..8149d0b13cf 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -1011,37 +1011,37 @@ int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm, static int wpa_supplicant_install_igtk(struct wpa_sm *sm, const wifi_wpa_igtk_t *igtk) { - size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher); - u16 keyidx = WPA_GET_LE16(igtk->keyid); - - /* Detect possible key reinstallation */ - if (sm->igtk.igtk_len == len && - os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) { - wpa_printf(MSG_DEBUG, - "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)", - keyidx); - return 0; - } - - wpa_printf(MSG_DEBUG, - "WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x", - keyidx, MAC2STR(igtk->pn)); - wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len); - if (keyidx > 4095) { - wpa_printf(MSG_WARNING, - "WPA: Invalid IGTK KeyID %d", keyidx); - return -1; - } - if (esp_wifi_set_igtk_internal(WIFI_IF_STA, igtk) < 0) { - wpa_printf(MSG_WARNING, - "WPA: Failed to configure IGTK to the driver"); - return -1; - } - - sm->igtk.igtk_len = len; - os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len); - - return 0; + size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher); + u16 keyidx = WPA_GET_LE16(igtk->keyid); + + /* Detect possible key reinstallation */ + if (sm->igtk.igtk_len == len && + os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) { + wpa_printf(MSG_DEBUG, + "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)", + keyidx); + return 0; + } + + wpa_printf(MSG_DEBUG, + "WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x", + keyidx, MAC2STR(igtk->pn)); + wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len); + + if (esp_wifi_set_igtk_internal(WIFI_IF_STA, igtk) < 0) { + if (keyidx > 4095) { + wpa_printf(MSG_WARNING, + "WPA: Invalid IGTK KeyID %d", keyidx); + } + wpa_printf(MSG_WARNING, + "WPA: Failed to configure IGTK to the driver"); + return -1; + } + + sm->igtk.igtk_len = len; + os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len); + + return 0; } #endif /* CONFIG_IEEE80211W */ From 482ba2b90986be1366b80c821b2ec21ce44c5ecf Mon Sep 17 00:00:00 2001 From: muhaidong Date: Thu, 16 Nov 2023 21:43:36 +0800 Subject: [PATCH 10/15] fix(wifi): fix psram enabled but initialized fail issue Closes https://github.com/espressif/esp-idf/issues/11971 --- components/esp_psram/Kconfig.spiram.common | 13 ++++- components/esp_wifi/CMakeLists.txt | 4 ++ components/esp_wifi/include/esp_wifi.h | 35 +++++++++++-- components/esp_wifi/src/wifi_init.c | 58 ++++++++++++++-------- 4 files changed, 84 insertions(+), 26 deletions(-) diff --git a/components/esp_psram/Kconfig.spiram.common b/components/esp_psram/Kconfig.spiram.common index 759c1334d81..9fb2a6bb9da 100644 --- a/components/esp_psram/Kconfig.spiram.common +++ b/components/esp_psram/Kconfig.spiram.common @@ -13,11 +13,20 @@ config SPIRAM_BOOT_INIT config SPIRAM_IGNORE_NOTFOUND bool "Ignore PSRAM when not found" default "n" - depends on SPIRAM_BOOT_INIT && !SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY + depends on SPIRAM_BOOT_INIT && !SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY && !SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY help Normally, if psram initialization is enabled during compile time but not found at runtime, it is seen as an error making the CPU panic. If this is enabled, booting will complete - but no PSRAM will be available. + but no PSRAM will be available. If PSRAM failed to initialize, the following configs may be affected + and may need to be corrected manually. SPIRAM_TRY_ALLOCATE_WIFI_LWIP will affect some LWIP and WiFi buffer + default values and range values. Enable SPIRAM_TRY_ALLOCATE_WIFI_LWIP, ESP_WIFI_AMSDU_TX_ENABLED, + ESP_WIFI_CACHE_TX_BUFFER_NUM and use static WiFi Tx buffer may cause potential memory exhaustion issues. + Suggest disable SPIRAM_TRY_ALLOCATE_WIFI_LWIP. + Suggest disable ESP_WIFI_AMSDU_TX_ENABLED. + Suggest disable ESP_WIFI_CACHE_TX_BUFFER_NUM, need clear CONFIG_FEATURE_CACHE_TX_BUF_BIT of + config->feature_caps. + Suggest change ESP_WIFI_TX_BUFFER from static to dynamic. Also suggest to adjust some buffer numbers to the + values used without PSRAM case. Such as, ESP_WIFI_STATIC_TX_BUFFER_NUM, ESP_WIFI_DYNAMIC_TX_BUFFER_NUM. choice SPIRAM_USE prompt "SPI RAM access method" diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index bcd442eeb80..0844b89578c 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -66,4 +66,8 @@ if(CONFIG_ESP_WIFI_ENABLED) endforeach() endif() + if(CONFIG_SPIRAM) + idf_component_optional_requires(PRIVATE esp_psram) + endif() + endif() diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index ad7867cdeb9..308af321457 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -180,7 +180,6 @@ typedef struct { #endif extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; -extern uint64_t g_wifi_feature_caps; #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F @@ -214,11 +213,41 @@ extern uint64_t g_wifi_feature_caps; #define WIFI_STA_DISCONNECTED_PM_ENABLED false #endif -#define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) +#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE +#define WIFI_ENABLE_WPA3_SAE (1<<0) +#else +#define WIFI_ENABLE_WPA3_SAE 0 +#endif + +#if CONFIG_SPIRAM +#define WIFI_ENABLE_SPIRAM (1<<1) +#else +#define WIFI_ENABLE_SPIRAM 0 +#endif + +#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT +#define WIFI_FTM_INITIATOR (1<<2) +#else +#define WIFI_FTM_INITIATOR 0 +#endif + +#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT +#define WIFI_FTM_RESPONDER (1<<3) +#else +#define WIFI_FTM_RESPONDER 0 +#endif + +#define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) #define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1) #define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2) #define CONFIG_FEATURE_FTM_RESPONDER_BIT (1<<3) +/* Set additional WiFi features and capabilities */ +#define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ + WIFI_ENABLE_SPIRAM | \ + WIFI_FTM_INITIATOR | \ + WIFI_FTM_RESPONDER) + #define WIFI_INIT_CONFIG_DEFAULT() { \ .osi_funcs = &g_wifi_osi_funcs, \ .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \ @@ -240,7 +269,7 @@ extern uint64_t g_wifi_feature_caps; .wifi_task_core_id = WIFI_TASK_CORE_ID,\ .beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \ .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \ - .feature_caps = g_wifi_feature_caps, \ + .feature_caps = WIFI_FEATURE_CAPS, \ .sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED, \ .espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, \ .magic = WIFI_INIT_CONFIG_MAGIC\ diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 1f4f3d32da6..fd96f51093c 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -19,6 +19,9 @@ #include "private/esp_coexist_internal.h" #include "esp_phy_init.h" #include "esp_private/phy.h" +#if __has_include("esp_psram.h") +#include "esp_psram.h" +#endif #ifdef CONFIG_ESP_WIFI_NAN_ENABLE #include "apps_private/wifi_apps_private.h" #endif @@ -45,22 +48,6 @@ static esp_pm_lock_handle_t s_wifi_modem_sleep_lock; wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb = NULL; #endif -/* Set additional WiFi features and capabilities */ -uint64_t g_wifi_feature_caps = -#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE - CONFIG_FEATURE_WPA3_SAE_BIT | -#endif -#if CONFIG_SPIRAM - CONFIG_FEATURE_CACHE_TX_BUF_BIT | -#endif -#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT - CONFIG_FEATURE_FTM_INITIATOR_BIT | -#endif -#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT - CONFIG_FEATURE_FTM_RESPONDER_BIT | -#endif -0; - #if SOC_PM_SUPPORT_PMU_MODEM_STATE # define WIFI_BEACON_MONITOR_CONFIG_DEFAULT(ena) { \ .enable = (ena), \ @@ -235,17 +222,46 @@ static void esp_wifi_config_info(void) #endif } +#if CONFIG_SPIRAM +static esp_err_t esp_wifi_psram_check(const wifi_init_config_t *config) +{ +#if CONFIG_SPIRAM_IGNORE_NOTFOUND + if (!esp_psram_is_initialized()) { + if (config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) { + ESP_LOGW(TAG, "WiFi cache TX buffers should be disabled when initialize SPIRAM failed"); + } + if (config->tx_buf_type == 0) { + ESP_LOGW(TAG, "TX buffers type should be changed from static to dynamic when initialize SPIRAM failed"); + } +#ifdef CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP + ESP_LOGW(TAG, "WiFi/LWIP prefer SPIRAM should be disabled when initialize SPIRAM failed"); +#endif + if (config->amsdu_tx_enable) { + ESP_LOGW(TAG, "WiFi AMSDU TX should be disabled when initialize SPIRAM failed"); + } + } +#endif + if ((config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) && (WIFI_CACHE_TX_BUFFER_NUM == 0)) { + ESP_LOGE(TAG, "Number of WiFi cache TX buffers should not equal 0 when enable SPIRAM"); + return ESP_ERR_NOT_SUPPORTED; + } + return ESP_OK; +} +#endif + esp_err_t esp_wifi_init(const wifi_init_config_t *config) { if (s_wifi_inited) { return ESP_OK; } - if ((config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) && (WIFI_CACHE_TX_BUFFER_NUM == 0)) - { - ESP_LOGE(TAG, "Number of WiFi cache TX buffers should not equal 0 when enable SPIRAM"); - return ESP_ERR_NOT_SUPPORTED; + esp_err_t result = ESP_OK; +#ifdef CONFIG_SPIRAM + result = esp_wifi_psram_check(config); + if (result != ESP_OK) { + return result; } +#endif #if CONFIG_ESP_WIFI_SLP_IRAM_OPT int min_freq_mhz = esp_pm_impl_get_cpu_freq(PM_MODE_LIGHT_SLEEP); @@ -302,7 +318,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) #endif esp_wifi_set_log_level(); esp_wifi_power_domain_on(); - esp_err_t result = esp_wifi_init_internal(config); + result = esp_wifi_init_internal(config); if (result == ESP_OK) { #if CONFIG_MAC_BB_PD esp_mac_bb_pd_mem_init(); From 23148a3138f08d3c65aace43445ec5e85c0cfaec Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Thu, 31 Aug 2023 14:58:58 +0800 Subject: [PATCH 11/15] Fix(esp_wifi): Add the missing header file to the wifi header files. --- .../include/esp_private/wifi_os_adapter.h | 4 ++++ .../esp_wifi/include/esp_wifi_crypto_types.h | 3 +++ .../esp_wifi/include/esp_wifi_default.h | 1 + components/esp_wifi/include/esp_wifi_netif.h | 8 ++++++- components/esp_wifi/include/smartconfig_ack.h | 22 ++++++++----------- tools/ci/check_copyright_ignore.txt | 1 - tools/ci/check_public_headers_exceptions.txt | 6 ----- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index 4b55b9c6b49..84ace9fd1be 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -8,6 +8,10 @@ #define ESP_WIFI_OS_ADAPTER_H_ #include +#include +#include +#include +#include "sdkconfig.h" #ifdef __cplusplus extern "C" { diff --git a/components/esp_wifi/include/esp_wifi_crypto_types.h b/components/esp_wifi/include/esp_wifi_crypto_types.h index 689668101db..6b41cc524a8 100644 --- a/components/esp_wifi/include/esp_wifi_crypto_types.h +++ b/components/esp_wifi/include/esp_wifi_crypto_types.h @@ -14,6 +14,9 @@ During normal operation, you don't need to use any of these types or functions in this header. See esp_wifi.h & esp_wifi_types.h instead. */ +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/components/esp_wifi/include/esp_wifi_default.h b/components/esp_wifi/include/esp_wifi_default.h index 0bb6450ab79..d30d512e358 100644 --- a/components/esp_wifi/include/esp_wifi_default.h +++ b/components/esp_wifi/include/esp_wifi_default.h @@ -8,6 +8,7 @@ #define _ESP_WIFI_DEFAULT_H #include "esp_netif.h" +#include "esp_wifi_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/esp_wifi/include/esp_wifi_netif.h b/components/esp_wifi/include/esp_wifi_netif.h index c25c52edd9f..7dfa724b066 100644 --- a/components/esp_wifi/include/esp_wifi_netif.h +++ b/components/esp_wifi/include/esp_wifi_netif.h @@ -1,11 +1,17 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once +#include +#include +#include "esp_err.h" +#include "esp_wifi_types.h" +#include "esp_netif_types.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/components/esp_wifi/include/smartconfig_ack.h b/components/esp_wifi/include/smartconfig_ack.h index abfada3ffaa..ea2cee59437 100644 --- a/components/esp_wifi/include/smartconfig_ack.h +++ b/components/esp_wifi/include/smartconfig_ack.h @@ -1,20 +1,16 @@ -// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef SMARTCONFIG_ACK_H #define SMARTCONFIG_ACK_H +#include "esp_smartconfig.h" +#include "esp_err.h" +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 0073242c461..94eb7005188 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -546,7 +546,6 @@ components/esp_system/test_eh_frame_parser/linker.ld components/esp_system/ubsan.c components/esp_wifi/include/esp_private/esp_wifi_types_private.h components/esp_wifi/include/esp_private/wifi_types.h -components/esp_wifi/include/smartconfig_ack.h components/esp_wifi/src/lib_printf.c components/esp_wifi/src/mesh_event.c components/esp_wifi/src/smartconfig.c diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 86b2eaa2d09..7916463792c 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -97,7 +97,6 @@ components/esp_hw_support/include/esp_private/esp_memprot_internal.h ### Here are the files that use CONFIG_XXX values but don't include sdkconfig.h # -components/esp_wifi/include/esp_private/wifi_os_adapter.h components/esp_coex/include/private/esp_coexist_adapter.h components/esp_coex/include/esp_coex_i154.h ### To be fixed: headers that rely on implicit inclusion @@ -118,10 +117,6 @@ components/esp_rom/include/esp32s2/rom/secure_boot.h components/esp_rom/include/esp32s2/rom/opi_flash.h components/esp_rom/include/esp32s2/rom/efuse.h components/esp_ringbuf/include/freertos/ringbuf.h -components/esp_wifi/include/esp_wifi_crypto_types.h -components/esp_wifi/include/esp_wifi_netif.h -components/esp_wifi/include/smartconfig_ack.h -components/esp_wifi/include/esp_wifi_default.h components/esp_event/include/esp_event_base.h components/esp_netif/include/esp_netif_sta_list.h components/esp_netif/include/esp_netif_defaults.h @@ -134,7 +129,6 @@ components/openssl/include/openssl/ssl.h components/ulp/include/ulp_common.h components/ulp/include/esp32s2/ulp_riscv.h components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h -components/wifi_provisioning/include/wifi_provisioning/scheme_softap.h components/usb/include/esp_private/usb_phy.h components/usb/include/usb/usb_types_stack.h From 796f315f6b8050da67336ab6b4af9eea70475c02 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 7 Sep 2023 19:47:33 +0800 Subject: [PATCH 12/15] doc(Wi-Fi/Vendor): Update comments for wifi_csi_info_t --- components/esp_wifi/include/esp_wifi_types.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index ba025126117..163cb3b3936 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -449,24 +449,26 @@ 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 */ - unsigned sig_mode:2; /**< 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ + unsigned sig_mode:2; /**< Protocol of the reveived packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ unsigned :16; /**< reserved */ unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ unsigned :16; /**< reserved */ - unsigned smoothing:1; /**< reserved */ - unsigned not_sounding:1; /**< reserved */ + unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended. + Set to 0 indicates that only per-carrierindependent (unsmoothed) channel estimate is recommended. */ + unsigned not_sounding:1; /**< Set to 0 indicates that PPDU is a sounding PPDU. Set to 1indicates that the PPDU is not a sounding PPDU. + sounding PPDU is used for channel estimation by the request receiver */ unsigned :1; /**< reserved */ unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ - unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */ + unsigned fec_coding:1; /**< Forward Error Correction(FEC). Flag is set for 11n packets which are LDPC */ unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ #if CONFIG_IDF_TARGET_ESP32 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ #elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 unsigned :8; /**< reserved */ #endif - unsigned ampdu_cnt:8; /**< ampdu cnt */ + unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */ unsigned channel:4; /**< primary channel on which this packet is received */ unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ unsigned :8; /**< reserved */ @@ -571,9 +573,9 @@ typedef struct { wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ uint8_t mac[6]; /**< source MAC address of the CSI data */ uint8_t dmac[6]; /**< destination MAC address of the CSI data */ - bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not */ - int8_t *buf; /**< buffer of CSI data */ - uint16_t len; /**< length of CSI data */ + bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */ + int8_t *buf; /**< valid buffer of CSI data */ + uint16_t len; /**< valid length of CSI data */ } wifi_csi_info_t; /** From 24da38f63cbd29a5bc747fb52c4e27bdf93cafcd Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 8 Sep 2023 11:46:12 +0800 Subject: [PATCH 13/15] fix(wifi): fix some wifi bugs 20231214 1. add support for espnow to seet dcm rate 2. bugfix: fix csi info is not correct 3. feature: add support for establishing over 4 rx ba sessions 4. sniffer: modified rx error dump in sniffer mode 5. fix(itwt): fix when receiving the twt setup response frame, twt tx cb has not yet been called 6. itwt: fix itwt information frame format is not correct when suspend time is 0 7. update esp_wifi_crypto_types.h 8. sta not pmf capable when ap requires should reject profile 9. fix softap set config issue 10. allow some special igtk keyindex to workaround faulty APs 11. fix psram enabled but initialized fail issue 12. add missing header files for wifi files 13. feat(wifi/vendor): get more wifi information in csi rx callback --- components/esp_wifi/include/esp_wifi_types.h | 3 +++ components/esp_wifi/lib | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 163cb3b3936..facec5f6815 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -576,6 +576,9 @@ typedef struct { bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */ int8_t *buf; /**< valid buffer of CSI data */ uint16_t len; /**< valid length of CSI data */ + uint8_t *hdr; /**< header of the wifi packet */ + uint8_t *payload; /**< payload of the wifi packet */ + uint16_t payload_len; /**< payload len of the wifi packet */ } wifi_csi_info_t; /** diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index b9944486f94..9bb605e822e 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit b9944486f94cb80c5ec8a1fac2bbc9a6dcae8d6a +Subproject commit 9bb605e822e5fa473448aa6a80b740e09c3c8df2 From f841f0ae52ee76c3c347d67df38ed7aa28bfbf72 Mon Sep 17 00:00:00 2001 From: Vikram Dattu Date: Mon, 27 Nov 2023 11:57:55 +0530 Subject: [PATCH 14/15] fix(esp_srp): Use `@file` for file documentation and missing doc Using @brief for file description wrongly associates the documentation to an API. Correct way to add file description is to use `@file` and then `@brief`. Corrected the same. - Also added missing doc for esp_srp_handle_t --- components/protocomm/include/crypto/srp6a/esp_srp.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/protocomm/include/crypto/srp6a/esp_srp.h b/components/protocomm/include/crypto/srp6a/esp_srp.h index 23db7db35c1..b02d78a5b57 100644 --- a/components/protocomm/include/crypto/srp6a/esp_srp.h +++ b/components/protocomm/include/crypto/srp6a/esp_srp.h @@ -13,6 +13,7 @@ extern "C" { #endif /** + * @file esp_srp.h * @brief SRP-6a protocol implementation * * More information on protocol can be found: https://datatracker.ietf.org/doc/html/rfc5054 @@ -98,6 +99,13 @@ typedef enum { ESP_NG_3072 = 0, } esp_ng_type_t; +/** + * @brief esp_srp handle as the result of `esp_srp_init` + * + * The handle is returned by `esp_srp_init` on successful init. It is then + * passed for subsequent API calls as an argument. `esp_srp_free` can be used to + * clean up the handle. After `esp_srp_free` the handle becomes invalid. + */ typedef struct esp_srp_handle esp_srp_handle_t; /** From b0493e0f6b165b5c88925bea2b83dda54793e87c Mon Sep 17 00:00:00 2001 From: Vikram Dattu Date: Wed, 29 Nov 2023 11:28:45 +0530 Subject: [PATCH 15/15] fix(docs): fixed doxygen warnings in few headers - non-matching arguments in `i2c_types.h` and `esp_wifi_crypto_types.h` - Fixed unended `@cond` macro in `esp_err.h` --- components/esp_common/include/esp_err.h | 1 - 1 file changed, 1 deletion(-) diff --git a/components/esp_common/include/esp_err.h b/components/esp_common/include/esp_err.h index d6b2e301d2c..ac66e0c3350 100644 --- a/components/esp_common/include/esp_err.h +++ b/components/esp_common/include/esp_err.h @@ -78,7 +78,6 @@ const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen); /** @cond */ void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((__noreturn__)); -/** @cond */ void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression); #ifndef __ASSERT_FUNC