Closed AlexMarcov closed 2 years ago
Hi @AlexMarcov
Thanks for your interest in the library and your contribution.
I'm sorry I don't think the PR is necessary because as design, whenever you entered the Config Portal (CP), it must stay there forever until user intentionally exits the CP by exiting or reset manually, no matter what.
If reset is necessary, users can write it in the users' code, not to force the behaviour on everybody by changing the library.
Moreover, it'll be beneficial next time for you PR to pay attention to these following details
#if ESP8266
ESP.reset();
#else
ESP.restart();
#endif
instead of only for ESP32
ESP.restart(); // Exit loop and restart ESP try to reconect to stored configs
LOGINFO("Restart");
instead of
Serial.println("Restart");
if ( ((millis() - (_configPortalStart + _configPortalTimeout)) >= _configPortalTimeout - 2)
&& ((millis() - (_configPortalStart + _configPortalTimeout)) >= _configPortalTimeout - 1))
{
Serial.println("Restart");
delay(2000);
ESP.restart(); // Exit loop and restart ESP try to reconect to stored configs
}
Anyway, you seem to be very good and interested in coding and have read thru the library's code. I expect you have more contributions in the future.
Best Regards,
Thank you for your work on the library!
The creation of this PR was pushed by the fact that I use the Double Reset Detector option to enter the CP. Sometimes a situation occurs when the device is powered on or power reset several times for various reasons. Something like a bounce of contacts when the power jack is connected, this event is recognized as a signal to enter CP. It really becomes an infinite loop, only a reset helps if you are there to click on it. In this case, I would really like the CP timeout to work, so I added the following lines.
(1, 2) I understand that I did not quite correctly design these small parts of the code, this is my first PR ) But this code solve my problem, i tested it on ESP8266, it works, I have not yet checked for ESP32.
(3) Yes, calculations are correct, tested on ESP8266
I can rewrite code as you suggest, and make it as one of the library settings that can be turned on or off if user desired. How do you think it makes sense for someone else or it is just my unique case? Or maybe you have another solution to my problem.
As I see it, the library was planned to be able to connect in parallel with CP to the saved AP Credentials when the specified timeout is reached, but for some reason this does not work, as i understand this part of code is unfinished. I was not able to fully figure out what the problem was, until now I just found out that the wifi scan works in parallel with CP, but the connection does not occur when timeout is reached. I will dig further.
Thank you Best Regards,
Something like a bounce of contacts when the power jack is connected, this event is recognized as a signal to enter CP
If this is the case, either
#define DRD_TIMEOUT 3
or
#define MRD_TIMES 3
#define MRD_TIMEOUT 10
with
// CP now timeout is 120s. Change as necessary
ESPAsync_wifiManager.setConfigPortalTimeout(120);
in
if (drd->detectDoubleReset())
{
// DRD, disable timeout.
ESPAsync_wifiManager.setConfigPortalTimeout(0);
Serial.println(F("Open Config Portal without Timeout: Double Reset Detected"));
initialConfig = true;
}
Please spend more time to test and use the designed features before adding more to already complex ones.
added Reset ESP after timeout (120sec) in config portal if there are stored Credentials