[GH-ISSUE #702] wifi doesn't connect after exiting the captive portal with ESP core 2.4.2 #587

Closed
opened 2026-02-28 01:25:59 +03:00 by kerem · 89 comments
Owner

Originally created by @andysc on GitHub (Aug 16, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/702

This might be for "upstream", but between ESP8266 core 2.4.1 and 2.4.2, connectWifi comes back with WL_IDLE_STATUS (0) and doesn't connect to the newly set wifi credentials.

With 2.4.1, the portal closes itself correctly and the device connects correctly to the new credentials.

With 2.4.2, the same code leaves the portal window open and gives WL_IDLE_STATUS and doesn't connect.

This is with a Wemos R2 D1 mini device.

Originally created by @andysc on GitHub (Aug 16, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/702 This might be for "upstream", but between ESP8266 core 2.4.1 and 2.4.2, connectWifi comes back with WL_IDLE_STATUS (0) and doesn't connect to the newly set wifi credentials. With 2.4.1, the portal closes itself correctly and the device connects correctly to the new credentials. With 2.4.2, the same code leaves the portal window open and gives WL_IDLE_STATUS and doesn't connect. This is with a Wemos R2 D1 mini device.
kerem 2026-02-28 01:25:59 +03:00
Author
Owner

@tablatronix commented on GitHub (Aug 16, 2018):

what branch?

<!-- gh-comment-id:413538785 --> @tablatronix commented on GitHub (Aug 16, 2018): what branch?
Author
Owner

@tablatronix commented on GitHub (Aug 16, 2018):

you can try development branch and post logs

<!-- gh-comment-id:413540045 --> @tablatronix commented on GitHub (Aug 16, 2018): you can try development branch and post logs
Author
Owner

@andysc commented on GitHub (Aug 16, 2018):

0.14.0

<!-- gh-comment-id:413550316 --> @andysc commented on GitHub (Aug 16, 2018): 0.14.0
Author
Owner

@andysc commented on GitHub (Aug 16, 2018):

(assuming you meant WiFiManager, not ESP core?)

<!-- gh-comment-id:413550508 --> @andysc commented on GitHub (Aug 16, 2018): (assuming you meant WiFiManager, not ESP core?)
Author
Owner

@andysc commented on GitHub (Aug 16, 2018):

yes, development branch of WiFiManager works correctly.

Any chance you could backport that part of the code (startConfigPortal) to the current codebase?

That looks like a huge re-write you're doing in development branch! wow :)

<!-- gh-comment-id:413634210 --> @andysc commented on GitHub (Aug 16, 2018): yes, development branch of WiFiManager works correctly. Any chance you could backport that part of the code (startConfigPortal) to the current codebase? That looks like a huge re-write you're doing in development branch! wow :)
Author
Owner

@tablatronix commented on GitHub (Aug 16, 2018):

yeah I have no idea what the issue is to fix though

<!-- gh-comment-id:413691872 --> @tablatronix commented on GitHub (Aug 16, 2018): yeah I have no idea what the issue is to fix though
Author
Owner

@andysc commented on GitHub (Aug 21, 2018):

I'll just go back to the earlier version of the core, as I know that works with the current released WiFimanager.
Keep up the great work :)

<!-- gh-comment-id:414731761 --> @andysc commented on GitHub (Aug 21, 2018): I'll just go back to the earlier version of the core, as I know that works with the current released WiFimanager. Keep up the great work :)
Author
Owner

@andysc commented on GitHub (Aug 21, 2018):

do you "need feedback" from me? #justchecking

<!-- gh-comment-id:414824548 --> @andysc commented on GitHub (Aug 21, 2018): do you "need feedback" from me? #justchecking
Author
Owner

@tablatronix commented on GitHub (Aug 21, 2018):

I need debug logs of failure or reproductions

<!-- gh-comment-id:414838656 --> @tablatronix commented on GitHub (Aug 21, 2018): I need debug logs of failure or reproductions
Author
Owner

@andysc commented on GitHub (Aug 22, 2018):

OK. This is the console output from when I save the new wifi config to where it goes round again (having failed to connect to the new wifi due to the Connection result 0 (WL_IDLE_STATUS).

How do I turn on more useful debug?

*WM: VodafoneMobileWiFi-D81949
*WM: -86
*WM: Sent config page
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.
*WM: Request redirected to captive portal
*WM: Scan done
*WM: DUP AP: _Free SOU Airport
<!-- gh-comment-id:415065540 --> @andysc commented on GitHub (Aug 22, 2018): OK. This is the console output from when I save the new wifi config to where it goes round again (having failed to connect to the new wifi due to the Connection result 0 (WL_IDLE_STATUS). How do I turn on more useful debug? ``` *WM: VodafoneMobileWiFi-D81949 *WM: -86 *WM: Sent config page *WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 0 *WM: Failed to connect. *WM: Request redirected to captive portal *WM: Scan done *WM: DUP AP: _Free SOU Airport ```
Author
Owner

@tablatronix commented on GitHub (Aug 22, 2018):

is this a hidden ap ?

If you get a chance turn on esp debugging wifi level

In development you can try
setSaveConnectTimeout(seconds); to increase the connection wait loop, by default it uses waitforconnectresult, maybe there is a bug in there, or problems with your router

<!-- gh-comment-id:415070511 --> @tablatronix commented on GitHub (Aug 22, 2018): is this a hidden ap ? If you get a chance turn on esp debugging wifi level In development you can try setSaveConnectTimeout(seconds); to increase the connection wait loop, by default it uses waitforconnectresult, maybe there is a bug in there, or problems with your router
Author
Owner

@tablatronix commented on GitHub (Aug 22, 2018):

connect result 0 is idle_status I think, which is weird
( ah i see the first post )

<!-- gh-comment-id:415074238 --> @tablatronix commented on GitHub (Aug 22, 2018): connect result 0 is idle_status I think, which is weird ( ah i see the first post )
Author
Owner

@andysc commented on GitHub (Aug 22, 2018):

No, not hidden - it's the WiFi hotspot on my iPhone - usually works fine.
I tried esp debugging wifi but it just inserted lots of WiFi event 7 into the stream, like this:

*WM: MW40V_B9B3
*WM: -75
*WM: Sent config page
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: WiFi save
*WM: Sent wifi save page
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.
wifi evt: 7
wifi evt: 7
*WM: Request redirected to captive portal
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
scandone
*WM: Scan done
*WM: DUP AP: BWU2

Yes, result 0 is WL_IDLE_STATUS, which, yes, is weird.

I'll try changing setConnectTimeout... thanks.

<!-- gh-comment-id:415078390 --> @andysc commented on GitHub (Aug 22, 2018): No, not hidden - it's the WiFi hotspot on my iPhone - usually works fine. I tried esp debugging wifi but it just inserted lots of WiFi event 7 into the stream, like this: ``` *WM: MW40V_B9B3 *WM: -75 *WM: Sent config page wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: WiFi save *WM: Sent wifi save page wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 0 *WM: Failed to connect. wifi evt: 7 wifi evt: 7 *WM: Request redirected to captive portal wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 scandone *WM: Scan done *WM: DUP AP: BWU2 ``` Yes, result 0 is WL_IDLE_STATUS, which, yes, is weird. I'll try changing setConnectTimeout... thanks.
Author
Owner

@andysc commented on GitHub (Aug 22, 2018):

That didn't help - I set
wifiManager.setConnectTimeout(5);
It just waited 5 seconds then gave the same result...

*WM: WiFi save
*WM: Sent wifi save page
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Waiting for connection result with time out
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connection timed out
wifi evt: 7
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.
*WM: Request redirected to captive portal
wifi evt: 7
<!-- gh-comment-id:415079990 --> @andysc commented on GitHub (Aug 22, 2018): That didn't help - I set `wifiManager.setConnectTimeout(5);` It just waited 5 seconds then gave the same result... ``` *WM: WiFi save *WM: Sent wifi save page wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Waiting for connection result with time out wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connection timed out wifi evt: 7 *WM: Connection result: *WM: 0 *WM: Failed to connect. *WM: Request redirected to captive portal wifi evt: 7 ```
Author
Owner

@tablatronix commented on GitHub (Aug 22, 2018):

have you tried staging master latest ?

Sorry I forgot you said you are using wm master, going to test now

<!-- gh-comment-id:415083711 --> @tablatronix commented on GitHub (Aug 22, 2018): have you tried staging master latest ? Sorry I forgot you said you are using wm master, going to test now
Author
Owner

@tablatronix commented on GitHub (Aug 22, 2018):

cannot reproduce with wm master and esp8266 staging

<!-- gh-comment-id:415086933 --> @tablatronix commented on GitHub (Aug 22, 2018): cannot reproduce with wm master and esp8266 staging
Author
Owner

@tablatronix commented on GitHub (Aug 22, 2018):

oh which lwip are you using ?

<!-- gh-comment-id:415127508 --> @tablatronix commented on GitHub (Aug 22, 2018): oh which lwip are you using ?
Author
Owner

@andysc commented on GitHub (Aug 22, 2018):

not sure what you're asking - current release of wifimanager with not-released-yet version of ESP core? (sorry, I don't use GitHub very much)

I tried the dev branch of wifi manager with the current release of ESP core and that works fine, so when that's released, all should be good.

lwip is "v2 lower memory"

<!-- gh-comment-id:415179043 --> @andysc commented on GitHub (Aug 22, 2018): not sure what you're asking - current release of wifimanager with not-released-yet version of ESP core? (sorry, I don't use GitHub very much) I tried the dev branch of wifi manager with the current release of ESP core and that works fine, so when that's released, all should be good. lwip is "v2 lower memory"
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

Hmm I didnt see any changes to esp core since last release that would have fixed any issues.
Ill test 2.4.2 also.

Maybe try lwip 1.4? There are some outstanding bugs with wifi disconnect/reconnect

<!-- gh-comment-id:415229279 --> @tablatronix commented on GitHub (Aug 23, 2018): Hmm I didnt see any changes to esp core since last release that would have fixed any issues. Ill test 2.4.2 also. Maybe try lwip 1.4? There are some outstanding bugs with wifi disconnect/reconnect
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

it's 2.4.2 core that's causing the problem with v0.14 of WiFiManager.

<!-- gh-comment-id:415304274 --> @andysc commented on GitHub (Aug 23, 2018): it's 2.4.2 core that's causing the problem with v0.14 of WiFiManager.
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

no, lwip 1.4 didn't fix it.

BTW, is it possible to change how long it tries to connect before it gives up and goes into captive portal mode? A bit longer would be useful :)

<!-- gh-comment-id:415305637 --> @andysc commented on GitHub (Aug 23, 2018): no, lwip 1.4 didn't fix it. BTW, is it possible to change how long it tries to connect before it gives up and goes into captive portal mode? A bit longer would be useful :)
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

ah, that's exactly what setConnectTimeout() does :) TVM

<!-- gh-comment-id:415402244 --> @andysc commented on GitHub (Aug 23, 2018): ah, that's exactly what setConnectTimeout() does :) TVM
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

I wonder if adding a disconnect before begin() in connectwifi would fix this hmm

<!-- gh-comment-id:415424997 --> @tablatronix commented on GitHub (Aug 23, 2018): I wonder if adding a disconnect before begin() in connectwifi would fix this hmm
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

I was just putting some trace into ESP8266WiFiSTA.cpp to explore some things like that :)
Apart from a couple of checks for _persistent mode, it doesn't seem to be any different between 2.4.1 and 2.4.2

<!-- gh-comment-id:415478480 --> @andysc commented on GitHub (Aug 23, 2018): I was just putting some trace into ESP8266WiFiSTA.cpp to explore some things like that :) Apart from a couple of checks for _persistent mode, it doesn't seem to be any different between 2.4.1 and 2.4.2
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

I also tried putting the mode(STA) before the connection attempt rather than after it's succeeded (which has always seemed inexplicable to me)... that makes the portal window close, but doesn't help the reconnect problem.

<!-- gh-comment-id:415478889 --> @andysc commented on GitHub (Aug 23, 2018): I also tried putting the mode(STA) *before* the connection attempt rather than after it's succeeded (which has always seemed inexplicable to me)... that makes the portal window close, but doesn't help the reconnect problem.
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

WiFi.mode(WIFI_STA);, I meant

<!-- gh-comment-id:415479305 --> @andysc commented on GitHub (Aug 23, 2018): ```WiFi.mode(WIFI_STA);```, I meant
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

yeah thats why I suggested lwip.

I just tested this and could not reproduce master branch 2.4.2

<!-- gh-comment-id:415485304 --> @tablatronix commented on GitHub (Aug 23, 2018): yeah thats why I suggested lwip. I just tested this and could not reproduce master branch 2.4.2
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

I suspected when it says idle_status it is between modes, or thinks sta is not on.

so disconnect then begin() fixes it ( this is implemented in development branch already )

<!-- gh-comment-id:415489679 --> @tablatronix commented on GitHub (Aug 23, 2018): I suspected when it says idle_status it is between modes, or thinks sta is not on. so disconnect then begin() fixes it ( this is implemented in development branch already )
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

\o/ yay! That worked :)
WiFi.disconnect(false);
before the connect.

<!-- gh-comment-id:415490696 --> @andysc commented on GitHub (Aug 23, 2018): \o/ yay! That worked :) ```WiFi.disconnect(false);``` before the connect.
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

pushed to hotfixes as test

<!-- gh-comment-id:415490717 --> @tablatronix commented on GitHub (Aug 23, 2018): pushed to hotfixes as test
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

I have no idea what causes this, but this is the workaround, you can test hotfixes branch if you want. Not merging into master just yet, until I know whats going on

<!-- gh-comment-id:415491081 --> @tablatronix commented on GitHub (Aug 23, 2018): I have no idea what causes this, but this is the workaround, you can test hotfixes branch if you want. Not merging into master just yet, until I know whats going on
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

didn't see your commit before I tried that.
Where is the WiFi_Disconnect() function defined? I get a compile error as it can't find that.

<!-- gh-comment-id:415494360 --> @andysc commented on GitHub (Aug 23, 2018): didn't see your commit before I tried that. Where is the WiFi_Disconnect() function defined? I get a compile error as it can't find that.
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

oops
hmm there is already a disconnect in the code
but only for existing creds

<!-- gh-comment-id:415496341 --> @tablatronix commented on GitHub (Aug 23, 2018): oops hmm there is already a disconnect in the code but only for existing creds
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

where does wifi_station_disconnect live? Is that preferred?

<!-- gh-comment-id:415498293 --> @andysc commented on GitHub (Aug 23, 2018): where does ```wifi_station_disconnect``` live? Is that preferred?
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

the UART stuff wrapped round it looks a bit like it's probably not preferred ;)

<!-- gh-comment-id:415498509 --> @andysc commented on GitHub (Aug 23, 2018): the UART stuff wrapped round it looks a bit like it's probably *not* preferred ;)
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

thats how it is in WiFi.disconnect but I am not sure if its needed for the config saving or the disconnect

<!-- gh-comment-id:415503162 --> @tablatronix commented on GitHub (Aug 23, 2018): thats how it is in WiFi.disconnect but I am not sure if its needed for the config saving or the disconnect
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

If you use WiFi.disconnect you have to toggle persistent off and stuff or else it can erase your creds.
Not sure what you mean by preferred, I prefer it..

<!-- gh-comment-id:415503982 --> @tablatronix commented on GitHub (Aug 23, 2018): If you use WiFi.disconnect you have to toggle persistent off and stuff or else it can erase your creds. Not sure what you mean by preferred, I prefer it..
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

Hey I added a debug status to hotfixes, if you can test that if you have time and let me know what the debug output says I would appreciate it.

I am curious if it will tell us anything , If it does it might be a way to check for this condition in the future I am curious if status is useful ( there are reasons to not always do a disconnect here, it causes a 2 second delay ) which is bad for battery devices

<!-- gh-comment-id:415514166 --> @tablatronix commented on GitHub (Aug 23, 2018): Hey I added a debug status to hotfixes, if you can test that if you have time and let me know what the debug output says I would appreciate it. I am curious if it will tell us anything , If it does it might be a way to check for this condition in the future I am curious if status is useful ( there are reasons to not always do a disconnect here, it causes a 2 second delay ) which is bad for battery devices
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

yup - the version in hot fixes works.

The two times that status gets printed, right at the start, and here when it reconnects, it's 0 both times...

*WM: Handle root
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
*WM: Waiting for connection result with time out
*WM: Connection result: 
*WM: 3
connected to wifi!
<!-- gh-comment-id:415536650 --> @andysc commented on GitHub (Aug 23, 2018): yup - the version in hot fixes works. The two times that status gets printed, right at the start, and here when it reconnects, it's 0 both times... ``` *WM: Handle root *WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 *WM: Waiting for connection result with time out *WM: Connection result: *WM: 3 connected to wifi! ```
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

hmm, hang on, I've done something and it's stopped working again - BRB

<!-- gh-comment-id:415540119 --> @andysc commented on GitHub (Aug 23, 2018): hmm, hang on, I've done something and it's stopped working again - BRB
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

Heh story of my life. Debugging debugs

<!-- gh-comment-id:415540696 --> @tablatronix commented on GitHub (Aug 23, 2018): Heh story of my life. Debugging debugs
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

very odd - it's not working now. I think I had the wrong lwip version, but I've tried with 2 and 1.4 and neither work.

<!-- gh-comment-id:415546673 --> @andysc commented on GitHub (Aug 23, 2018): very odd - it's not working now. I think I had the wrong lwip version, but I've tried with 2 and 1.4 and neither work.
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

you said you put a mode(sta) before maybe that is what fixed it ?

<!-- gh-comment-id:415549048 --> @tablatronix commented on GitHub (Aug 23, 2018): you said you put a mode(sta) before maybe that is what fixed it ?
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

OK ... so it doesn't work for me with your fix:

    ETS_UART_INTR_DISABLE();
    wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();

but it DOES work with my earlier suggestion:

WiFi.disconnect(false);

(with lwip 2 and 2.4.2 core)

<!-- gh-comment-id:415550432 --> @andysc commented on GitHub (Aug 23, 2018): OK ... so it doesn't work for me with your fix: ``` ETS_UART_INTR_DISABLE(); wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); ``` but it DOES work with my earlier suggestion: ``` WiFi.disconnect(false); ``` (with lwip 2 and 2.4.2 core)
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

I'll try putting the mode(STA) back in with your version... l8r

<!-- gh-comment-id:415550855 --> @andysc commented on GitHub (Aug 23, 2018): I'll try putting the mode(STA) back in with your version... l8r
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

putting in WiFi.mode(WIFI_STA); before your debug status line only has the effect of closing the portal window.
It still doesn't connect.
I think we might have to go with my fix ;)

<!-- gh-comment-id:415552885 --> @andysc commented on GitHub (Aug 23, 2018): putting in ``` WiFi.mode(WIFI_STA);``` before your debug status line only has the effect of closing the portal window. It still doesn't connect. I think we might have to go with my fix ;)
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

ah, best to put in the mode change too - otherwise the portal window closes after the device reconnects...

<!-- gh-comment-id:415553823 --> @andysc commented on GitHub (Aug 23, 2018): ah, best to put in the mode change too - otherwise the portal window closes after the device reconnects...
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

OK - actually the mode change doesn't affect the window closing.
so my change to your hot fix is:

    //trying to fix connection in progress hanging
/*
    ETS_UART_INTR_DISABLE();
    wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();
*/
        // ASC
    WiFi.disconnect(false);
<!-- gh-comment-id:415554772 --> @andysc commented on GitHub (Aug 23, 2018): OK - actually the mode change doesn't affect the window closing. so my change to your hot fix is: ``` //trying to fix connection in progress hanging /* ETS_UART_INTR_DISABLE(); wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); */ // ASC WiFi.disconnect(false); ```
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

hmm, it is literally the same code

bool ESP8266WiFiSTAClass::disconnect(bool wifioff) {
    bool ret;
    struct station_config conf;
    *conf.ssid = 0;
    *conf.password = 0;

    ETS_UART_INTR_DISABLE();
    if(WiFi._persistent) {
        wifi_station_set_config(&conf);
    } else {
        wifi_station_set_config_current(&conf);
    }
    ret = wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();

    if(wifioff) {
        WiFi.enableSTA(false);
    }

    return ret;
}
<!-- gh-comment-id:415557007 --> @tablatronix commented on GitHub (Aug 23, 2018): hmm, it is literally the same code ```C++ bool ESP8266WiFiSTAClass::disconnect(bool wifioff) { bool ret; struct station_config conf; *conf.ssid = 0; *conf.password = 0; ETS_UART_INTR_DISABLE(); if(WiFi._persistent) { wifi_station_set_config(&conf); } else { wifi_station_set_config_current(&conf); } ret = wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); if(wifioff) { WiFi.enableSTA(false); } return ret; } ```
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

could it be a race condition ?
add delay(500) after it

SO sorry man, makes no sense, no idea whats going on, I can change it to WiFi.disconnect but probably wrap it in WiFi.persistent(false) to prevent erasing config

<!-- gh-comment-id:415557279 --> @tablatronix commented on GitHub (Aug 23, 2018): could it be a race condition ? add delay(500) after it SO sorry man, makes no sense, no idea whats going on, I can change it to WiFi.disconnect but probably wrap it in WiFi.persistent(false) to prevent erasing config
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

curious have you tried erasing flash or using another esp, did I ask that already ?

<!-- gh-comment-id:415558865 --> @tablatronix commented on GitHub (Aug 23, 2018): curious have you tried erasing flash or using another esp, did I ask that already ?
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

oh wow, so it is the same code - that's nuts. ...<--- apart from setting the config object... ;)
Yeah - could be race condition - I'll try that.

No, haven't tried either of those things, and no you didn't ask... good call - I'll try that too

<!-- gh-comment-id:415581584 --> @andysc commented on GitHub (Aug 23, 2018): oh wow, so it is the same code - that's nuts. ...<--- apart from setting the config object... ;) Yeah - could be race condition - I'll try that. No, haven't tried either of those things, and no you didn't ask... good call - I'll try that too
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

adding a delay between the disconnect code and the begin didn't help.

<!-- gh-comment-id:415587446 --> @andysc commented on GitHub (Aug 23, 2018): adding a delay between the disconnect code and the begin didn't help.
Author
Owner

@tablatronix commented on GitHub (Aug 23, 2018):

Well what ever works, until someone else reproduces just use whatever you need to
ill try changing it later

<!-- gh-comment-id:415592289 --> @tablatronix commented on GitHub (Aug 23, 2018): Well what ever works, until someone else reproduces just use whatever you need to ill try changing it later
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

just had a thought - I'm configuring the same wifi credentials each time (I turn off my wifi hotspot so the ESP doesn't see it, it goes into config portal and then I turn the wifi on and then reconfigure the same wifi settings in WM).
So... in wifi.begin() it checks to see if the config is the same, and does something different (does a set config) if so.
In my case, it is the same (well, as far as SSID/password concerned) so maybe that's causing something?

I erased the wifi credentials and it worked fine. Then the next time it didn't (once I'd set some credentials).

<!-- gh-comment-id:415593516 --> @andysc commented on GitHub (Aug 23, 2018): just had a thought - I'm configuring the **same** wifi credentials each time (I turn off my wifi hotspot so the ESP doesn't see it, it goes into config portal and then I turn the wifi on and then reconfigure the same wifi settings in WM). So... in wifi.begin() it checks to see if the config is the same, and does something different (does a set config) if so. In my case, it *is* the same (well, as far as SSID/password concerned) so maybe that's causing something? I erased the wifi credentials and it worked fine. Then the next time it didn't (once I'd set some credentials).
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

aha!
So, with the existing code, when it tries to reconnect it says:

*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
STA config unchanged
*WM: Waiting for connection result with time out
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connection timed out
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.

If I go into
Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src
and change ESP8266WiFiSTA.cpp

in function begin(...)
if (sta_config_equal(conf_compare, conf)) {
to
if (0)
i.e. so even if the new credentials are the same, it still calls
wifi_station_set_config_current

Then it works! (with your hot fix version of WiFiManager.cpp).

The output this time is:

*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
*WM: Waiting for connection result with time out
wifi evt: 2
scandone
switch to channel 6
state: 0 -> 2 (b0)
wifi evt: 7
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt 

connected with PiWiFi, channel 6
dhcp client start...
wifi evt: 0
ip:172.20.10.3,mask:255.255.255.240,gw:172.20.10.1
wifi evt: 3
*WM: Connection result: 
*WM: 3
station: f4:5c:89:a1:54:c3 leave, AID = 1
rm 1
bcn 0
del if1
pm open,type:2 0
mode : sta(5c:cf:7f:wifi evt: 6
59:ff:62)
connected to wifi!

BTW I couldn't work out how to get the output from that DEBUGV in there to say the STA config is the same, so I replaced it with a Serial.println and it displayed that (before I made the change!) when the wifi credentials were the same. So that confirmed it wasn't calling the set config when the credentials are the same.

<!-- gh-comment-id:415603041 --> @andysc commented on GitHub (Aug 23, 2018): aha! So, with the existing code, when it tries to reconnect it says: ``` *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 STA config unchanged *WM: Waiting for connection result with time out wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connection timed out *WM: Connection result: *WM: 0 *WM: Failed to connect. ``` If I go into `Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src` and change `ESP8266WiFiSTA.cpp` in function `begin(...)` ` if (sta_config_equal(conf_compare, conf)) {` to ` if (0)` i.e. so even if the new credentials are the same, it still calls `wifi_station_set_config_current` Then it works! (with your hot fix version of `WiFiManager.cpp`). The output this time is: ``` *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 *WM: Waiting for connection result with time out wifi evt: 2 scandone switch to channel 6 state: 0 -> 2 (b0) wifi evt: 7 state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 2 cnt connected with PiWiFi, channel 6 dhcp client start... wifi evt: 0 ip:172.20.10.3,mask:255.255.255.240,gw:172.20.10.1 wifi evt: 3 *WM: Connection result: *WM: 3 station: f4:5c:89:a1:54:c3 leave, AID = 1 rm 1 bcn 0 del if1 pm open,type:2 0 mode : sta(5c:cf:7f:wifi evt: 6 59:ff:62) connected to wifi! ``` BTW I couldn't work out how to get the output from that DEBUGV in there to say the STA config is the same, so I replaced it with a `Serial.println` and it displayed that (before I made the change!) when the wifi credentials were the same. So that confirmed it wasn't calling the set config when the credentials are the same.
Author
Owner

@andysc commented on GitHub (Aug 23, 2018):

BTW, how do I turn off WM debug? It just seems to be on all the time

<!-- gh-comment-id:415606521 --> @andysc commented on GitHub (Aug 23, 2018): BTW, how do I turn off WM debug? It just seems to be on all the time
Author
Owner

@PProvost commented on GitHub (Aug 29, 2018):

Any updates on resolving this with the current ESP Core, etc.? From the thread above, it isn't clear that the hotfix will resolve it. Thanks.

I have confirmed, as @andysc discovered a couple of messages back, that it seems to be caused by re-using the same SSID & creds. Basically, if I full reset the ESP back to the stock AT firmware, it is fine the next time, but once it restarts, we're back to the "Connection result: 0" issue.

<!-- gh-comment-id:416792945 --> @PProvost commented on GitHub (Aug 29, 2018): Any updates on resolving this with the current ESP Core, etc.? From the thread above, it isn't clear that the hotfix will resolve it. Thanks. I have confirmed, as @andysc discovered a couple of messages back, that it seems to be caused by re-using the same SSID & creds. Basically, if I full reset the ESP back to the stock AT firmware, it is fine the next time, but once it restarts, we're back to the "Connection result: 0" issue.
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

Yeah this is a well know persistent begin bug.
Ill take a look and see. Not sure why you see a different result sometimes. Yeah that is not the best test method either. There are also bugs in wm that are fixed in develoment.

<!-- gh-comment-id:416795763 --> @tablatronix commented on GitHub (Aug 29, 2018): Yeah this is a well know persistent begin bug. Ill take a look and see. Not sure why you see a different result sometimes. Yeah that is not the best test method either. There are also bugs in wm that are fixed in develoment.
Author
Owner

@andysc commented on GitHub (Aug 29, 2018):

my fix (forcing it to call wifi_station_set_config_current, whatever the wifi settings), is working fine for me.

<!-- gh-comment-id:416861897 --> @andysc commented on GitHub (Aug 29, 2018): my fix (forcing it to call `wifi_station_set_config_current`, whatever the wifi settings), is working fine for me.
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

I know what the issue is I think.
Gonna check

<!-- gh-comment-id:416994498 --> @tablatronix commented on GitHub (Aug 29, 2018): I know what the issue is I think. Gonna check
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

ok can you post exactly how to reproduce

  • wm master
  • esp 2.4.2
  • save credentials in esp
  • take ap down
  • reset
  • autoconnect fails -> cp starts
  • enter cp , resave the existing saved credentials ( turn ap back on )
  • click save
  • ????

Is this correct?

<!-- gh-comment-id:417013232 --> @tablatronix commented on GitHub (Aug 29, 2018): ok can you post exactly how to reproduce - wm master - esp 2.4.2 - save credentials in esp - take ap down - reset - autoconnect fails -> cp starts - enter cp , resave the existing saved credentials ( turn ap back on ) - click save - ???? Is this correct?
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

I think this is related to a bug fix I made in 2.4.2
https://github.com/esp8266/Arduino/pull/3798/files

<!-- gh-comment-id:417014273 --> @tablatronix commented on GitHub (Aug 29, 2018): I think this is related to a bug fix I made in 2.4.2 https://github.com/esp8266/Arduino/pull/3798/files
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

can you try
WiFi.enableSTA(false); right before the begin()

    //trying to fix connection in progress hanging
    ETS_UART_INTR_DISABLE();
    wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();
    WiFi.enableSTA(false);
    WiFi.begin(ssid.c_str(), pass.c_str());

Actually that will probably not work

hmm

<!-- gh-comment-id:417015963 --> @tablatronix commented on GitHub (Aug 29, 2018): can you try ` WiFi.enableSTA(false);` right before the begin() ```C++ //trying to fix connection in progress hanging ETS_UART_INTR_DISABLE(); wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); WiFi.enableSTA(false); WiFi.begin(ssid.c_str(), pass.c_str()); ``` Actually that will probably not work hmm
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

I added some test fix
forcing connect in begin, and some debugging

res = WiFi.begin(ssid.c_str(), pass.c_str(),0,NULL,true);
if(res != WL_CONNECTED) DEBUG_WM(F("[ERROR]")+" "+(String)res);
<!-- gh-comment-id:417030398 --> @tablatronix commented on GitHub (Aug 29, 2018): I added some test fix forcing connect in begin, and some debugging ```C++ res = WiFi.begin(ssid.c_str(), pass.c_str(),0,NULL,true); if(res != WL_CONNECTED) DEBUG_WM(F("[ERROR]")+" "+(String)res); ```
Author
Owner

@PProvost commented on GitHub (Aug 29, 2018):

@andysc - above you mentioned that your fix (forcing it to set...) seems to be working. Did you make that fix against the current release or against the hotfix branch? It is unclear trying to follow the thread how to make the workaround. I don't suppose you have a fork repo with the change already in place? :)

<!-- gh-comment-id:417076976 --> @PProvost commented on GitHub (Aug 29, 2018): @andysc - above you mentioned that your fix (forcing it to set...) seems to be working. Did you make that fix against the current release or against the hotfix branch? It is unclear trying to follow the thread how to make the workaround. I don't suppose you have a fork repo with the change already in place? :)
Author
Owner

@tablatronix commented on GitHub (Aug 29, 2018):

That was a kludge in esp lib code not wm.
It is the symtom not really a fix

<!-- gh-comment-id:417092293 --> @tablatronix commented on GitHub (Aug 29, 2018): That was a kludge in esp lib code not wm. It is the symtom not really a fix
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

I agree it was a kludge ;)
But the WM code was the vanilla 0.14.0 master branch install.
The hack was to a file in the ESP wifi core code

<!-- gh-comment-id:417211603 --> @andysc commented on GitHub (Aug 30, 2018): I agree it was a kludge ;) But the WM code was the vanilla 0.14.0 master branch install. The hack was to a file in the ESP wifi core code
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

re:
>ok can you post exactly how to reproduce
Yes, that's right
Just to be clear:
After the reconnect fails (because the AP is off), and it enters AP mode,
turn back on the AP
Then when the CP window opens, your (previously configured) AP is visible.
Select the previously configure AP, enter password
click save

<!-- gh-comment-id:417212938 --> @andysc commented on GitHub (Aug 30, 2018): re: `>ok can you post exactly how to reproduce` Yes, that's right Just to be clear: After the reconnect fails (because the AP is off), and it enters AP mode, `turn back on the AP` Then when the CP window opens, your (previously configured) AP is visible. `Select the previously configure AP, enter password` `click save`
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

what do you want me to try?
Not the "actually that will probably not work"...
the test fix?
or just this bit?

res = WiFi.begin(ssid.c_str(), pass.c_str(),0,NULL,true);
if(res != WL_CONNECTED) DEBUG_WM(F("[ERROR]")+" "+(String)res);
<!-- gh-comment-id:417213395 --> @andysc commented on GitHub (Aug 30, 2018): what do you want me to try? Not the "actually that will probably not work"... the test fix? or just this bit? ``` res = WiFi.begin(ssid.c_str(), pass.c_str(),0,NULL,true); if(res != WL_CONNECTED) DEBUG_WM(F("[ERROR]")+" "+(String)res); ```
Author
Owner

@tablatronix commented on GitHub (Aug 30, 2018):

yes, and I committed that to hotfixes so you can try the branch if you want

<!-- gh-comment-id:417303714 --> @tablatronix commented on GitHub (Aug 30, 2018): yes, and I committed that to hotfixes so you can try the branch if you want
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

now I'm running the right code on the device...

core 2.42 with your hot fix ...

*WM: Handle root
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
STA config unchanged
*WM: [ERROR] WiFi.begin res:
*WM: 0
*WM: Waiting for connection result with time out
*WM: Connection timed out
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.
*WM: Request redirected to captive portal
*WM: Handle root

<!-- gh-comment-id:417375136 --> @andysc commented on GitHub (Aug 30, 2018): now I'm running the right code on the device... core 2.42 with your hot fix ... ``` *WM: Handle root *WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 STA config unchanged *WM: [ERROR] WiFi.begin res: *WM: 0 *WM: Waiting for connection result with time out *WM: Connection timed out *WM: Connection result: *WM: 0 *WM: Failed to connect. *WM: Request redirected to captive portal *WM: Handle root ```
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

(that STA config unchanged is a line of debug I left in ESP8266STA.cpp (line 149)

   if (sta_config_equal(conf_compare, conf)) {
        // ASC
        Serial.println("STA config unchanged");

        DEBUGV("sta config unchanged");
    }
<!-- gh-comment-id:417376400 --> @andysc commented on GitHub (Aug 30, 2018): (that `STA config unchanged` is a line of debug I left in ESP8266STA.cpp (line 149) ``` if (sta_config_equal(conf_compare, conf)) { // ASC Serial.println("STA config unchanged"); DEBUGV("sta config unchanged"); } ```
Author
Owner

@tablatronix commented on GitHub (Aug 30, 2018):

oh you might have to add a connecttimeout
mine took a delay to work
I will test again with waitforconnectresult

EDIT
oh its says with timeout.. hmmmmmm

<!-- gh-comment-id:417427995 --> @tablatronix commented on GitHub (Aug 30, 2018): oh you might have to add a connecttimeout mine took a delay to work I will test again with waitforconnectresult EDIT oh its says with timeout.. hmmmmmm
Author
Owner

@andysc commented on GitHub (Aug 30, 2018):

I've got a connect timeout of 30...
wifiManager.setConnectTimeout(30);
There's a 30 sec gap between these two lines:

*WM: Waiting for connection result with time out
*WM: Connection timed out
<!-- gh-comment-id:417471435 --> @andysc commented on GitHub (Aug 30, 2018): I've got a connect timeout of 30... ` wifiManager.setConnectTimeout(30);` There's a 30 sec gap between these two lines: ``` *WM: Waiting for connection result with time out *WM: Connection timed out ```
Author
Owner

@tablatronix commented on GitHub (Aug 30, 2018):

so strange, Do you have esp debugging on ? Is the wifi not doing anyhting, I mean we are calling wifi connect now it should be looking for the ap or something
use debug flag wifi

<!-- gh-comment-id:417472037 --> @tablatronix commented on GitHub (Aug 30, 2018): so strange, Do you have esp debugging on ? Is the wifi not doing anyhting, I mean we are calling wifi connect now it should be looking for the ap or something use debug flag wifi
Author
Owner

@andysc commented on GitHub (Aug 31, 2018):

The debug is very boring...

*WM: WiFi save
*WM: Sent wifi save page
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
ASC: STA config unchanged
ASC: calling wifi_station_connect
ASC: returned from wifi_station_connect
*WM: [ERROR] WiFi.begin res:
*WM: 0
*WM: Waiting for connection result with time out
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connection timed out
wifi evt: 7
*WM: Connection result: 
*WM: 0
*WM: Failed to connect.
*WM: Request redirected to captive portal
*WM: Handle root

I put debug round the call to wifi_station_connect just to check:

ASC: calling wifi_station_connect
ASC: returned from wifi_station_connect
<!-- gh-comment-id:417594553 --> @andysc commented on GitHub (Aug 31, 2018): The debug is very boring... ``` *WM: WiFi save *WM: Sent wifi save page wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 ASC: STA config unchanged ASC: calling wifi_station_connect ASC: returned from wifi_station_connect *WM: [ERROR] WiFi.begin res: *WM: 0 *WM: Waiting for connection result with time out wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connection timed out wifi evt: 7 *WM: Connection result: *WM: 0 *WM: Failed to connect. *WM: Request redirected to captive portal *WM: Handle root ``` I put debug round the call to `wifi_station_connect` just to check: ``` ASC: calling wifi_station_connect ASC: returned from wifi_station_connect ```
Author
Owner

@andysc commented on GitHub (Aug 31, 2018):

Note if I clear the WiFi credentials (in the IDE), it works great...

*WM: WiFi save
wifi evt: 7
*WM: Sent wifi save page
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Status:
*WM: 0
ASC: calling wifi_station_connect
ASC: returned from wifi_station_connect
*WM: [ERROR] WiFi.begin res:
*WM: 6
*WM: Waiting for connection result with time out
wifi evt: 2
wifi evt: 7
wifi evt: 7
scandone
switch to channel 6
state: 0 -> 2 (b0)
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt 
wifi evt: 7
wifi evt: 7

connected with PiWiFi, channel 6
dhcp client start...
wifi evt: 0
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
ip:172.20.10.3,mask:255.255.255.240,gw:172.20.10.1
wifi evt: 3
*WM: Connection result: 
*WM: 3
station: f4:5c:89:a1:54:c3 leave, AID = 1
rm 1
bcn 0
del if1
pm open,type:2 0
mode : sta(5c:cf:7f:wifi evt: 6
59:ff:62)
connected to wifi!

(even though the res return code is 6... that looks better than '0' for a successful subsequent connection)

ASC: returned from wifi_station_connect
*WM: [ERROR] WiFi.begin res:
*WM: 6
*WM: Waiting for connection result with time out
<!-- gh-comment-id:417596194 --> @andysc commented on GitHub (Aug 31, 2018): Note if I clear the WiFi credentials (in the IDE), it works great... ``` *WM: WiFi save wifi evt: 7 *WM: Sent wifi save page wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Status: *WM: 0 ASC: calling wifi_station_connect ASC: returned from wifi_station_connect *WM: [ERROR] WiFi.begin res: *WM: 6 *WM: Waiting for connection result with time out wifi evt: 2 wifi evt: 7 wifi evt: 7 scandone switch to channel 6 state: 0 -> 2 (b0) wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 1 cnt wifi evt: 7 wifi evt: 7 connected with PiWiFi, channel 6 dhcp client start... wifi evt: 0 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 wifi evt: 7 ip:172.20.10.3,mask:255.255.255.240,gw:172.20.10.1 wifi evt: 3 *WM: Connection result: *WM: 3 station: f4:5c:89:a1:54:c3 leave, AID = 1 rm 1 bcn 0 del if1 pm open,type:2 0 mode : sta(5c:cf:7f:wifi evt: 6 59:ff:62) connected to wifi! ``` (even though the res return code is 6... that looks better than '0' for a successful subsequent connection) ``` ASC: returned from wifi_station_connect *WM: [ERROR] WiFi.begin res: *WM: 6 *WM: Waiting for connection result with time out ```
Author
Owner

@bepehr commented on GitHub (Dec 3, 2018):

I have same problem too , so i downgrade it to v 0.13.0

<!-- gh-comment-id:443729731 --> @bepehr commented on GitHub (Dec 3, 2018): I have same problem too , so i downgrade it to v 0.13.0
Author
Owner

@tablatronix commented on GitHub (Dec 3, 2018):

Anyone figure this out?

<!-- gh-comment-id:443870212 --> @tablatronix commented on GitHub (Dec 3, 2018): Anyone figure this out?
Author
Owner

@andysc commented on GitHub (Dec 4, 2018):

I'm using 0.14.0, but (copied from way up there ^^ ) ...

you need to go into
Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src
and change ESP8266WiFiSTA.cpp

in function begin(...)
if (sta_config_equal(conf_compare, conf)) {
to
if (0)
i.e. so even if the new credentials are the same, it still calls
wifi_station_set_config_current

Then it works!
(this is with ESP core 2.4.2)

<!-- gh-comment-id:444015375 --> @andysc commented on GitHub (Dec 4, 2018): I'm using 0.14.0, **but** (copied from way up there ^^ ) ... you need to go into Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src and change ESP8266WiFiSTA.cpp in function begin(...) if (sta_config_equal(conf_compare, conf)) { to if (0) i.e. so even if the new credentials are the same, it still calls wifi_station_set_config_current Then it works! (this is with ESP core 2.4.2)
Author
Owner

@bepehr commented on GitHub (Dec 4, 2018):

I just want to confirm @andysc solution is worked for me .
Library : 0.14.0
Esp core : 2.4.0

<!-- gh-comment-id:444114119 --> @bepehr commented on GitHub (Dec 4, 2018): I just want to confirm @andysc solution is worked for me . Library : 0.14.0 Esp core : 2.4.0
Author
Owner

@andysc commented on GitHub (Dec 4, 2018):

:)

<!-- gh-comment-id:444124875 --> @andysc commented on GitHub (Dec 4, 2018): :)
Author
Owner

@tablatronix commented on GitHub (Dec 4, 2018):

can you guys debug this and tell me which condition is met, if persistent?
I still cannot reproduce, it must be something in user code that triggers it
( or make a minimal reproduction sketch )

    struct station_config conf_compare;
    if(WiFi._persistent){
        DEBUGV("sta config persistent"); // <---
        wifi_station_get_config_default(&conf_compare);
    }
    else {
        DEBUGV("sta config not persistent"); // <---
        wifi_station_get_config(&conf_compare);
    }

    if(sta_config_equal(conf_compare, conf)) {
        DEBUGV("sta config unchanged");
    }
<!-- gh-comment-id:444132122 --> @tablatronix commented on GitHub (Dec 4, 2018): can you guys debug this and tell me which condition is met, if persistent? I still cannot reproduce, it must be something in user code that triggers it ( or make a minimal reproduction sketch ) ```C++ struct station_config conf_compare; if(WiFi._persistent){ DEBUGV("sta config persistent"); // <--- wifi_station_get_config_default(&conf_compare); } else { DEBUGV("sta config not persistent"); // <--- wifi_station_get_config(&conf_compare); } if(sta_config_equal(conf_compare, conf)) { DEBUGV("sta config unchanged"); } ```
Author
Owner

@tablatronix commented on GitHub (Dec 4, 2018):

I will have to reread this but I think the premise is, we turn off sta, then when saving the same wifi we cannot reconnect, because sdk thinks we are already connected, even though we are not, and setting config current does not renable wifi properly.

can you guys try removing the if connect() condition and always do
wifi_station_connect(); in there as a work around instead of bypassing the config check and see if that helps also?

( I thought this was working in hotfixes already )

<!-- gh-comment-id:444146569 --> @tablatronix commented on GitHub (Dec 4, 2018): I will have to reread this but I think the premise is, we turn off sta, then when saving the same wifi we cannot reconnect, because sdk thinks we are already connected, even though we are not, and setting config current does not renable wifi properly. can you guys try removing the if connect() condition and always do `wifi_station_connect();` in there as a work around instead of bypassing the config check and see if that helps also? ( I thought this was working in hotfixes already )
Author
Owner

@andysc commented on GitHub (Dec 4, 2018):

yes, that is the premise (and the test case... re-configure onto same wifi).
Where is the "if connect()" condition you want us to change?
I'll try it

<!-- gh-comment-id:444156680 --> @andysc commented on GitHub (Dec 4, 2018): yes, that is the premise (and the test case... re-configure onto same wifi). Where is the "if connect()" condition you want us to change? I'll try it
Author
Owner

@tablatronix commented on GitHub (Dec 20, 2018):

a few lines below that other kludge in begin

    ETS_UART_INTR_DISABLE();
   // if(connect) { // bypass
        wifi_station_connect();
   // } // 
    ETS_UART_INTR_ENABLE();

<!-- gh-comment-id:449067498 --> @tablatronix commented on GitHub (Dec 20, 2018): a few lines below that other kludge in begin ```C++ ETS_UART_INTR_DISABLE(); // if(connect) { // bypass wifi_station_connect(); // } // ETS_UART_INTR_ENABLE(); ```
Author
Owner

@andysc commented on GitHub (Dec 20, 2018):

thanks - got distracted - I'll try it this weekend

<!-- gh-comment-id:449100973 --> @andysc commented on GitHub (Dec 20, 2018): thanks - got distracted - I'll try it this weekend
Author
Owner

@quique123 commented on GitHub (Oct 29, 2019):

Did you guys work out the bit where the Esp got disconnected from the successfully configured ssid after exiting the config portal?

<!-- gh-comment-id:547232785 --> @quique123 commented on GitHub (Oct 29, 2019): Did you guys work out the bit where the Esp got disconnected from the successfully configured ssid after exiting the config portal?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#587
No description provided.