From f9ef78528ea30b20c0f61f0c08114003a984deb9 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 27 Sep 2024 15:23:18 +0800 Subject: [PATCH 1/2] docs(wifi/espnow): Update the description for ESP-NOW frame --- components/esp_wifi/include/esp_now.h | 10 ++++--- docs/en/api-reference/network/esp_now.rst | 27 ++++++++++++------- docs/zh_CN/api-reference/network/esp_now.rst | 28 ++++++++++++-------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 0f01054d8c..1d9a8dd71f 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -49,7 +49,8 @@ extern "C" { #define ESP_NOW_MAX_TOTAL_PEER_NUM 20 /*!< Maximum number of ESPNOW total peers */ #define ESP_NOW_MAX_ENCRYPT_PEER_NUM 6 /*!< Maximum number of ESPNOW encrypted peers */ -#define ESP_NOW_MAX_DATA_LEN 250 /*!< Maximum length of ESPNOW data which is sent very time */ +#define ESP_NOW_MAX_IE_DATA_LEN 250 /**< Maximum data length in a vendor-specific element */ +#define ESP_NOW_MAX_DATA_LEN ESP_NOW_MAX_IE_DATA_LEN /**< Maximum length of data sent in each ESPNOW transmission for v1.0 */ /** * @brief Status of sending ESPNOW data . @@ -135,7 +136,10 @@ esp_err_t esp_now_init(void); esp_err_t esp_now_deinit(void); /** - * @brief Get the version of ESPNOW + * @brief Get the version of ESPNOW. Currently, ESPNOW supports one version: v1.0. + * + * The v1.0 devices can receive packets if the packet length is less than or equal to ESP_NOW_MAX_IE_DATA_LEN. + * For packets exceeding this length, the v1.0 devices will discard the packet entirely. * * @param version ESPNOW version * diff --git a/docs/en/api-reference/network/esp_now.rst b/docs/en/api-reference/network/esp_now.rst index 2e6974c88c..4bec914dca 100644 --- a/docs/en/api-reference/network/esp_now.rst +++ b/docs/en/api-reference/network/esp_now.rst @@ -13,7 +13,12 @@ CTR with CBC-MAC Protocol (CCMP) is used to protect the action frame for securit Frame Format ------------ -ESP-NOW uses a vendor-specific action frame to transmit ESP-NOW data. The default ESP-NOW bit rate is 1 Mbps. The format of the vendor-specific action frame is as follows: +ESP-NOW uses a vendor-specific action frame to transmit ESP-NOW data. The default ESP-NOW bit rate is 1 Mbps. + +Currently, ESP-NOW supports one version: v1.0. The maximum packet length supported by v1.0 devices is ESP_NOW_MAX_DATA_LEN bytes. +The v1.0 devices can receive packets if the packet length is less than or equal to ESP_NOW_MAX_IE_DATA_LEN. For packets exceeding this length, the v1.0 devices will discard the packet entirely. + +The format of the vendor-specific action frame is as follows: .. highlight:: none @@ -22,28 +27,32 @@ ESP-NOW uses a vendor-specific action frame to transmit ESP-NOW data. The defaul ------------------------------------------------------------------------------------------------------------ | MAC Header | Category Code | Organization Identifier | Random Values | Vendor Specific Content | FCS | ------------------------------------------------------------------------------------------------------------ - 24 bytes 1 byte 3 bytes 4 bytes 7-257 bytes 4 bytes + 24 bytes 1 byte 3 bytes 4 bytes 7-x bytes 4 bytes - Category Code: The Category Code field is set to the value (127) indicating the vendor-specific category. - Organization Identifier: The Organization Identifier contains a unique identifier (0x18fe34), which is the first three bytes of MAC address applied by Espressif. - Random Value: The Random Value filed is used to prevents relay attacks. -- Vendor Specific Content: The Vendor Specific Content contains vendor-specific fields as follows: +- Vendor Specific Content: The Vendor Specific Content contains one vendor-specific element field, x = 257(250 + 7). + +The format of the vendor-specific element frame is as follows: .. highlight:: none :: - ------------------------------------------------------------------------------- - | Element ID | Length | Organization Identifier | Type | Version | Body | - ------------------------------------------------------------------------------- - 1 byte 1 byte 3 bytes 1 byte 1 byte 0-250 bytes + ------------------------------------------------------------------------------------------ + | Element ID | Length | Organization Identifier | Type | Reserved | Version | Body | + ------------------------------------------------------------------------------------------ + 7~4 bits | 3~0 bits + 1 byte 1 byte 3 bytes 1 byte 1 byte 0-250 bytes + - Element ID: The Element ID field is set to the value (221), indicating the vendor-specific element. -- Length: The length is the total length of Organization Identifier, Type, Version and Body. +- Length: The length is the total length of Organization Identifier, Type, Version and Body, the maximum value is 255. - Organization Identifier: The Organization Identifier contains a unique identifier (0x18fe34), which is the first three bytes of MAC address applied by Espressif. - Type: The Type field is set to the value (4) indicating ESP-NOW. - Version: The Version field is set to the version of ESP-NOW. -- Body: The Body contains the ESP-NOW data. +- Body: The Body contains the actual ESP-NOW data to be transmitted. As ESP-NOW is connectionless, the MAC header is a little different from that of standard frames. The FromDS and ToDS bits of FrameControl field are both 0. The first address field is set to the destination address. The second address field is set to the source address. The third address field is set to broadcast address (0xff:0xff:0xff:0xff:0xff:0xff). diff --git a/docs/zh_CN/api-reference/network/esp_now.rst b/docs/zh_CN/api-reference/network/esp_now.rst index 560a7ffda7..dbb7af47b4 100644 --- a/docs/zh_CN/api-reference/network/esp_now.rst +++ b/docs/zh_CN/api-reference/network/esp_now.rst @@ -13,37 +13,43 @@ CTR 与 CBC-MAC 协议 (CCMP) 可用来保护动作帧的安全。ESP-NOW 广泛 帧格式 ------------ -ESP-NOW 使用各个供应商的动作帧传输数据,默认比特率为 1 Mbps。各个供应商的动作帧格式为: +ESP-NOW 使用供应商的动作帧传输数据,默认比特率为 1 Mbps。目前 ESP-NOW 支持一个版本: v1.0。v1.0 的设备支持的最大数据包长度为 ESP_NOW_MAX_DATA_LEN bytes。 +v1.0 设备可以接收长度不超过 ESP_NOW_MAX_IE_DATA_LEN 的数据包,而对于长度超过 ESP_NOW_MAX_IE_DATA_LEN 的数据包,会丢弃数据包。 + +供应商的动作帧格式为: .. highlight:: none :: - ----------------------------------------------------------------------------------------- + ----------------------------------------------------------------------------- | MAC 报头 | 分类代码 | 组织标识符 | 随机值 | 供应商特定内容 | FCS | - ----------------------------------------------------------------------------------------- - 24 字节 1 字节 3 字节 4 字节 7-257 字节 4 字节 + ----------------------------------------------------------------------------- + 24 字节 1 字节 3 字节 4 字节 7-x 字节 4 字节 - 分类代码:分类代码字段可用于指示各个供应商的类别(比如 127)。 - 组织标识符:组织标识符包含一个唯一标识符(比如 0x18fe34),为乐鑫指定的 MAC 地址的前三个字节。 - 随机值:防止重放攻击。 -- 供应商特定内容:供应商特定内容包含供应商特定字段,如下所示: +- 供应商特定内容:供应商特定内容包含一个特定供应商元素字段,x = 257(250+7)。 + +特定供应商元素的帧格式为: .. highlight:: none :: - ---------------------------------------------------------------------------------------- - | 元素 ID | 长度 | 组织标识符 | 类型 | 版本 | 正文 | - ---------------------------------------------------------------------------------------- - 1 字节 1 字节 3 字节 1 字节 1 字节 0-250 字节 + --------------------------------------------------------------------------- + | 元素 ID | 长度 | 组织标识符 | 类型 | 保留 | 版本 | 正文 | + --------------------------------------------------------------------------- + 7~4 比特| 3~0 比特 + 1 字节 1 字节 3 字节 1 字节 1 字节 0-250 字节 - 元素 ID:元素 ID 字段可用于指示特定于供应商的元素。 -- 长度:长度是组织标识符、类型、版本和正文的总长度。 +- 长度:长度是组织标识符、类型、版本和正文的总长度,最大值为 255。 - 组织标识符:组织标识符包含一个唯一标识符(比如 0x18fe34),为乐鑫指定的 MAC 地址的前三个字节。 - 类型:类型字段设置为 4,代表 ESP-NOW。 - 版本:版本字段设置为 ESP-NOW 的版本。 -- 正文:正文包含 ESP-NOW 数据。 +- 正文:正文包含实际要发送的 ESP-NOW 数据。 由于 ESP-NOW 是无连接的,因此 MAC 报头与标准帧略有不同。FrameControl 字段的 FromDS 和 ToDS 位均为 0。第一个地址字段用于配置目标地址。第二个地址字段用于配置源地址。第三个地址字段用于配置广播地址 (0xff:0xff:0xff:0xff:0xff:0xff)。 From 5a354837a83fb0aba4261d6d2aaeb20725abc49f Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 14 Nov 2024 10:42:42 +0800 Subject: [PATCH 2/2] fix(wifi): Optimization for wifi components 1. fix(wifi/pm): Fixed the tbtt interval update error when AP's beacon interval changed Closes https://github.com/espressif/esp-idf/issues/14720 2. fix(wifi/mesh): Enlarge the mesh TX task stack 3. fix(wifi/espnow): Added check for espnow type and length on v1.0 4. fix(wifi/mesh): Fixed delete group id error in wifi mesh Closes https://github.com/espressif/esp-idf/issues/14735 --- 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 caa74e6d3d..e0f9d9d333 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit caa74e6d3d084d1e68b97b8ebc91a4e12f610f73 +Subproject commit e0f9d9d333e5ed484e62ebbf0349a079bfc45092