Closed Bazmundi closed 1 year ago
Okay, I am have added more decoding of return from esp_now_send
, to get a ESP NOW peer wifi mismatch
(aka ESP_ERR_ESPNOW_IF
). Is there a boilerplate for setting up an AP/STA for working with ESP-NOW, please?
Okay, so I tried the following:
From:
// setup access point
WiFi.mode(WIFI_AP);
To:
// setup access point
WiFi.mode(WIFI_AP_STA);
WiFi.disconnect();
That seems to have fixed the problem.
I'll do some further checking and report back.
Seems fine. I just have to sort now how to get the pair to reconnect if, say, the pump gets turned on then off. It seems to need some more smarts added. The function descriptions in the resources don't help with understanding the function relational behaviour.
I can get by with starting the pump, then starting the pedal and they will connect.
So, I am finding that people are either:
I got away with AP_STA and WiFi.disconnect() on "master".
Is anyone right? Are they all right? Are any of them wrong?
@Bazmundi Any update about this?
Basically, looking at the idea that the framework uses lower end of OSI stack, it makes sense that it is, for both master/slave, to use:
WiFi.mode(WIFI_STA);
WiFi.disconnet();
I note, however, the odd occasional message that does not get through. Infrequent, and the error reports seem to be link up, but message not received, but I suspect that is simply par for the course, and some interference. For my application, the problem is solved by pressing the button a second time, no harm done.
@Bazmundi Good news, please close the issue if it has solved.
I have two devices, a Wemos BT with battery (aka wemosbat in PlatformIO), and a Wemos D1 R32, with the wemosbat to send a message to the R32 whenever a switch is closed on an input. The wemosbat is the "Pedal" (switch) and the D1 R32 is the "Pump". The wemosbat is the AP and the D1 R32 the STA.
Both fire up, connect, at least between the STA and the AP (I've used this scheme plenty of times for MQTT work but not with ESPNow - first time). However, while I set the callback on send, it never gets called?
Both use:
PEDAL
The callback on send is simple and aims to set a flag locally if the callback is successful, since that hints to the PEDAL that the PUMP is present.
Setup reports ESPNow initialise and peer attached.
The main loop will halt and report no PUMP.
It is iffy currently, having the PUMP PRESENCE set both in callback and
findPump
, but I am still trying to understand where is best to do this. I am assuming it will be in the callback, but as I am stuck presently, with the callback not firing, this is something to address once the callback is working.Console reports at start up, so no debug message from callback and PUMP PRESENCE is never set to
true
:PUMP
Pump sets up with:
Console reports:
The single "." indicating STA finding and connecting to AP. MAC address of pedal matches that embedded in PEDAL code. ESPNOW inits. No callback onReceive raised.
UPSHOT
If this were simply subnets not set up properly, I would assume I would happily be receiving send callback indicating unsuccessful send.