From d11ee31bf119400a5eb366f7882c4238e85b107e Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Wed, 3 Aug 2022 17:26:33 +0800 Subject: [PATCH 1/3] 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 +- tools/ci/check_copyright_ignore.txt | 1 - 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index de3c6c9f3b..211598a2cc 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -385,4 +385,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 abb403be44..f065bc50e9 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -107,6 +107,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; @@ -225,6 +226,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 239a66e1f6..3c010a6ce3 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -315,7 +315,7 @@ typedef struct { #if CONFIG_IDF_TARGET_ESP32C2 #define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ #else -#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 */ #endif /** @brief List of stations associated with the ESP32 Soft-AP */ diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 7ffee83210..f62845e8d0 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -601,7 +601,6 @@ components/esp_system/test_eh_frame_parser/eh_frame_parser_impl.h components/esp_system/test_eh_frame_parser/esp_private/panic_internal.h components/esp_system/test_eh_frame_parser/linker.ld components/esp_system/ubsan.c -components/esp_wifi/include/esp_mesh_internal.h components/esp_wifi/include/esp_private/esp_wifi_types_private.h components/esp_wifi/include/esp_private/wifi_types.h components/esp_wifi/include/esp_smartconfig.h From 8683a2622e123f712ee79a14557dd397172d33e1 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Wed, 3 Aug 2022 17:50:21 +0800 Subject: [PATCH 2/3] update doc for espnow max encryped connection --- docs/en/api-reference/network/esp_now.rst | 10 +++------- docs/zh_CN/api-reference/network/esp_now.rst | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index a5bbd0dad4..fcd09393b2 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -68,15 +68,11 @@ Call :cpp:func:`esp_now_add_peer()` to add the device to the paired device list .. only:: esp32c2 - The maximum number of paired devices is 20, and the paired encryption devices are no more than 4, the default is 2. + The maximum number of paired devices is 20, and the paired encryption devices are no more than 4, the default is 2. 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:: 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 cffc9438e9..0be251dc36 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -68,15 +68,11 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参 .. only:: esp32c2 - 配对设备的最大数量是 20,其中加密设备的数量不超过 4,默认值是 2。 + 配对设备的最大数量是 20,其中加密设备的数量不超过 4,默认值是 2。如果想要修改加密设备的数量,在 WiFi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。 -.. 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 fbbb762a4e89924c2b1be9fffc4c1efd4088605c Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 17 Nov 2022 16:03:25 +0800 Subject: [PATCH 3/3] update wifi lib: 1. Modify wifi max connection num 2. Fix the ESPNOW senf fail after changing opmode Closes IDFGH-7960 Closes WIFI-4176 Closes WIFI-5004 --- 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 b10fa11471..f6339efe87 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit b10fa11471b69b82f9599aa2941e1c353bd517c1 +Subproject commit f6339efe87a713de50b998cb7483d5c5fb72c6f8