From 5c1ff3d70b3d11e6534810c82be42d3a1126ea33 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Wed, 3 Aug 2022 17:26:33 +0800 Subject: [PATCH 1/6] Modify maximum softap conn num and espnow encryption peer num --- components/esp_wifi/Kconfig | 15 ++++++++++++ .../esp_wifi/include/esp_mesh_internal.h | 23 ++++++++----------- components/esp_wifi/include/esp_wifi.h | 2 ++ components/esp_wifi/include/esp_wifi_types.h | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index f76a50755f..5be0a8afe2 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -372,4 +372,19 @@ menu "Wi-Fi" Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will be delayed for the time specified by the configuration item. Unit: 1024 microsecond. + config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM + int "Maximum espnow encrypt peers number" + range 0 4 if IDF_TARGET_ESP32C2 + range 0 16 if (!IDF_TARGET_ESP32C2) + default 2 if IDF_TARGET_ESP32C2 + default 6 if !IDF_TARGET_ESP32C2 + help + Maximum number of encrypted peers supported by espnow. + The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same + hardware keys. So this configuration will affect the maximum connection number of SoftAP. + Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware keys number. + + When using ESP mesh, this value should be set to a maximum of 6. + + endmenu # Wi-Fi diff --git a/components/esp_wifi/include/esp_mesh_internal.h b/components/esp_wifi/include/esp_mesh_internal.h index e967dbaafb..af602bb548 100644 --- a/components/esp_wifi/include/esp_mesh_internal.h +++ b/components/esp_wifi/include/esp_mesh_internal.h @@ -1,16 +1,8 @@ -// Copyright 2017-2018 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: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_MESH_INTERNAL_H__ #define __ESP_MESH_INTERNAL_H__ @@ -107,6 +99,9 @@ typedef struct { mesh_chain_layer_t chain; } __attribute__((packed)) mesh_chain_assoc_t; +/* mesh max connections */ +#define MESH_MAX_CONNECTIONS (10) + /** * @brief Mesh PS duties */ @@ -117,7 +112,7 @@ typedef struct { bool used; uint8_t duty; uint8_t mac[6]; - } child[ESP_WIFI_MAX_CONN_NUM]; + } child[MESH_MAX_CONNECTIONS]; } esp_mesh_ps_duties_t; /******************************************************* diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index f1e9468a9d..a05c359a40 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -108,6 +108,7 @@ typedef struct { int mgmt_sbuf_num; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */ uint64_t feature_caps; /**< Enables additional WiFi features and capabilities */ bool sta_disconnected_pm; /**< WiFi Power Management for station at disconnected status */ + int espnow_max_encrypt_num; /**< Maximum encrypt number of peers supported by espnow */ int magic; /**< WiFi init magic number, it should be the last field */ } wifi_init_config_t; @@ -227,6 +228,7 @@ extern uint64_t g_wifi_feature_caps; .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \ .feature_caps = g_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/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 9c66f252f1..1bc273be67 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -305,7 +305,7 @@ typedef struct { uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; -#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */ +#define ESP_WIFI_MAX_CONN_NUM (16) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2/ESP32C3 soft-AP */ /** @brief List of stations associated with the ESP32 Soft-AP */ typedef struct { From 3823a991db9076d0acf752a9c46a0c182b3b6777 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Wed, 3 Aug 2022 17:50:21 +0800 Subject: [PATCH 2/6] update doc for espnow max encryped connection --- docs/en/api-reference/network/esp_now.rst | 8 ++------ docs/zh_CN/api-reference/network/esp_now.rst | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index f723ba1fd0..70ff76d0c4 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -66,13 +66,9 @@ Add Paired Device Call :cpp:func:`esp_now_add_peer()` to add the device to the paired device list before you send data to this device. If security is enabled, the LMK must be set. You can send ESP-NOW data via both the Station and the SoftAP interface. Make sure that the interface is enabled before sending ESP-NOW data. -.. only:: esp32c3 +.. only:: esp32 or esp32s2 or esp32s3 or esp32c3 - The maximum number of paired devices is 20, and the paired encryption devices are no more than 10, the default is 6. - -.. only:: esp32 or esp32s2 or esp32s3 - - The maximum number of paired devices is 20, and the paired encryption devices are no more than 16, the default is 6. + The maximum number of paired devices is 20, and the paired encryption devices are no more than 16, the default is 6. If you want to change the number of paired encryption devices, set :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM` in WiFi component configuration menu. A device with a broadcast MAC address must be added before sending broadcast data. The range of the channel of paired devices is from 0 to 14. If the channel is set to 0, data will be sent on the current channel. Otherwise, the channel must be set as the channel that the local device is on. diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index 05ce8b6e57..c2a2bc8856 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -66,13 +66,9 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参 在将数据发送到其他设备之前,请先调用 :cpp:func:`esp_now_add_peer()` 将其添加到配对设备列表中。如果启用了加密,则必须设置 LMK。ESP-NOW 数据可以从 Station 或 Softap 接口发送。确保在发送 ESP-NOW 数据之前已启用该接口。 -.. only:: esp32c3 +.. only:: esp32 or esp32s2 or esp32s3 or esp32c3 - 配对设备的最大数量是 20,其中加密设备的数量不超过 10,默认值是 6。 - -.. only:: esp32 or esp32s2 or esp32s3 - - 配对设备的最大数量是 20,其中加密设备的数量不超过 16,默认值是 6。 + 配对设备的最大数量是 20,其中加密设备的数量不超过 16,默认值是 6。如果想要修改加密设备的数量,在 WiFi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。 在发送广播数据之前必须添加具有广播 MAC 地址的设备。配对设备的信道范围是从 0 ~14。如果信道设置为 0,数据将在当前信道上发送。否则,必须使用本地设备所在的通道。 From 2bbd3ac583396232aab9a7d9bd9cf4b6cb7b38b1 Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Wed, 9 Nov 2022 13:30:32 +0530 Subject: [PATCH 3/6] esp_wifi:Add wifi station config for enabling transition_disbale feature --- components/esp_wifi/include/esp_wifi_types.h | 3 ++- .../wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c | 9 +++++++++ .../wpa_supplicant/esp_supplicant/src/esp_wpas_glue.h | 2 ++ components/wpa_supplicant/src/common/wpa_common.h | 4 ++++ components/wpa_supplicant/src/rsn_supp/wpa.c | 5 +++-- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 1bc273be67..029aeebb83 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -277,7 +277,8 @@ typedef struct { uint32_t rm_enabled:1; /**< Whether Radio Measurements are enabled for the connection */ uint32_t btm_enabled:1; /**< Whether BSS Transition Management is enabled for the connection */ uint32_t mbo_enabled:1; /**< Whether MBO is enabled for the connection */ - uint32_t reserved:29; /**< Reserved for future feature set */ + uint32_t transition_disable:1; /**< Whether to enable transition disable feature */ + uint32_t reserved:28; /**< Reserved for future feature set */ wifi_sae_pwe_method_t sae_pwe_h2e; /**< Whether SAE hash to element is enabled */ uint8_t failure_retry_cnt; /**< Number of connection retries station will do before moving to next AP. scan_method should be set as WIFI_ALL_CHANNEL_SCAN to use this config. Note: Enabling this may cause connection time to increase incase best AP doesn't behave properly. */ } wifi_sta_config_t; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c index 1e3fc424c7..1cf6686a69 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c @@ -61,6 +61,15 @@ void wpa_sm_free_eapol(u8 *buffer) os_free(buffer); } +void wpa_supplicant_transition_disable(void *sm, u8 bitmap) +{ + wpa_printf(MSG_INFO, "TRANSITION_DISABLE %02x", bitmap); + + if (bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) { + esp_wifi_sta_disable_wpa2_authmode_internal(); + } +} + void wpa_sm_deauthenticate(struct wpa_sm *sm, u8 reason_code) { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.h b/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.h index 4d867962e7..24dff6184e 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.h @@ -30,4 +30,6 @@ int wpa_sm_get_beacon_ie(struct wpa_sm *sm); void wpa_sm_free_eapol(u8 *buffer); +void wpa_supplicant_transition_disable(void *sm, u8 bitmap); + #endif /* WPAS_GLUE_H */ diff --git a/components/wpa_supplicant/src/common/wpa_common.h b/components/wpa_supplicant/src/common/wpa_common.h index 9a4b619cfb..e38af8cc5f 100644 --- a/components/wpa_supplicant/src/common/wpa_common.h +++ b/components/wpa_supplicant/src/common/wpa_common.h @@ -311,6 +311,10 @@ struct rsn_rdie { #endif /* CONFIG_IEEE80211R */ +/* WFA Transition Disable KDE (using OUI_WFA) */ +/* Transition Disable Bitmap bits */ +#define TRANSITION_DISABLE_WPA3_PERSONAL BIT(0) + struct wpa_ie_data { int proto; int pairwise_cipher; diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index 9a9e0fd3d1..b00250e758 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -1264,8 +1264,9 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, goto failed; } - if (ie.transition_disable) - esp_wifi_sta_disable_wpa2_authmode_internal(); + if (ie.transition_disable) { + wpa_supplicant_transition_disable(sm, ie.transition_disable[0]); + } if (sm->key_install && sm->key_info & WPA_KEY_INFO_INSTALL && sm->use_ext_key_id) { wpa_supplicant_install_ptk(sm, KEY_FLAG_RX); From e943143e0f5ac60ab7eb3d23cce08d8d2aef07ca Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Mon, 28 Nov 2022 16:09:24 +0800 Subject: [PATCH 4/6] esp_wifi: fix esp32c3 connect fail Closes IDFCI-1524 --- components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index e5723fc2b9..60affc6741 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1716,7 +1716,7 @@ ic_reset_rx_ba = 0x4000184c; ieee80211_align_eb = 0x40001850; ieee80211_ampdu_reorder = 0x40001854; ieee80211_ampdu_start_age_timer = 0x40001858; -ieee80211_encap_esfbuf = 0x4000185c; +/*ieee80211_encap_esfbuf = 0x4000185c;*/ ieee80211_is_tx_allowed = 0x40001860; ieee80211_output_pending_eb = 0x40001864; ieee80211_output_process = 0x40001868; From 43f93678cebe73e3c2252d7196f5c03a4e87cba3 Mon Sep 17 00:00:00 2001 From: jack Date: Wed, 7 Dec 2022 18:03:57 +0800 Subject: [PATCH 5/6] reduce the max connection number to 15 --- components/esp_wifi/Kconfig | 7 +++---- components/esp_wifi/include/esp_wifi_types.h | 6 +++++- docs/en/api-reference/network/esp_now.rst | 8 ++++++-- docs/zh_CN/api-reference/network/esp_now.rst | 8 ++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 5be0a8afe2..d2b67e3abe 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -374,10 +374,9 @@ menu "Wi-Fi" config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM int "Maximum espnow encrypt peers number" - range 0 4 if IDF_TARGET_ESP32C2 - range 0 16 if (!IDF_TARGET_ESP32C2) - default 2 if IDF_TARGET_ESP32C2 - default 6 if !IDF_TARGET_ESP32C2 + range 0 10 if IDF_TARGET_ESP32C3 + range 0 15 if (!IDF_TARGET_ESP32C3) + default 6 help Maximum number of encrypted peers supported by espnow. The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 029aeebb83..7da6f0eb36 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -306,7 +306,11 @@ typedef struct { uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; -#define ESP_WIFI_MAX_CONN_NUM (16) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2/ESP32C3 soft-AP */ +#if CONFIG_IDF_TARGET_ESP32C3 +#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32C3 soft-AP */ +#else +#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ +#endif /** @brief List of stations associated with the ESP32 Soft-AP */ typedef struct { diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index 70ff76d0c4..0177c2ab7a 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -66,9 +66,13 @@ Add Paired Device Call :cpp:func:`esp_now_add_peer()` to add the device to the paired device list before you send data to this device. If security is enabled, the LMK must be set. You can send ESP-NOW data via both the Station and the SoftAP interface. Make sure that the interface is enabled before sending ESP-NOW data. -.. only:: esp32 or esp32s2 or esp32s3 or esp32c3 +.. only:: esp32c3 - The maximum number of paired devices is 20, and the paired encryption devices are no more than 16, the default is 6. If you want to change the number of paired encryption devices, set :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM` in WiFi component configuration menu. + The maximum number of paired devices is 20, and the paired encryption devices are no more than 10, the default is 6. If you want to change the number of paired encryption devices, set :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM` in WiFi component configuration menu. + +.. only:: esp32 or esp32s2 or esp32s3 + + The maximum number of paired devices is 20, and the paired encryption devices are no more than 15, the default is 6. If you want to change the number of paired encryption devices, set :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM` in WiFi component configuration menu. A device with a broadcast MAC address must be added before sending broadcast data. The range of the channel of paired devices is from 0 to 14. If the channel is set to 0, data will be sent on the current channel. Otherwise, the channel must be set as the channel that the local device is on. diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index c2a2bc8856..3437c57c32 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -66,9 +66,13 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参 在将数据发送到其他设备之前,请先调用 :cpp:func:`esp_now_add_peer()` 将其添加到配对设备列表中。如果启用了加密,则必须设置 LMK。ESP-NOW 数据可以从 Station 或 Softap 接口发送。确保在发送 ESP-NOW 数据之前已启用该接口。 -.. only:: esp32 or esp32s2 or esp32s3 or esp32c3 +.. only:: esp32c3 - 配对设备的最大数量是 20,其中加密设备的数量不超过 16,默认值是 6。如果想要修改加密设备的数量,在 WiFi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。 + 配对设备的最大数量是 20,其中加密设备的数量不超过 10,默认值是 6。如果想要修改加密设备的数量,在 WiFi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。 + +.. only:: esp32 or esp32s2 or esp32s3 + + 配对设备的最大数量是 20,其中加密设备的数量不超过 15,默认值是 6。如果想要修改加密设备的数量,在 WiFi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。 在发送广播数据之前必须添加具有广播 MAC 地址的设备。配对设备的信道范围是从 0 ~14。如果信道设置为 0,数据将在当前信道上发送。否则,必须使用本地设备所在的通道。 From a34a4a91fbd09cbbd326ed82952325ad381d2963 Mon Sep 17 00:00:00 2001 From: jack Date: Wed, 7 Dec 2022 11:49:36 +0800 Subject: [PATCH 6/6] esp_wifi: update wifi lib 1. Modify wifi max connection num 2. Fix the ESPNOW senf fail after changing opmode 3.Add wifi station config for enabling transition_disbale feature --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 5ca3788624..309d6435ef 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 5ca3788624cd81ba5d8f8d9f62934050318ac13d +Subproject commit 309d6435ef2e873d771c23ea4ed19cfad3b825b2