Two questions: first, I am sending a small (12 byte) struct from one ESP32 to another, and returning an ack. The exchange frequently fails. The esp_now_send() never fails, and always returns ESP_OK. However, the send callback returns failure most of the time. When I check the status in the callback, it's either ESP_NOW_SEND_SUCCESS (occasionally) or ESP_NOW_SEND_FAIL (usually).
In esp_now.h, there are a lot of specific error codes for different conditions. How do I get access to the error code causing my failure? The send always returns success, and then the failed callback doesn't give any useful information.
Second question: I'm hosting a small web site for device/sensor status (sent via SSE/Javascript), as well as OTA updates and Webserial. I suspect there's too much TCP/HTTP traffic going out and the ESPNOW packets are squashed. Are there any good ways to broker traffic between ESPNOW and everything else? Obviously I can shut off the web service but I would like to have both. And I can switch ESPNOW to raw UDP or TCP, but I would like the two devices to be able to communicate even when they are not connected to wifi (the devices will go on a boat where there may sometimes be wifi and frequently there will not but they still need to communicate). I could switch to TCP when connected to a network and switch back to ESPNOW otherwise, but that's a lot of additional work. It would be nice if they could coexist.
Environment: VS Code + PIO + Arduino.
how to see ESPNOW send error code?
-
- Posts: 1725
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: how to see ESPNOW send error code?
Seems like that's all the information you get. ESP-NOW works asynchronously, i.e. you enqueue data to be sent via esp_now_send(), transmission and re-transmission happen 'in the background', and you are notified via callback about the outcome when it's done.wjquigs wrote: ↑Wed Jun 19, 2024 4:49 amThe esp_now_send() never fails, and always returns ESP_OK. However, the send callback returns failure most of the time. When I check the status in the callback, it's either ESP_NOW_SEND_SUCCESS (occasionally) or ESP_NOW_SEND_FAIL (usually).
In esp_now.h, there are a lot of specific error codes for different conditions. How do I get access to the error code causing my failure? The send always returns success, and then the failed callback doesn't give any useful information.
If you get ESP_NOW_SEND_FAIL in the callback, https://docs.espressif.com/projects/esp ... p-now-data applies:
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.
I don't think that's the issue.I suspect there's too much TCP/HTTP traffic going out and the ESPNOW packets are squashed.
Re: how to see ESPNOW send error code?
Thanks, that was helpful. It looks like my problem is more about channel selection on my mesh network.
-
- Posts: 1725
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Who is online
Users browsing this forum: VinayDand and 379 guests