[GH-ISSUE #1388] BUG, non-bocking, AP is shut aften connect when set first time #1189

Closed
opened 2026-02-28 01:28:55 +03:00 by kerem · 19 comments
Owner

Originally created by @0x0fe on GitHub (Apr 8, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1388

In non blocking mode, with a timeout (15*60) the AP is shut down right after STA connection succeed, after the wifi password has been set.
This bug does not occur on subsequent boot (so, when the password is already saved).

Originally created by @0x0fe on GitHub (Apr 8, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1388 In non blocking mode, with a timeout (15*60) the AP is shut down right after STA connection succeed, after the wifi password has been set. This bug does not occur on subsequent boot (so, when the password is already saved).
kerem closed this issue 2026-02-28 01:28:56 +03:00
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

What bug? What is the expected behavior?

non blocking doesn't mean always on, if you are using autoconnect that is the expected behavior.

<!-- gh-comment-id:1093519538 --> @tablatronix commented on GitHub (Apr 9, 2022): What bug? What is the expected behavior? non blocking doesn't mean always on, if you are using autoconnect that is the expected behavior.
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

When non blocking and timeout are set the portal keeps running after connect, except at first time when you set the password, i am not sure ifs its a bug or a feature, but i feel should be consistent, either stop portal after connect or leave it open, regardless if its the first time you set the password or not, no?
I also notice something very strange, when adding a custom label it works fine at first time when we set password, however the datas are corrupted for any subsequent access to the portal (within the same sessions at least).

char devId[16];
WiFiManagerParameter custom_field(devId); 

void captive_portal_init(void) {
  sprintf(devId,"<p>Device UUID %s</p>",getUUID().c_str());
  wm.addParameter(&custom_field);
  wm.setConfigPortalBlocking(false);
  wm.setConfigPortalTimeout(60*15);
  //wm.resetSettings();
  if(wm.autoConnect("FillLand Smart Parasol")){msg("WIFI link up\n");}
  else{msg("portal active\n");}
  wm.startConfigPortal("FillLand Smart Parasol");
  //while(WiFi.status()!=WL_CONNECTED) wm.process();
}
<!-- gh-comment-id:1093523229 --> @0x0fe commented on GitHub (Apr 9, 2022): When non blocking and timeout are set the portal keeps running after connect, except at first time when you set the password, i am not sure ifs its a bug or a feature, but i feel should be consistent, either stop portal after connect or leave it open, regardless if its the first time you set the password or not, no? I also notice something very strange, when adding a custom label it works fine at first time when we set password, however the datas are corrupted for any subsequent access to the portal (within the same sessions at least). ```c++ char devId[16]; WiFiManagerParameter custom_field(devId); void captive_portal_init(void) { sprintf(devId,"<p>Device UUID %s</p>",getUUID().c_str()); wm.addParameter(&custom_field); wm.setConfigPortalBlocking(false); wm.setConfigPortalTimeout(60*15); //wm.resetSettings(); if(wm.autoConnect("FillLand Smart Parasol")){msg("WIFI link up\n");} else{msg("portal active\n");} wm.startConfigPortal("FillLand Smart Parasol"); //while(WiFi.status()!=WL_CONNECTED) wm.process(); } ```
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

The portal should NOT keep running after connect, the portal should never run unless no wifi or you ask it too.

What is the code? Which example are you using , i can test

<!-- gh-comment-id:1093524237 --> @tablatronix commented on GitHub (Apr 9, 2022): The portal should NOT keep running after connect, the portal should never run unless no wifi or you ask it too. What is the code? Which example are you using , i can test
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

You are calling wm.startConfigPortal("FillLand Smart Parasol");

ok so I see, which version you running?

<!-- gh-comment-id:1093526127 --> @tablatronix commented on GitHub (Apr 9, 2022): You are calling wm.startConfigPortal("FillLand Smart Parasol"); ok so I see, which version you running?
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

last version from manager. I think i know the problem : char devId[16]; this buffer was initially used for the UUID only, its too small for the HTML tags, shame on me

<!-- gh-comment-id:1093527018 --> @0x0fe commented on GitHub (Apr 9, 2022): last version from manager. I think i know the problem : char devId[16]; this buffer was initially used for the UUID only, its too small for the HTML tags, shame on me
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

yeah that shouds like a memory issue ( also length)

are you calling wm.process(); in loop?

<!-- gh-comment-id:1093527560 --> @tablatronix commented on GitHub (Apr 9, 2022): yeah that shouds like a memory issue ( also length) are you calling wm.process(); in loop?
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

yes, the application is a free running state machine. By the way is there a define or call to avoid closing the AP after connect?

<!-- gh-comment-id:1093528121 --> @0x0fe commented on GitHub (Apr 9, 2022): yes, the application is a free running state machine. By the way is there a define or call to avoid closing the AP after connect?
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

The process of connecting turns off the softap by design, as sta connections cannot be made with it on

<!-- gh-comment-id:1093532406 --> @tablatronix commented on GitHub (Apr 9, 2022): The process of connecting turns off the softap by design, as sta connections cannot be made with it on
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

ESP32C has AP-STA mode, with hardware handling of both, how comes it is a softAP?

<!-- gh-comment-id:1093533663 --> @0x0fe commented on GitHub (Apr 9, 2022): ESP32C has AP-STA mode, with hardware handling of both, how comes it is a softAP?
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

Also there was some changed to the code recently to non blocking timeouts, it might only be in git

sta+ap mode can only operate on the same channel, so trying to connect to an ssid on another channel than the softap is already on cause instability and errors

<!-- gh-comment-id:1093533779 --> @tablatronix commented on GitHub (Apr 9, 2022): Also there was some changed to the code recently to non blocking timeouts, it might only be in git sta+ap mode can only operate on the same channel, so trying to connect to an ssid on another channel than the softap is already on cause instability and errors
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

i recall now, ok i will pull from the master branch, thank you for all the clarifications

<!-- gh-comment-id:1093537523 --> @0x0fe commented on GitHub (Apr 9, 2022): i recall now, ok i will pull from the master branch, thank you for all the clarifications
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

If you really want softap+sta you can do it, let me see , the best is probably to startap after sta is connected.

I might have some code in there to play with this


    bool          _disableSTA             = false; // disable sta when starting ap, always
    bool          _disableSTAConn         = true;  // disable sta when starting ap, if sta is not connected ( stability )

 // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond
  // @todo sometimes still cannot connect to AP for no known reason, no events in log either
  if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){

<!-- gh-comment-id:1093537694 --> @tablatronix commented on GitHub (Apr 9, 2022): If you really want softap+sta you can do it, let me see , the best is probably to startap after sta is connected. I might have some code in there to play with this ```c++ bool _disableSTA = false; // disable sta when starting ap, always bool _disableSTAConn = true; // disable sta when starting ap, if sta is not connected ( stability ) // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond // @todo sometimes still cannot connect to AP for no known reason, no events in log either if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){ ```
Author
Owner

@0x0fe commented on GitHub (Apr 9, 2022):

nice, that is convenient

<!-- gh-comment-id:1093539025 --> @0x0fe commented on GitHub (Apr 9, 2022): nice, that is convenient
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

So I am thinking it should be working like that already, let me check and see

<!-- gh-comment-id:1093539920 --> @tablatronix commented on GitHub (Apr 9, 2022): So I am thinking it should be working like that already, let me check and see
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

Mine seems to work,
Serial.println(wm.getModeString(WiFi.getMode()));

But for saving a new connection, we always turn off softap, let me see if I added a test for that to play with, I know i did at some point

<!-- gh-comment-id:1093543256 --> @tablatronix commented on GitHub (Apr 9, 2022): Mine seems to work, ` Serial.println(wm.getModeString(WiFi.getMode()));` But for saving a new connection, we always turn off softap, let me see if I added a test for that to play with, I know i did at some point
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

remove this line

WiFi_Mode(_usermode); // restore users wifi mode, BUG https://github.com/esp8266/Arduino/issues/4372

But that wont keep the portal open let me check one more thing

<!-- gh-comment-id:1093554728 --> @tablatronix commented on GitHub (Apr 9, 2022): remove this line ` WiFi_Mode(_usermode); // restore users wifi mode, BUG https://github.com/esp8266/Arduino/issues/4372` But that wont keep the portal open let me check one more thing
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

ok if you remove

in processConfigportal
shutdownConfigPortal(); it will keep running even on saves

Ill see how to make this a toggle, it seems to work OK, depends on your wifi environment.

I will eventually test this fully when I add wifi save status to the webpage, in the past the SDK has been very buggy in dual modes especially on esp8266

<!-- gh-comment-id:1093563244 --> @tablatronix commented on GitHub (Apr 9, 2022): ok if you remove in processConfigportal shutdownConfigPortal(); it will keep running even on saves Ill see how to make this a toggle, it seems to work OK, depends on your wifi environment. I will eventually test this fully when I add wifi save status to the webpage, in the past the SDK has been very buggy in dual modes especially on esp8266
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

also if you are gonna run the cp portal always, no reason to start it in autoconnect

// if true (default) then start the config portal from autoConnect if connection failed void setEnableConfigPortal(boolean enable);

<!-- gh-comment-id:1093564590 --> @tablatronix commented on GitHub (Apr 9, 2022): also if you are gonna run the cp portal always, no reason to start it in autoconnect ` // if true (default) then start the config portal from autoConnect if connection failed void setEnableConfigPortal(boolean enable); `
Author
Owner

@tablatronix commented on GitHub (Apr 9, 2022):

7bffda3fe6

    // if true (default) then stop the config portal from autoConnect when wifi is saved
    void          setDisableConfigPortal(boolean enable);

wm.setDisableConfigPortal(false);

I will probably change name by release, as it is confusing, just made to match the other one

good enough to test

<!-- gh-comment-id:1093572363 --> @tablatronix commented on GitHub (Apr 9, 2022): 7bffda3fe67ae7d4cb567fbc6bfa7d4322871d29 ```c++ // if true (default) then stop the config portal from autoConnect when wifi is saved void setDisableConfigPortal(boolean enable); ``` ` wm.setDisableConfigPortal(false);` I will probably change name by release, as it is confusing, just made to match the other one good enough to test
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#1189
No description provided.