https://toitlang.org/ logo
:question: ESPnow & Wifi alternaltely possible ?
# help
k
I got a simple ESPnow-example working. Jag is disabled for a long time and a boot button press is used to exit the app. Now it would be nice to switch programmatically between ESPnow and Wifi (MQTT, ...). Is that possible ?
f
At the moment WiFi and ESPNow can't run at the same time. You would need to coordinate the uses of WiFi and ESPNow to make this work. Jaguar doesn't really have a way to be controlled from the outside (except for the
-D
flags.This means that you can't run Jaguar while having a container that sporadically connects to EPSNow. The following options would fix this: - allow WiFi and EPSNow at the same time. In theory the ESP-IDF supports this (as long as EPSNow uses the same channel as the WiFi). That's work that would probably need to be done by us. - change Jaguar so it has a way to disconnect from WiFi. Maybe add a service to it that allows you to ask it to turn off the WiFi for a period of time. We did something similar in Artemis. - use your own Jaguar implementation. Jaguar is getting more complicated with time, but the basics are really simple. You can probably reimplement a mini-version in ~100 lines of code? We did something similar for our testing: https://github.com/toitlang/toit/blob/master/tests/hw/esp-tester/mini-jag.toit - implement a network service. Jaguar uses the standard network service which, by default, uses WiFi. However, you could add your own network service that supports disconnecting from WiFi. Artemis uses this to support other networks than WiFi (while still using
net.open
). This is basically a cleaner version of "change Jaguar" from above, since you get the same behavior but without changing Jaguar itself. If you are interested in trying one of these options, let me know, and I can try to provide more information.
k
Thank you for the info. I prefer to implement a simple message gateway by serial coupling of two ESPs.
f
I was thinking of doing the same thing. The best solution would be to support running espnow and wifi at the same time. Unfortunately that requires a bit of low-level work.
If only one side can initiate the communication then you can just shut-down that side before you communicate on the other one.
However, if both sides can send a message, then there is currently no really nice solution.
k
In the current ESPnow experimental state, I want to implement a remote operated, battery driven bell (outdoor notification). If this goes well, there will definitely be more remote-controlled devices in the garden. Their connection to my Home Assistant would then be easily possible via MQTT using that gateway.
f
In that case you could have a receiver-esp listen to esp-now messages, and switch to WiFi whenever it receives one.