Closed marcelstoer closed 3 years ago
Thanks again for your interest in the library and your nice and clean code. The library's examples are normally over-crowded with too many definitions trying to demonstrate to as many use cases as possible.
The Async_ConfigOnSwitch example is just a simple example to demonstrate the ESPAsync_WiFiManager library's feature and certainly can not be expected to be perfect in all use cases.
To make sure to enter the Config Portal whenever a button is pressed, it's suggested you use either
Please check these examples
for how to use Button Interrupt in ESP8266/ESP32.
I think your ConfigOnSwitch example might be flawed but I cannot be exactly sure (yet). The issue is that if the device cannot connect to one of the configured WiFi networks it keeps looping ignoring that pressed button to start the config portal.
I took your example and simplified it for my needs:
wifimanager.h
that I can use from my mainsetup()
/loop()
-> see Gist https://gist.github.com/marcelstoer/914ff2ac58a42a957dfa071c9c5c8acd -> use as below
As far as I understand the problem is the
while
-loop inconnectMultiWiFi()
at https://github.com/khoih-prog/ESPAsync_WiFiManager/blob/master/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino#L388.The function sequence is like this:
loop()
->check_status()
->check_WiFi()
->connectMultiWiFi()
. While trying to connect to one of the WiFis in thatwhile
-loop pressing the button to start the config portal has no effect! You would have to press the button for a really long time until the loop ends, the sequence above returns toloop()
and the button status is evaluated again.