fix(docs): update max data length in espnow doc

This commit is contained in:
zhangyanjiao
2025-03-20 18:01:00 +08:00
parent 5bf37234b8
commit c5a61099c1
2 changed files with 14 additions and 8 deletions

View File

@@ -15,7 +15,8 @@ Frame Format
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 two versions: v1.0 and v2.0. The maximum packet length supported by v2.0 devices is ESP_NOW_MAX_DATA_LEN_V2 bytes, while the maximum packet length supported by v1.0 devices is ESP_NOW_MAX_DATA_LEN bytes.
Currently, ESP-NOW supports two versions: v1.0 and v2.0. The maximum packet length supported by v2.0 devices is 1470 (``ESP_NOW_MAX_DATA_LEN_V2``) bytes, while the maximum packet length supported by v1.0 devices is 250 (``ESP_NOW_MAX_DATA_LEN``) bytes.
The v2.0 devices are capable of receiving packets from both v2.0 and v1.0 devices. In contrast, v1.0 devices can only receive packets from other v1.0 devices.
However, v1.0 devices can receive v2.0 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 either truncate the data to the first ESP_NOW_MAX_IE_DATA_LEN bytes or discard the packet entirely.
@@ -35,7 +36,7 @@ The format of the vendor-specific action frame is as follows:
- 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 several (at least one) vendor-specific element fields. For version v2.0, x = 1532(1490 + 6*7), for version v1.0, x = 257(250 + 7).
- Vendor Specific Content: The Vendor Specific Content contains several (at least one) vendor-specific element fields. For version v2.0, x = 1512(1470 + 6*7), for version v1.0, x = 257(250 + 7).
The format of the vendor-specific element frame is as follows:
@@ -107,7 +108,7 @@ Send ESP-NOW Data
Call :cpp:func:`esp_now_send()` to send ESP-NOW data and :cpp:func:`esp_now_register_send_cb()` to register sending callback function. It will return `ESP_NOW_SEND_SUCCESS` in sending callback function if the data is received successfully on the MAC layer. Otherwise, it will return `ESP_NOW_SEND_FAIL`. Several reasons can lead to ESP-NOW fails to send data. For example, the destination device does not exist; the channels of the devices are not the same; the action frame is lost when transmitting on the air, etc. It is not guaranteed that application layer can receive the data. If necessary, send back ack data when receiving ESP-NOW data. If receiving ack data timeouts, retransmit the ESP-NOW data. A sequence number can also be assigned to ESP-NOW data to drop the duplicate data.
If there is a lot of ESP-NOW data to send, call :cpp:func:`esp_now_send()` to send less than or equal to 250 bytes of data once a time. Note that too short interval between sending two ESP-NOW data may lead to disorder of sending callback function. So, it is recommended that sending the next ESP-NOW data after the sending callback function of the previous sending has returned. The sending callback function runs from a high-priority Wi-Fi task. So, do not do lengthy operations in the callback function. Instead, post the necessary data to a queue and handle it from a lower priority task.
If there is a lot of ESP-NOW data to send, call :cpp:func:`esp_now_send()` to send less than or equal to the maximum packet length (v1.0 is 250 bytes, v2.0 is 1470 bytes) of data once a time. Note that too short interval between sending two ESP-NOW data may lead to disorder of sending callback function. So, it is recommended that sending the next ESP-NOW data after the sending callback function of the previous sending has returned. The sending callback function runs from a high-priority Wi-Fi task. So, do not do lengthy operations in the callback function. Instead, post the necessary data to a queue and handle it from a lower priority task.
Receiving ESP-NOW Data
----------------------

View File

@@ -13,10 +13,15 @@ CTR 与 CBC-MAC 协议 (CCMP) 可用来保护动作帧的安全。ESP-NOW 广泛
帧格式
------------
ESP-NOW 使用供应商的动作帧传输数据,默认比特率为 1 Mbps。目前 ESP-NOW 支持两个版本: v1.0 和 v2.0。
ESP-NOW 使用供应商的动作帧传输数据,默认比特率为 1 Mbps。
v2.0 的设备支持的最大数据包长度为 ESP_NOW_MAX_DATA_LEN_V2 bytes v1.0 的设备支持的最大数据包长度为 ESP_NOW_MAX_DATA_LEN bytes
v2.0 设备可以接收来自 v2.0 和 v1.0 设备的数据包。v1.0 设备能接收来自 v1.0 的数据包。v1.0 设备可以接收长度不超过 ESP_NOW_MAX_IE_DATA_LEN 的 v2.0 数据包,而对于长度超过 ESP_NOW_MAX_IE_DATA_LEN 的数据包,它要么只接收前 ESP_NOW_MAX_IE_DATA_LEN 字节,要么丢弃数据包。具体行为请参考对应 IDF 版本中的文档。
目前 ESP-NOW 支持两个版本v1.0 和 v2.0。v2.0 的设备支持的最大数据包长度为 1470 (``ESP_NOW_MAX_DATA_LEN_V2``) 字节;v1.0 的设备支持的最大数据包长度为 250 (``ESP_NOW_MAX_DATA_LEN``) 字节
v2.0 设备可以接收来自 v2.0 和 v1.0 设备的数据包。v1.0 设备只能接收来自 v1.0 设备的数据包。
当然v1.0 设备也可以接收长度不超过 250 (``ESP_NOW_MAX_IE_DATA_LEN``) 的 v2.0 数据包,只是如果长度超过此值,就只接收前 250 (``ESP_NOW_MAX_IE_DATA_LEN``) 字节,或是直接丢弃数据包。
具体行为请参考对应 IDF 版本中的文档。
供应商的动作帧格式为:
@@ -32,7 +37,7 @@ v2.0 设备可以接收来自 v2.0 和 v1.0 设备的数据包。v1.0 设备能
- 分类代码:分类代码字段可用于指示各个供应商的类别(比如 127
- 组织标识符:组织标识符包含一个唯一标识符(比如 0x18fe34为乐鑫指定的 MAC 地址的前三个字节。
- 随机值:防止重放攻击。
- 供应商特定内容供应商特定内容包含若干个大于等于1特定供应商元素字段对于 v2.0 版本x = 1532(1490+6*7);对于 v1.0 版本x = 257(250+7)。
- 供应商特定内容供应商特定内容包含若干个大于等于1特定供应商元素字段对于 v2.0 版本x = 1512(1470+6*7);对于 v1.0 版本x = 257(250+7)。
特定供应商元素的帧格式为:
@@ -104,7 +109,7 @@ ESP-NOW 数据可以从 Station 或 SoftAP 接口发送。确保在发送 ESP-NO
调用 :cpp:func:`esp_now_send()` 发送 ESP-NOW 数据,调用 :cpp:func:`esp_now_register_send_cb` 注册发送回调函数。如果 MAC 层成功接收到数据,则该函数将返回 `ESP_NOW_SEND_SUCCESS` 事件。否则,它将返回 `ESP_NOW_SEND_FAIL`。ESP-NOW 数据发送失败可能有几种原因,比如目标设备不存在、设备的信道不相同、动作帧在传输过程中丢失等。应用层并不一定可以总能接收到数据。如果需要,应用层可在接收 ESP-NOW 数据时发回一个应答 (ACK) 数据。如果接收 ACK 数据超时,则将重新传输 ESP-NOW 数据。可以为 ESP-NOW 数据设置序列号,从而删除重复的数据。
如果有大量 ESP-NOW 数据要发送,调用 ``esp_now_send()`` 时需注意单次发送的数据不能超过 250 字节。请注意,两个 ESP-NOW 数据包的发送间隔太短可能导致回调函数返回混乱。因此,建议在等到上一次回调函数返回 ACK 后再发送下一个 ESP-NOW 数据。发送回调函数从高优先级的 Wi-Fi 任务中运行。因此,不要在回调函数中执行冗长的操作。相反,将必要的数据发布到队列,并交给优先级较低的任务处理。
如果有大量 ESP-NOW 数据要发送,调用 ``esp_now_send()`` 时需注意单次发送的数据不能超过最大数据包长v1.0 是 250 bytes v2.0 是 1470 字节。请注意,两个 ESP-NOW 数据包的发送间隔太短可能导致回调函数返回混乱。因此,建议在等到上一次回调函数返回 ACK 后再发送下一个 ESP-NOW 数据。发送回调函数从高优先级的 Wi-Fi 任务中运行。因此,不要在回调函数中执行冗长的操作。相反,将必要的数据发布到队列,并交给优先级较低的任务处理。
接收 ESP-NOW 数据
----------------------