ESP-NOW bi-directional communications --- send & receive
ESP-NOW bi-directional communications --- send & receive
Hello,
I'm trying to get 2 ESP32 Dev Boards to talk to each other.
I started with the master-slave examples from the Arduino IDE, and got that working fine. In that example 'master' is set to STA, and 'slave' is set to AP. 'Master' sends a message to 'slave', and 'slave' prints the message to serial.
When I try to send a message from the slave back to the master using the 'from' MAC address, it says:
Send Status: Peer not found.
I've registered send and receive callbacks for both boards.
I am a total newbie at this kind of communications programming, so I am probably missing something very obvious to most of you. I've been reading a lot for the past week and still haven't cracked this.
Do I need to use WIFI_AP_STA to be able to both send and receive messages? Or ?????
Any help or hints or pseudo-code would be greatly appreciated.
Thanks Robby in NC, USA
I'm trying to get 2 ESP32 Dev Boards to talk to each other.
I started with the master-slave examples from the Arduino IDE, and got that working fine. In that example 'master' is set to STA, and 'slave' is set to AP. 'Master' sends a message to 'slave', and 'slave' prints the message to serial.
When I try to send a message from the slave back to the master using the 'from' MAC address, it says:
Send Status: Peer not found.
I've registered send and receive callbacks for both boards.
I am a total newbie at this kind of communications programming, so I am probably missing something very obvious to most of you. I've been reading a lot for the past week and still haven't cracked this.
Do I need to use WIFI_AP_STA to be able to both send and receive messages? Or ?????
Any help or hints or pseudo-code would be greatly appreciated.
Thanks Robby in NC, USA
Re: ESP-NOW bi-directional communications --- send & receive
Did you esp_now_add_peer on both sides
Re: ESP-NOW bi-directional communications --- send & receive
No I didn't. I'll try that right now.
I just realized that I posted this in the wrong forum --- SDK instead of Arduino. Can I change that?
Thanks, Robby
I just realized that I posted this in the wrong forum --- SDK instead of Arduino. Can I change that?
Thanks, Robby
Re: ESP-NOW bi-directional communications --- send & receive
Tried esp_now_add_peer in 'slave' module, now I get:
Send Status: Not sure what happened
I set:
peer.peer_addr to mac address of master
peer.channel to same channel as master ?? not sure if this should be different
peer.encrypt to 0
Wondering if I should delete this post and repost in ESP32 Arduino
Thanks, Robby
Send Status: Not sure what happened
I set:
peer.peer_addr to mac address of master
peer.channel to same channel as master ?? not sure if this should be different
peer.encrypt to 0
Wondering if I should delete this post and repost in ESP32 Arduino
Thanks, Robby
Re: ESP-NOW bi-directional communications --- send & receive
Re-posting in ESP Arduino
Robby
Robby
Re: ESP-NOW bi-directional communications --- send & receive
Check how the idf version does it https://github.com/espressif/esp-idf/tr ... ifi/espnow
Re: ESP-NOW bi-directional communications --- send & receive
Thanks. I've been looking at that for a while now and also the "esp-now_user_guide_.pdf", but some of the terminology, names and methods seem very different.
Haven't quite figured out what is meant by "state" --- is that wifi mode like AP or STA?
I have a 'supposedly' sucessful pair from the slave back to the master, but when I try to send a message back to the master, it fails.
Also I notice that the slave APmac and mac addresses are different. APmac is mac+1 . Master is paired with the APmac of slave and successfully sends messages to it.
Maybe the slave sends from regular mac and master doesn't recognize it???
Still reading, trying and cursing --- R
Haven't quite figured out what is meant by "state" --- is that wifi mode like AP or STA?
I have a 'supposedly' sucessful pair from the slave back to the master, but when I try to send a message back to the master, it fails.
Also I notice that the slave APmac and mac addresses are different. APmac is mac+1 . Master is paired with the APmac of slave and successfully sends messages to it.
Maybe the slave sends from regular mac and master doesn't recognize it???
Still reading, trying and cursing --- R
Re: ESP-NOW bi-directional communications --- send & receive
Maybe its little offtopic but it can help to explain why AP mac is different than other:
http://esp-idf.readthedocs.io/en/latest ... ac-address
http://esp-idf.readthedocs.io/en/latest ... ac-address
Re: ESP-NOW bi-directional communications --- send & receive
Not off topic at all --- thanks.
I remembered reading something about that somewhere, but did not remember where.
I don't really understand why MAC addresses need to be changed, though.
I don't suppose that 0 or 1 added to MAC is the "state" that is mentioned here:
https://github.com/espressif/esp-idf/tr ... ifi/espnow ????
Thanks again -R
I remembered reading something about that somewhere, but did not remember where.
I don't really understand why MAC addresses need to be changed, though.
I don't suppose that 0 or 1 added to MAC is the "state" that is mentioned here:
https://github.com/espressif/esp-idf/tr ... ifi/espnow ????
Thanks again -R
Re: ESP-NOW bi-directional communications --- send & receive
Well, a small success in figuring this out.
Turns out the esp-now code in the arduino examples that I copied did not check for:
ESP_ERR_ESPNOW_IF : current WiFi interface doesn't match that of peer
That is the error I'm getting.
SoI guess that would be peer.ifidx which I have set to ESP_IF_WIFI_STA. That is what master is set to --- is that right???
Thanks -R
Turns out the esp-now code in the arduino examples that I copied did not check for:
ESP_ERR_ESPNOW_IF : current WiFi interface doesn't match that of peer
That is the error I'm getting.
Code: Select all
typedef struct esp_now_peer_info {
uint8_t peer_addr[ESP_NOW_ETH_ALEN]; /**< ESPNOW peer MAC address that is also the MAC address of station or softap */
uint8_t lmk[ESP_NOW_KEY_LEN]; /**< ESPNOW peer local master key that is used to encrypt data */
uint8_t channel; /**< Wi-Fi channel that peer uses to send/receive ESPNOW data. If the value is 0,
use the current channel which station or softap is on. Otherwise, it must be
set as the channel that station or softap is on. */
wifi_interface_t ifidx; /**< Wi-Fi interface that peer uses to send/receive ESPNOW data */
bool encrypt; /**< ESPNOW data that this peer sends/receives is encrypted or not */
void *priv; /**< ESPNOW peer private data */
} esp_now_peer_info_t;
Thanks -R
Who is online
Users browsing this forum: Baidu [Spider] and 52 guests