Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifi reconnect doesn't seem to work on ESP32 multithread environment #1281

Open
TLS1000 opened this issue Aug 20, 2021 · 0 comments
Open

wifi reconnect doesn't seem to work on ESP32 multithread environment #1281

TLS1000 opened this issue Aug 20, 2021 · 0 comments
Labels
Needs Feeback Developer needs feedback QA Quality Assurance testing needed Question User Question member to member support

Comments

@TLS1000
Copy link

TLS1000 commented Aug 20, 2021

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: ESP32

Core Version: 2.4.0, staging

Description

Problem description
Hi, I'm using your great library in a number of ESP32 devices and they lose wifi connection; sometimes after a few days, sometimes after just a few minutes. the code is multithread, the 'loop' section is empty. It seems that the reconnect-mechanism is not successful. The problem can be avoided by manually adding a reconnect routine in the 'loop' section:

void loop() {
  if ((WiFi.status() != WL_CONNECTED) ) {
  Serial.print(millis());
  Serial.println("Reconnecting to WiFi...");
  WiFi.disconnect();
  WiFi.reconnect();
}
delay(2000);
}

The setup is:

WiFiManager wm;
void setup() {
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  //WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE); // required to set hostname properly
  //WiFi.setHostname("LF2battery");
  //WiFiManager wm;
    //wm.resetSettings();  //reset settings - wipe credentials for testing
    // Automatically connect using saved credentials,
    // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
    // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
    // then goes into a blocking loop awaiting configuration and will return success result
    bool res;
    // res = wm.autoConnect(); // auto generated AP name from chipid
    // res = wm.autoConnect("AutoConnectAP"); // anonymous ap
    
    //wm.setConfigPortalBlocking(false);
    wm.setHostname("myHost");
    wm.setCleanConnect(true);
    wm.setTimeout(3);
    wm.setConnectRetries(10);
    res = wm.autoConnect("myAP","password"); // password protected ap
    if(!res) {
        Serial.println("Failed to connect");
        // ESP.restart();
    } 
    else {
        //if you get here you have connected to the WiFi    
        Serial.println("connected...yeey :)");
        myIP=WiFi.localIP();
    }
}

Settings in IDE

Module: doitV1

Additional libraries: pubsubclient, ESPmDNS,

Is there a way to let the reconnect be handled correctly by the library? thank you

@tablatronix tablatronix added Needs Feeback Developer needs feedback QA Quality Assurance testing needed Question User Question member to member support labels Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Feeback Developer needs feedback QA Quality Assurance testing needed Question User Question member to member support
Projects
None yet
Development

No branches or pull requests

2 participants