Page 1 of 1

ESP-NOW Implementation

Posted: Fri Dec 10, 2021 4:04 am
by LiveRock
Hi

My project consists of many ESP32s communicating with each other.
Any one of them can be a master and the rest of them will be slave.
There can be only one Master.

So, my strategy is the user set up one unit as a Master using the LCD touch screen.
The user will set up the rest as slaves.

So, the Master send broadcast Mac ff:ff:ff:ff:ff:ff
The slaves received the data, which include a bool flag to say it is from the Master and remembers the mac.
The slaves then send data to the Master and the Master adds (pairs) the slave mac to the list using

// clear slave data
memset(&peerInfo, 0, sizeof(peerInfo));
// register first peer
memcpy(peerInfo.peer_addr, mac, 6);
esp_err_t addStatus = esp_now_add_peer(&peerInfo);

I have some questions:

1. Is this good way to implement my object for Master/Slave?
2. I am using WiFi.mode(WIFI_STA) and yet I can receive and send for my Master and Slaves. Why is this so?
3. I also do not use esp_now_set_self_role(ESP_NOW_ROLE_COMBO) or anything like this. Should I?