Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-Now does work with WiFi #11

Open
WindyYam opened this issue Aug 1, 2018 · 2 comments
Open

ESP-Now does work with WiFi #11

WindyYam opened this issue Aug 1, 2018 · 2 comments

Comments

@WindyYam
Copy link

WindyYam commented Aug 1, 2018

First good code for ESP-now functions

Recently I have tested with a 1-master 1-slave setup, master connected to WiFi ap.
as long as ESP-Now and WiFi operate at the same wifi channel, they both do work.

since ap channel is determined by ap gateway, the only thing we can change is ESP-Now channel. just connect to ap, then set the slave the same channel as the master's wifi_get_channel().

this could be done with a default init channel, after master connected ap, do the following on master:

wifi_channel = wifi_get_channel();
wifi_set_channel(default_channel);
for (int i = 0; i < 5; i++) {
//tell slave to switch wifi_channel
}
wifi_set_channel(wifi_channel);

on the slave, do:
in the recv callback:
wifi_set_channel(wifi_channel); //the wifi_channel is from master

Edit: after some experiments wifi_set_channel only last a few seconds at slave side, the only stable way to change channel on slave is by setting AP config wifi_softap_set_config_current(conf)

@torntrousers
Copy link
Contributor

How reliably does this actually work for you? I've been trying it but although sometimes messages do get through but many others are not received, whereas with Wifi off messages get received quite reliably. I'll keep trying it out but I'd be interested if you or others have had good success with this or also just get some messages received when Wifi is on.

@WindyYam
Copy link
Author

WindyYam commented Nov 5, 2018

I've had some try'n'error and the system work without any problem. but the anonying part is that i have to set both master and slave to station+ap in order to set the channel by wifi_softap_set_config_current()
in my new setup the master do the espnow mac registration and connect to the AP then broadcast it's wifi channel by ssid. slave scan for it and set it's channel by wifi_softap_set_config_current(). after these step the espnow system could work properly.
In my most failure tries they do not work just because their channels are not the same. You could print their channel at run time constantly with wifi_get_channel to see if they are right. the wifi_set_channel is not a reliable way to set channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants