Saved WiFi credentials takes a excessive time to reconnect after power cycle (possible red herring) #555
Replies: 8 comments 7 replies
-
Below are a few debug logs for comparison. 1. First run with a blank ESP8266. Launches a portal, allows me to configure my local IP/Netmask/Gateway/DNS, connects to my local router WiFi network and saves the credentials, followed by me performing a reset by clicking on the Reset button within the portal. All looks OK:
2. Following a hard reset. For some reason the first
3. Double reset to force immediate rise of portal. In this case I didn't bother connecting to the raised AP and just pushed the ESP reset button a few moments later. On restart from this condition the
|
Beta Was this translation helpful? Give feedback.
-
Hmmm....Are we talking about the same issue here? The situation I am seeing is that WiFi STA connection from a hard reset/cold boot is slow and WiFi STA connection after deep sleep is quick. The link/procedure you provide seems to describe the opposite - that WiFi connection on cold boot/hard reset is quick, but WiFi reconnection following a deep sleep is slow (or not working at all). The second AC log I listed, above, is only a partial extract of what was occurring. I actually left it running for several minutes and after every deep sleep the WiFi STA reconnection time was consistently <400 milliseconds. It appears the Indeed, I've had an ESP8266 next to me for the last 10 minutes or so while I've been typing this running the above code and the log seems to replicate this:
Notice how the first 'Connecting to WiFi' statement (following initial power-up) takes one timeout and an autoConnect 15+ seconds to complete. Every subsequent WiFi reconnection (except the third one, which I'm willing to bet was due to weak WiFi signal from my router) is <350 milliseconds. |
Beta Was this translation helpful? Give feedback.
-
I reviewed the conditions for the connection waiting of 1st-WiFi.begin. Omit to wait for connecting if no available SSID is stored. It doesn't solve the root of the problem, but it makes things a little better. |
Beta Was this translation helpful? Give feedback.
-
The more I play with the DRD, the more I think this issue is unrelated to a cold boot.
Because the DRD is occasionally being mis-triggered (I still have to try out your What is the default behaviour of AutoConnect if an AP is raised after credentials have previously been set up in the portal? Is AutoConnect perhaps expecting the user to take advantage of the portal when it's raised, and either configure a new set of credentials or manually select a previously saved set of credentials in the 'OpenSSIDs' tab? If the user does neither does AutoConnect perhaps unexpectedly erase the previously-working SDK WiFi credentials, similar to doing a As an experiment, I tried modifying my test code to remove all references to the DRD. In this new version the portal is only raised if there are no saved credentials. I can't fault it no matter how many times I reset, deep sleep or reboot the ESP8266. Reconnection to the last known WiFi STA is always fast, and it never times out or has to
|
Beta Was this translation helpful? Give feedback.
-
OK - I can confirm that change appears to work, thankyou :) But I agree with you, that it's kind of masking the issue of 'lost' SDK WiFi credentials. |
Beta Was this translation helpful? Give feedback.
-
Ah - yes, I can see now why I'm losing my credentials on an
Probably not that particular case. I'm thinking more of situations where the portal might be raised on demand, but not for the purpose of setting/changing WiFi STA credentials. For example, my device has MQTT settings that are made using a custom page inside the portal. The user may need to change them at some point after the device is deployed (maybe the MQTT server details need to be adjusted?), and in that situation because the WiFi credentials hadn't been modified the device should just resume connecting using the saved WiFi credentials after the portal is closed and/or the ESP rebooted.
I'm not sure. What would happen if the library simply didn't have that red-painted step at all? Is there a need to |
Beta Was this translation helpful? Give feedback.
-
What happens if you use
No, you're probably right. As I mentioned earlier, my C++ skills and detailed understanding of the WiFi SDK are only just above 'basic', so I'm more guided by you as to the correct operation of it. I guess my only other query would be if we can't avoid using |
Beta Was this translation helpful? Give feedback.
-
Understood. Let's not over-complicate things at this stage then. I'm currently happy that AutoConnect operates well enough in my situation that there's no pressing need for further adjustments under the hood to the library. Thank you again for providing technical support and assistance with regards to my queries for AutoConnect. Could I offer anything in return for your help? Maybe provide assistance with documentation or make a donation to the project? |
Beta Was this translation helpful? Give feedback.
-
Split off from another discussion here...
I think the issue I've been seeing is related to the Double Reset Detector and the way I'm using AutoConnect when I'm detecting the double reset.
In my setup I'm doing the following in an attempt to speed up the display of the Config Portal when the double reset occurs:
I think what is happening is that if the double reset is detected (or is falsely triggered by a power cycle), the first branch of the
if
statement is performed and the config portal is raised through the AP 172.217.28.1 waiting for me to connect to it. Obviously in this situation if I wasn't expecting this it looks like ESP8266 has not connected to the STA and everything halts inportal.begin()
. If I reset it again and get it to not detect a double reset theelse
component of the setup is performed and WiFi connects to STA as expected, but takes much longer to re-connect (15 sec instead of 300 millisec).For what it's worth, my stripped-down code for the above phenomena is below. The idea is that if a blank ESP is run it checks if any credentials are already saved. If none are found it immediately raises an AP so the user can configure it. I then enter my WiFi details in the portal (including assigning a static IP/Netmask/Gateway/DNS instead of using DHCP) and it connects OK. The code then keeps the WiFi connection active for 60 seconds before going to deep sleep for 60 seconds. On wake-up it immediately connects using the last active credentials, stays awake for 60 seconds and sleeps for 60 seconds, and so on. If the user double-resets the ESP I had hoped it would simply re-display the AP to allow the settings to be changed, but doing so must be upsetting the last saved WiFi credentials and the ESP takes much longer to reconnect again on the subsequent reboot/reset, particularly if the DRD mis-triggers and raises the AP without me knowing:
Beta Was this translation helpful? Give feedback.
All reactions