https://toitlang.org/ logo
surviving a power outage
# help
r
After a power outage the ESP32 comes up faster than the WiFi router, so jaguar tends to fail. What is the easiest way to overcome this problem? Using a watchdog? And if so, which of the two, the built-in or the package?
m
@User On all mine, jag just keeps trying, each attempt is like three times in succession. Then it has a 5sec stand down and does it again, continually. Could the failure be elsewhere? What do you see in the monitor?
r
Sorry, t didn't look at this project for 6 months so I did not remember well what was wrong. Looking at the code again I supppose the problem is caused by the MQTT broker (on a Raspberry Pi Zero 2) comes up much later still .
f
You can delay Jaguar by using `-D jag.wifi=false`: https://github.com/toitlang/jaguar?tab=readme-ov-file#temporarily-disabling-jaguars-wifi If you then install a container that just doesn't do anything for 10s, Jaguar will wait for it, and then only try to connect to the WiFi. However, Jaguar still runs all other containers. So if you primary container is the one crashing (which seems to be likely), then you need to deal with that in your container. Two things come to mind: - protect your own
net.open
. It might throw if it couldn't connect. Jaguar already has the retry loop (as @milkmansson commented above). Your own program would need one too. - protect accesses to servers. You already mentioned the MQTT broker, so that one should probably be guarded somehow. It depends a bit on which MQTT client you use. The default one reconnects automatically, but still needs a
catch
around the
connect
(or whatever the initial function was called).