Skip to content

WiFi Multi library endless connect loops and missing scan timeout handling #7620

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

Closed
5 of 6 tasks
Erriez opened this issue Sep 30, 2020 · 1 comment
Closed
5 of 6 tasks

Comments

@Erriez
Copy link
Contributor

Erriez commented Sep 30, 2020

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP8266]
  • Core Version: [master]
  • Development Env: [N.A.]
  • Operating System: [N.A.]

Settings in IDE

N.A.

Problem Description

  1. A missing WiFi scan completed results in endless connect loops

  2. The WiFiMulti example does not connect to other registered networks on WiFi connection failure such as incorrect password.

Sketch

#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti wifiMulti;

void setup() 
{
    Serial.begin(115200);
  
    WiFi.mode(WIFI_STA);
    wifiMulti.addAP("MySSID1", "wrong_password");
    wifiMulti.addAP("MySSID2", "correct_password");
  
    Serial.println("Connecting Wifi...");
    if (wifiMulti.run() == WL_CONNECTED) {
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
    }
}

void loop() 
{
    if (wifiMulti.run() != WL_CONNECTED) {
        Serial.println("WiFi not connected!");
        delay(1000);
    }
}

Debug Messages

[WIFI] Connecting BSSID: XX:XX:XX:XX:XX:XX SSID: MySSID1 Channel: 11 (-72)
[WIFI] Connecting Failed (6).
WiFi not connected!
[WIFI] delete old wifi config...
[WIFI] start scan
WiFi not connected!
WiFi not connected!
WiFi not connected!
[WIFI] scan done
[WIFI] 8 networks found
 --->  0: [1][XX:XX:XX:XX:XX:XX] MySSID2 (-80) *
       1: [1][XX:XX:XX:XX:XX:XX] XXXXXXXXXXX (-90) *
       2: [1][XX:XX:XX:XX:XX:XX] XXXXXXXXX (-89) *
       3: [1][XX:XX:XX:XX:XX:XX] XXXXXXXXXXX (-90) *
 --->  4: [11][XX:XX:XX:XX:XX:XX] MySSID1 (-70) *
       5: [3][XX:XX:XX:XX:XX:XX] XXXXXXXXXXX (-85) *
       6: [11][XX:XX:XX:XX:XX:XX] XXXXXX (-70) *
       7: [11][XX:XX:XX:XX:XX:XX] XXXXXXXXX (-94) *


[WIFI] Connecting BSSID: XX:XX:XX:XX:XX:XX SSID: MySSID1 Channel: 11 (-70)
[WIFI] Connecting Failed (6).
WiFi not connected!
[WIFI] delete old wifi config...
[WIFI] start scan

I've redesigned the complete library and created a pull request:

#7619

Fixed critical issues WiFiMulti library:

  • WiFi scan timeout implemented to prevent endless connect loop
  • Fallback implemented on WiFi connect failure to prevent endless loop
  • Fast WiFi connection at startup
  • Improved debug prints
  • Doxygen added
  • Code maturing
  • Example update

The API is identical.

@esp8266 esp8266 deleted a comment from MonishMathew Oct 1, 2020
@Erriez
Copy link
Contributor Author

Erriez commented Oct 3, 2020

Resolved in pull request #7619.

@Erriez Erriez closed this as completed Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant