To implement the ESP-NOW Protocol, we first need to understand how it works in details.
The datasheet doesn't say much on the really low level, especially on the acknowledgment behavior.
To understand what ESP-NOW does, I use Wireshark with my PC Wifi card in monitoring mode:
> sudo ifconfig wlan0 down > sudo iwconfig wlan0 mode monitor > sudo ifconfig wlan0 up > sudo wireshark
With one ESP8266 sending ESP-NOW to a non existing MAC adress, I got the following packets:
The same packet is sent multiple times, with a decreasing datarate :
- 2 tries at 6Mb/s
- 2 tries at 2Mb/s
- 7 tries at 1Mb/s (maybe this last number of tries depends on a timeout...)
First bad news: ESP-NOW continues to send the packet again and again for 20ms !
I hope their is a way to disable this resend behavior... Indeed, for a robotic control, we prefer to wait for the next up-to-date packet than getting an outdated one, and jamming the channel...
Let's look at the packet itself:
0000 00 00 12 00 2e 48 00 00 10 0c 6c 09 c0 00 d5 03 .....H....l.À.Õ. 0010 00 00 d0 00 3c 00 84 f3 eb 73 55 0d 86 f3 eb 73 ..Ð.<..óësU..óës 0020 ca 61 84 f3 eb 73 55 0d a0 09 7f 18 fe 34 17 71 Êa.óësU. ...þ4.q 0030 47 8c dd ff 18 fe 34 04 01 62 12 12 12 12 12 12 G.Ýÿ.þ4..b...... 0040 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0050 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0060 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0070 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0080 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0090 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00a0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00b0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00c0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00d0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00e0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 00f0 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0100 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0110 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0120 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 ................ 0130 12 12 12 1d 2c ba 98 ....,º.
The payload is "0x04 0x12 0x12 ... 0x12" (on my test I choose to begin with a packet counter to distinguish different packets.)
The frame format seems to follow the documentation from expressif, and the header should be easy to generate:
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/wifi/esp_now.html
Now, if I turn on the destination ESP8266, the packets are sent only once, and a quick acknowledgement frame is sent back in (about 60us):
I guess this acknowledgment frame will be generated by the low level MAC layer, so we shouldn't take care of managing it...
The next test is then to send ESP-NOW packets to my laptop MAC address, and check that ACK are sent automatically even in monitoring mode...
Hum... After a quick test, when I Sending a packet to my laptop's MAC address, it does't send an ACK back. Maybe the monitor mode disable this in the MAC layer ?
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.