[GH-ISSUE #1034] Switched to Dev Branch and Wifi disconnects immediately after #880

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

Originally created by @jbronikowski on GitHub (Apr 9, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1034

Hello,

Trying to understand the new logic in the Dev branch. I recently switched over from the master to the dev branch and when i run it, the ESP gets an IP right away but then disconnect configportal and disconnects wifi. Any insight would be greatly appreciated. This works fine on Master

09:49:52.973 -> *WM: [2] <- HTTP WiFi save  
09:49:52.973 -> *WM: [3] Method: POST
09:49:52.973 -> *WM: [3] Sent wifi save page 
09:49:52.973 -> *WM: [2] processing save 
09:49:54.992 -> *WM: [2] Connecting as wifi client... 
09:49:54.992 -> *WM: [3] STA static IP:
09:49:54.992 -> *WM: [2] setSTAConfig static ip not set, skipping 
09:49:54.992 -> *WM: [1] CONNECTED:
09:49:54.992 -> *WM: [1] Connecting to NEW AP: YoshRen
09:49:54.992 -> *WM: [3] Using Password: aspentrevor
09:49:54.992 -> *WM: [3] WiFi station enable 
09:49:54.992 -> *WM: [3] enableSTA PERSISTENT ON 
09:49:55.181 -> *WM: [1] connectTimeout not set, ESP waitForConnectResult... 
09:50:00.752 -> *WM: [2] Connection result: WL_CONNECTED
09:50:00.752 -> *WM: [3] lastconxresult: WL_CONNECTED
09:50:00.752 -> *WM: [1] Connect to new AP [SUCCESS] 
09:50:00.752 -> *WM: [1] Got IP Address: 
09:50:00.752 -> *WM: [1] 10.10.100.109 
09:50:00.752 -> Should save config
09:50:00.752 -> *WM: [2] disconnect configportal 
09:50:01.750 -> *WM: [2] restoring usermode AP
09:50:01.750 -> *WM: [2] wifi status: WL_DISCONNECTED
09:50:01.750 -> *WM: [2] wifi mode: AP
09:50:01.750 -> *WM: [1] config portal exiting 
09:50:01.750 -> connected...yeey :)
09:50:01.750 -> local ip
09:50:01.750 -> (IP unset)
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println();

  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;

  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);

  //exit after config instead of connecting
  wifiManager.setBreakAfterConfig(true);


  //reset settings - for testing
  wifiManager.resetSettings();

  
  //tries to connect to last known settings
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP" with password "password"
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
    Serial.println("failed to connect, we should reset as see if it connects");
    delay(3000);
    ESP.reset();
    delay(5000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  //read updated parameters

  Serial.println("local ip");
  Serial.println(WiFi.localIP());
}
void loop() {
  // wait for WiFi connection
  if ((WiFi.localIP())) {

    Serial.println("===============");
    Serial.println(apikey);
    Serial.println(email);

    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);

    client->setFingerprint(fingerprint);

    HTTPClient https;
Originally created by @jbronikowski on GitHub (Apr 9, 2020). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1034 Hello, Trying to understand the new logic in the Dev branch. I recently switched over from the master to the dev branch and when i run it, the ESP gets an IP right away but then disconnect configportal and disconnects wifi. Any insight would be greatly appreciated. This works fine on Master ```PHP 09:49:52.973 -> *WM: [2] <- HTTP WiFi save 09:49:52.973 -> *WM: [3] Method: POST 09:49:52.973 -> *WM: [3] Sent wifi save page 09:49:52.973 -> *WM: [2] processing save 09:49:54.992 -> *WM: [2] Connecting as wifi client... 09:49:54.992 -> *WM: [3] STA static IP: 09:49:54.992 -> *WM: [2] setSTAConfig static ip not set, skipping 09:49:54.992 -> *WM: [1] CONNECTED: 09:49:54.992 -> *WM: [1] Connecting to NEW AP: YoshRen 09:49:54.992 -> *WM: [3] Using Password: aspentrevor 09:49:54.992 -> *WM: [3] WiFi station enable 09:49:54.992 -> *WM: [3] enableSTA PERSISTENT ON 09:49:55.181 -> *WM: [1] connectTimeout not set, ESP waitForConnectResult... 09:50:00.752 -> *WM: [2] Connection result: WL_CONNECTED 09:50:00.752 -> *WM: [3] lastconxresult: WL_CONNECTED 09:50:00.752 -> *WM: [1] Connect to new AP [SUCCESS] 09:50:00.752 -> *WM: [1] Got IP Address: 09:50:00.752 -> *WM: [1] 10.10.100.109 09:50:00.752 -> Should save config 09:50:00.752 -> *WM: [2] disconnect configportal 09:50:01.750 -> *WM: [2] restoring usermode AP 09:50:01.750 -> *WM: [2] wifi status: WL_DISCONNECTED 09:50:01.750 -> *WM: [2] wifi mode: AP 09:50:01.750 -> *WM: [1] config portal exiting 09:50:01.750 -> connected...yeey :) 09:50:01.750 -> local ip 09:50:01.750 -> (IP unset) ``` ```C++ bool shouldSaveConfig = false; //callback notifying us of the need to save config void saveConfigCallback () { Serial.println("Should save config"); shouldSaveConfig = true; } void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.println(); // The extra parameters to be configured (can be either global or just in the setup) // After connecting, parameter.getValue() will get you the configured value // id/name placeholder/prompt default length //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around WiFiManager wifiManager; //set config save notify callback wifiManager.setSaveConfigCallback(saveConfigCallback); //exit after config instead of connecting wifiManager.setBreakAfterConfig(true); //reset settings - for testing wifiManager.resetSettings(); //tries to connect to last known settings //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" with password "password" //and goes into a blocking loop awaiting configuration if (!wifiManager.autoConnect("AutoConnectAP", "password")) { Serial.println("failed to connect, we should reset as see if it connects"); delay(3000); ESP.reset(); delay(5000); } //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); //read updated parameters Serial.println("local ip"); Serial.println(WiFi.localIP()); } void loop() { // wait for WiFi connection if ((WiFi.localIP())) { Serial.println("==============="); Serial.println(apikey); Serial.println(email); std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure); client->setFingerprint(fingerprint); HTTPClient https; ```
kerem 2026-02-28 01:27:28 +03:00
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2020):

Dev branch now preserves your user code esp modes, so it puts them back when its done.

You do not have wifi sta mode set.
Autoconnect, will force it on.
Your code should set esp mode WiFi.mode(); on its own.

cp save does not, I am going to change the default and add a getter, cause I get too many issues about it. Consider it "fixed" in 5 minutes.

"09:50:01.750 -> *WM: [2] restoring usermode AP
09:50:01.750 -> *WM: [2] wifi status: WL_DISCONNECTED
09:50:01.750 -> *WM: [2] wifi mode: AP
<!-- gh-comment-id:612066401 --> @tablatronix commented on GitHub (Apr 10, 2020): Dev branch now preserves your user code esp modes, so it puts them back when its done. You do not have wifi sta mode set. Autoconnect, will force it on. Your code should set esp mode WiFi.mode(); on its own. cp save does not, I am going to change the default and add a getter, cause I get too many issues about it. Consider it "fixed" in 5 minutes. ``` "09:50:01.750 -> *WM: [2] restoring usermode AP 09:50:01.750 -> *WM: [2] wifi status: WL_DISCONNECTED 09:50:01.750 -> *WM: [2] wifi mode: AP ```
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2020):

It also preseves persistent, so user can go back to exactly the same wifi modes as before running wm, but since this is drastically different than previous versions ( which are bugged! in this )

<!-- gh-comment-id:612068122 --> @tablatronix commented on GitHub (Apr 10, 2020): It also preseves persistent, so user can go back to exactly the same wifi modes as before running wm, but since this is drastically different than previous versions ( which are bugged! in this )
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2020):

e9d75a08b8

<!-- gh-comment-id:612069851 --> @tablatronix commented on GitHub (Apr 10, 2020): e9d75a08b8ad59508a70441fad1cbba90ec0dcaf
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2020):

I changed it to force sta mode after using wm now, it will prevent these complaints or confusion but will also turn off ap mode if you are using it, so yo have to turn it back on in that case. Should help for now and prevent these issues or questions.

<!-- gh-comment-id:612070336 --> @tablatronix commented on GitHub (Apr 10, 2020): I changed it to force sta mode after using wm now, it will prevent these complaints or confusion but will also turn off ap mode if you are using it, so yo have to turn it back on in that case. Should help for now and prevent these issues or questions.
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#880
No description provided.