mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 02:37:19 +02:00
Merge branch 'bugfix/fix_some_wifi_bugs_0421_v5.4' into 'release/v5.4'
fix(wifi): fix some wifi bugs 0421 (v5.4) See merge request espressif/esp-idf!38594
This commit is contained in:
@ -33,7 +33,7 @@ ppCalTxAMPDULength = 0x40001bd8;
|
||||
ppRxFragmentProc = 0x40001c28;
|
||||
ppRxPkt = 0x40001c2c;
|
||||
pp_coex_tx_request = 0x40001c54;
|
||||
rcGetSched = 0x40001c88;
|
||||
/* rcGetSched = 0x40001c88; */
|
||||
rcTxUpdatePer = 0x40001c94;
|
||||
rcUpdateRate = 0x40001c9c;
|
||||
wDev_AppendRxBlocks = 0x40001cdc;
|
||||
|
@ -895,7 +895,7 @@ wep_decap = 0x40002028;
|
||||
dbg_hmac_rxtx_statis_dump = 0x4000202c;
|
||||
dbg_hmac_statis_dump = 0x40002030;
|
||||
/* ieee80211_send_action_vendor_spec = 0x40002034; */
|
||||
ieee80211_vnd_lora_ie_size = 0x40002048;
|
||||
/* ieee80211_vnd_lora_ie_size = 0x40002048; */
|
||||
ieee80211_vnd_ie_size = 0x4000204c;
|
||||
ieee80211_add_ssid = 0x40002050;
|
||||
ieee80211_add_rates = 0x40002054;
|
||||
@ -903,7 +903,7 @@ ieee80211_add_rates = 0x40002054;
|
||||
ieee80211_is_ht_cipher = 0x4000205c;
|
||||
ieee80211_setup_lr_rates = 0x40002068;
|
||||
ieee80211_ht_node_init = 0x4000206c;
|
||||
ieee80211_is_support_rate = 0x40002070;
|
||||
/* ieee80211_is_support_rate = 0x40002070; */
|
||||
ieee80211_setup_rates = 0x40002074;
|
||||
ieee80211_is_lr_only = 0x40002078;
|
||||
ieee80211_setup_phy_mode = 0x4000207c;
|
||||
|
@ -232,7 +232,7 @@ rcampduuprate = 0x40000f30;
|
||||
rcClearCurAMPDUSched = 0x40000f34;
|
||||
rcClearCurSched = 0x40000f38;
|
||||
rcClearCurStat = 0x40000f3c;
|
||||
rcGetSched = 0x40000f40;
|
||||
/* rcGetSched = 0x40000f40; */
|
||||
rcLowerSched = 0x40000f44;
|
||||
rcSetTxAmpduLimit = 0x40000f48;
|
||||
rcTxUpdatePer = 0x40000f4c;
|
||||
|
@ -238,7 +238,7 @@ rcampduuprate = 0x40000ea4;
|
||||
rcClearCurAMPDUSched = 0x40000ea8;
|
||||
rcClearCurSched = 0x40000eac;
|
||||
rcClearCurStat = 0x40000eb0;
|
||||
rcGetSched = 0x40000eb4;
|
||||
/* rcGetSched = 0x40000eb4;*/
|
||||
rcLowerSched = 0x40000eb8;
|
||||
rcSetTxAmpduLimit = 0x40000ebc;
|
||||
rcTxUpdatePer = 0x40000ec0;
|
||||
|
@ -111,7 +111,7 @@ extern "C" {
|
||||
#define ESP_ERR_MESH_DISCARD_DUPLICATE (ESP_ERR_MESH_BASE + 20) /**< discard the packet due to the duplicate sequence number */
|
||||
#define ESP_ERR_MESH_DISCARD (ESP_ERR_MESH_BASE + 21) /**< discard the packet */
|
||||
#define ESP_ERR_MESH_VOTING (ESP_ERR_MESH_BASE + 22) /**< vote in progress */
|
||||
#define ESP_ERR_MESH_XMIT (ESP_ERR_MESH_BASE + 23) /**< XMIT */
|
||||
#define ESP_ERR_MESH_XMIT (ESP_ERR_MESH_BASE + 23) /**< TX fail, the tx state is a value other than timeout and disconnect */
|
||||
#define ESP_ERR_MESH_QUEUE_READ (ESP_ERR_MESH_BASE + 24) /**< error in reading queue */
|
||||
#define ESP_ERR_MESH_PS (ESP_ERR_MESH_BASE + 25) /**< mesh PS is not specified as enable or disable */
|
||||
#define ESP_ERR_MESH_RECV_RELEASE (ESP_ERR_MESH_BASE + 26) /**< release esp_mesh_recv_toDS */
|
||||
@ -682,6 +682,8 @@ esp_err_t esp_mesh_stop(void);
|
||||
* - ESP_ERR_MESH_QUEUE_FULL
|
||||
* - ESP_ERR_MESH_NO_ROUTE_FOUND
|
||||
* - ESP_ERR_MESH_DISCARD
|
||||
* - ESP_ERR_MESH_NOT_SUPPORT
|
||||
* - ESP_ERR_MESH_XMIT
|
||||
*/
|
||||
esp_err_t esp_mesh_send(const mesh_addr_t *to, const mesh_data_t *data,
|
||||
int flag, const mesh_opt_t opt[], int opt_count);
|
||||
|
@ -51,7 +51,7 @@ extern "C" {
|
||||
|
||||
#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 */
|
||||
#define ESP_NOW_MAX_DATA_LEN_V2 1490 /**< Maximum length of data sent in each ESPNOW transmission for v2.0 */
|
||||
#define ESP_NOW_MAX_DATA_LEN_V2 1470 /**< Maximum length of data sent in each ESPNOW transmission for v2.0 */
|
||||
|
||||
/**
|
||||
* @brief Status of sending ESPNOW data .
|
||||
|
@ -192,7 +192,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 */
|
||||
signed : 8; /**< reserved */
|
||||
signed : 8; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
|
Submodule components/esp_wifi/lib updated: 7b7d0bec8a...7a103b60ff
@ -1853,7 +1853,11 @@ At the start of `Interval` time, RF, PHY, BB would be turned on and kept for `Wi
|
||||
|
||||
- Event `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ would be posted at the start of `Interval`. Since `Window` also starts at that moment, its recommended to TX in that event.
|
||||
|
||||
- At connected state, the start of `Interval` would be aligned with TBTT.
|
||||
- At connected state, the start of `Interval` would be aligned with TBTT. To improve the packet reception success rate in connectionless modules, the sender and receiver can be connected to the same AP, and packets can be transmitted within the event `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_. This synchronization helps align the connectionless modules transmission window.
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
On the ESP32, TBTT timing is affected by DFS(Dynamic Frequency Scaling). To synchronize the connectionless modules transmission window using TBTT on the ESP32, DFS must be disabled.
|
||||
|
||||
**Window**
|
||||
|
||||
|
@ -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:
|
||||
|
||||
@ -86,7 +87,13 @@ When :cpp:func:`esp_now_deinit()` is called, all of the information of paired de
|
||||
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.
|
||||
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. A device with a broadcast MAC address must be added before sending broadcast data.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
For the receiving device, calling :cpp:func:`esp_now_add_peer()` is not required. If no paired device is added, it can only receive broadcast packets and unencrypted unicast packets. To receive encrypted unicast packets, a paired device must be added, and the same LMK must be set.
|
||||
|
||||
.. only:: esp32c2
|
||||
|
||||
@ -96,14 +103,12 @@ Call :cpp:func:`esp_now_add_peer()` to add the device to the paired device list
|
||||
|
||||
The maximum number of paired devices is 20, and the paired encryption devices are no more than 17, the default is 7. If you want to change the number of paired encryption devices, set :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM` in the Wi-Fi 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.
|
||||
|
||||
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
|
||||
----------------------
|
||||
|
@ -1829,7 +1829,11 @@ AP 睡眠
|
||||
|
||||
- 在 `Interval` 开始时,将会给出 `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ 事件,由于 `Window` 将在此时开始,可以在此事件内布置发包动作。
|
||||
|
||||
- 在连接状态下,`Interval` 开始的时间点将会与 TBTT 时间点对齐。
|
||||
- 在连接状态下,`Interval` 开始的时间点将会与 TBTT 时间点对齐。可以通过将非连接模块的接收端和发送端连接在同一路由器下,并在 `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ 事件内进行发包,以同步非连接模块的传输窗口,达到提高接收端收包成功率的效果。
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
在 ESP32 上,TBTT 时间点会受到 DFS(Dynamic Frequency Scaling) 的干扰,如果想要在 ESP32 上通过 TBTT 同步非连接模块的传输窗口,需要禁用 DFS。
|
||||
|
||||
**Window**
|
||||
|
||||
|
@ -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)。
|
||||
|
||||
特定供应商元素的帧格式为:
|
||||
|
||||
@ -83,7 +88,13 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参
|
||||
添加配对设备
|
||||
-----------------
|
||||
|
||||
在将数据发送到其他设备之前,请先调用 :cpp:func:`esp_now_add_peer()` 将其添加到配对设备列表中。如果启用了加密,则必须设置 LMK。ESP-NOW 数据可以从 Station 或 SoftAP 接口发送。确保在发送 ESP-NOW 数据之前已启用该接口。
|
||||
在将数据发送到其他设备之前,请先调用 :cpp:func:`esp_now_add_peer()` 将其添加到配对设备列表中。如果启用了加密,则必须设置 LMK。
|
||||
|
||||
ESP-NOW 数据可以从 Station 或 SoftAP 接口发送。确保在发送 ESP-NOW 数据之前已启用该接口。
|
||||
|
||||
配对设备的信道范围是从 0 ~ 14。如果信道设置为 0,数据将在当前信道上发送。否则,必须使用本地设备所在的通道。
|
||||
|
||||
对于接收设备,调用 :cpp:func:`esp_now_add_peer()` 不是必需的。如果没有添加配对设备,只能接收广播包和不加密的单播包。如果需要接收加密的单播包,则必须添加配对设备并设置相同的 LMK。
|
||||
|
||||
.. only:: esp32c2
|
||||
|
||||
@ -93,14 +104,12 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参
|
||||
|
||||
配对设备的最大数量是 20,其中加密设备的数量不超过 17,默认值是 7。如果想要修改加密设备的数量,在 Wi-Fi menuconfig 设置 :ref:`CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM`。
|
||||
|
||||
在发送广播数据之前必须添加具有广播 MAC 地址的设备。配对设备的信道范围是从 0 ~ 14。如果信道设置为 0,数据将在当前信道上发送。否则,必须使用本地设备所在的通道。
|
||||
|
||||
发送 ESP-NOW 数据
|
||||
-----------------
|
||||
|
||||
调用 :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 数据
|
||||
----------------------
|
||||
|
@ -47,7 +47,7 @@ menu "Example Configuration"
|
||||
|
||||
config ESPNOW_SEND_LEN
|
||||
int "Send len"
|
||||
range 10 250
|
||||
range 10 1470
|
||||
default 10
|
||||
help
|
||||
Length of ESPNOW data to be sent, unit: byte.
|
||||
|
@ -168,6 +168,12 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
if (CONFIG_LOG_MAXIMUM_LEVEL > CONFIG_LOG_DEFAULT_LEVEL) {
|
||||
/* If you only want to open more logs in the wifi module, you need to make the max level greater than the default level,
|
||||
* and call esp_log_level_set() before esp_wifi_init() to improve the log level of the wifi module. */
|
||||
esp_log_level_set("wifi", CONFIG_LOG_MAXIMUM_LEVEL);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
|
||||
wifi_init_sta();
|
||||
}
|
||||
|
Reference in New Issue
Block a user