The wifi.on ('disconnected') event fires only once. #7172
Unanswered
espruino-discuss3
asked this question in
ESP32
Replies: 1 comment
-
Posted at 2020-01-20 by maze1980 I'd suggest to place the code for "wifi.on('disconnected',..." into the "wifi.on('connected'," function. I didn't try this, but as the disconnect function gets registered after every connect it should work. Posted at 2020-01-21 by Robin Mon 2020.01.20 @gfwilliams just posted the very solution needed here within a separate thread post just this morning. @homoludens a full explanation is there also. I'd read the entire thread. . . . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-01-10 by Homoludens
Hello everybody.
Faced the problem of reconnecting to the WiFi network through the wifi.on (‘connected’) event.
Program code:
When you first start wifi.on (‘connected’), it works:
{
"ip": "192.168.0.10",
"netmask": "255.255.255.0",
"gw": "192.168.0.1",
"mac": "a4:cf:12:75:38:ec"
}
I turn off the router with my hands:
Obviously wifi.on (‘disconnected’) - it worked.
I turn on the router, I get a message from wifi.on (‘connected’):
{
"ip": "192.168.0.10",
"netmask": "255.255.255.0",
"gw": "192.168.0.1",
"mac": "a4:cf:12:75:38:ec"
}
And that’s it. If I turn off the router again, then no events occur.
Moreover, if you give the wifi.getIP () command when the router is off, then we get.
{
ip: "192.168.0.10",
netmask: "255.255.255.0",
gw: "192.168.0.1",
mac: "a4:cf:12:75:38:ec"
}
(the router has been turned off for more than two minutes)
That is, the board does not understand that wifi / network is no more.
Question:
PS So far, the only working option I have found is the gateway ping once every 30 seconds, and if (rateTime> 1000) {e.Reboot ()};
But I think this is not the best option :)
PPS Sorry for the presentation - English is not my native language.
I will be glad to any advice. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions