I decided to dive in deep myself, but it took a while to find a good sample on how to setup ESP-NOW with two STATION mode units and make use of encryption and peering.
This supprised me a bit, but majority of samples skip encryption options and sometimes also use mac broadcast messages.
That looks like a similar security by obscurity as with the Wifi probe mac hack solution. That was fun to play with but i don't think i'll be using it in real production.
And it only allowed for 5 bytes of data where ESP-NOW can send plain text messages, as needed within the Smartnoderules concept.
I'm totally new on ESP-NOW, so ready to make stupid mistakes, but i think that i've implemented it into SmartNodeRules the way that uses best options that the official API provides.
Using custom encryption keys and verifying peer nodes against the configed peer list should avoid sniffing data and protect against attacks with mac spoofing.
(i'm no expert on this and have to rely on how espressif build their stuff inside ESP-NOW magic)
New rule engine commands:
* ESPNowConfig <kok>,<key>,<mac>,<mode>
* ESPNowAddPeer <key>,<mac>,<role>
* ESPNowSend <msg>
Using it now on a battery operated doorsensor as sender node. Normal ESP as receiver.
Alive time is now a lot shorter than with standard Wifi and it will surely extend battery life.
It also speeds up reaction time quite a lot.
Sample rules to configure two SmartNodeRules:
Receiver:
Code: Select all
on espnow do
ESPNowConfig 1234567890abcdef,1234567890abcdef,02:01:02:03:04:30,Receiver
ESPNowAddPeer 1234567890abcdef,02:01:02:03:04:01,1
endon
Sensor:
Code: Select all
on espnow do
ESPNowConfig 1234567890abcdef,1234567890abcdef,02:01:02:03:04:01,Sender
ESPNowAddPeer 1234567890abcdef,02:01:02:03:04:30,0
ESPNowSend Hello There!
endon
It seems that the peering is limited to 10 stations. May not be enough for some, but you could always add another receiver for 10 more.
Maybe ESP32 can do more, but i have not checked this.