esp8266 / esp8266/Arduino

wifiMulti - undesirable behaviour when "best" AP not connectable

Open
#2,117 0 comments 0 reactions 0 assignees View on GitHub
component: libraries type: bug
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos
#### Hardware

Hardware: NodeMCU 1.0 Amica ESP-12E
Core Version: 2.2.0
IDE Arduino: 1.6.8
### Description

While testing how `wifiMulti` handles choice of AP I took the NodeMCU close to my secondary access point. The SSID of this AP was in the list added by `addAP`, but the passphrase had changed since uploading the sketch to the NodeMCU. Naturally, no connexion occurred (other devices were able to connect to the AP by using the correct passphrase).

However, I think it's unfortunate that `wifiMulti.run` refuses to quit trying to connect to this AP, despite the availability of other, working APs on it's list (by moving back closer to my primary AP, it connected fine). Maybe I didn't wait long enough (over 2 minutes) ?

This may be a design feature but I can't immediately figure why this might be desirable behaviour.

Secondary observation: highest strength, unprotected APs seem to be ignored if they aren't explicitly added by `addAP`. This too seems unfortunate.
EDIT: I can understand that an "open" AP could cause problems if it requires a further http dialogue to establish connectivity, but then it becomes the same case as an AP with a bad passphrase (or MAC filtering).
### Settings in IDE

Module: NodeMCU 1.0 (ESP-12E Module)
Flash Size: 4M (3M SPIFFS)
CPU Frequency: 80Mhz
Flash Mode: n/a
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: n/a
### Sketch

``` cpp
#include
#include
#include

ESP8266WiFiMulti wifiMulti;

void setup() {
Serial.begin(115200);
delay(10);
Serial.setDebugOutput(true);

wifiMulti.addAP("Stevebox", "passphrase1"); // my ADSL gateway router
wifiMulti.addAP("AndroidAP", "passphrase2"); // my android phone
wifiMulti.addAP("SteveAP", "passphrase3"); // my secondary wifi router, with bad passphrase
wifiMulti.addAP("FreeWifi"); // a neighbour's ADSL gateway router with public AP
}

void loop() {
Serial.println();
if (int stat = wifiMulti.run() != WL_CONNECTED) {
Serial.print("WiFi not connected! run returned: ");
Serial.println(stat);
}

WiFi.printDiag(Serial);
delay(5000);
}
```
### Debug Messages

```
f r0, scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
f -180, scandone
no SteveAP found, reconnect after 1s
WiFi not connected! run returned: 1
Mode: STA
PHY mode: N
Channel: 6
AP id: 0
Status: 3
Auto connect: 1
SSID (7): SteveAP
Passphrase (11): passphrase3
BSSID set: 1
reconnect
f r0, scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
f -180, scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
f r0,
scandone
f r0, WiFi not connected! run returned: 1
Mode: STA
PHY mode: N
Channel: 1
AP id: 0
Status: 0
Auto connect: 1
SSID (0):
Passphrase (0):
BSSID set: 0

...etc. etc. etc.
```
##

Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34954146-wifimulti-undesirable-behaviour-when-best-ap-not-connectable?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.