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

WifiMulti.run not connecting to declared APs which don't broadcast SSID #2246

Closed
SteveToulouse opened this issue Jul 7, 2016 · 16 comments
Closed
Labels

Comments

@SteveToulouse
Copy link
Contributor

SteveToulouse commented Jul 7, 2016

Basic Infos

Hardware

Hardware: NodeMCU 1.0 Amica ESP-12E
Core Version: 2.3.0 github latest edited
IDE Arduino: 1.6.9 edited

Description

The nearest AP at my workplace (2 metres away) doesn't broadcast its SSID (checked by WiFiScan example sketch) but the NodeMCU connects perfectly well with a simple WiFi.begin("WorkAP1","passphrase0") (tested on NTPClient example sketch).

When I added it to a test sketch (see also #2117, 2115) by addAP, no connection occurs, no errors either. The AP is simply "not there" as far as WiFiMulti is concerned, even though I told it that it exists.

The problem seems to be that it is looping through the visible (by scan) networks to see if they are in the addAP'ed list and, among those which are, to pick the strongest. It should probably be looping through the addAP'ed APs to get their strengths and connect to the strongest one. I don't know how to acheive this for "hidden" SSIDs though.

NOTE: Work environment is densly populated with APs (16 APs at -74..-93dB) but I don't believe this is an issue.

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

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti wifiMulti;

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

  wifiMulti.addAP("WorkAP1", "passphrase0"); // Work *fibre* gateway router no. 1
  wifiMulti.addAP("Stevebox", "passphrase1"); // my home ADSL gateway router
  wifiMulti.addAP("AndroidAP", "passphrase2"); // my android phone
  wifiMulti.addAP("SteveAP", "passphrase3"); // my secondary home 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

scandone
f r0, scandone
>>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
f r0, scandone
>>WiFi not connected! run returned: 1

...etc. etc. etc.
@sharkwheels
Copy link

Was this ever updated to include non broadcasting APs?

@Solice55
Copy link

I can confirm. I also noted something odd. The behavior seems to be that it will not connect to a hidden wifi SSID. However, if I upload a sketch (like WiFiClient example) to the same ESP8266 device that uses just ESP8266WiFi.h and WiFi.begin(), it will connect. If I then upload the original sketch (like BasicHttpClient) that uses WiFiMulti, it connects. I have confirmed this behavior on every new ESP8266 device (2x NodeMCU and 2x WeMos D1 Mini) that I introduce to my wireless network. Thereafter, they seem to connect just fine with WiFiMulti.

Can anyone else confirm?

@cjbaar
Copy link

cjbaar commented Jan 27, 2017

That method does not work for me. WiFi will connect to a hidden SSID, but WiFiMulti will not, even after successful test with WiFi only. I think Steve is right about the scanning feature of WiFiMulti; it continues to return WL_NO_SSID_AVAIL.

@Fibula1
Copy link

Fibula1 commented Oct 7, 2017

What's the chances of this bug ever gettng repaired :) I do workarounds and use a combination of WifiMulti and normal WiFi.begin. It would be really handy to just be able to add the hidden SSIDs to WifiMulti.

@devyte
Copy link
Collaborator

devyte commented Oct 15, 2017

@SteveToulouse @Fibula1
Please try #3215 . I believe there are fixes for hidden beacons in sdk 2.1.0.
Please report back here.

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 15, 2017
@adavidzh
Copy link

adavidzh commented May 2, 2018

I have just stumbled upon this and I'm running

SDK:2.2.1(cfd48f3)/Core:2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)

This looks like a Multi-specific issue.

@sezeryalcin
Copy link

Will there be a fix for this?

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 19, 2019

@sezeryalcin
Can you try and modify the always-used-as-default parameter show_hidden = false to true,
and report whether WiFiMulti works with hidden APs ?

@d-a-v d-a-v added this to the 2.7.0 milestone Dec 19, 2019
@sezeryalcin
Copy link

I do an async scan before getting to wifimulti

WiFi.scanNetworks(true, true); // Async and show hidden
Bu still ESP8266WiFiMulti does not connect to hidden networks.
This is 2.5.2 Arduino core.

@sezeryalcin
Copy link

sezeryalcin commented Dec 19, 2019

Code itself does not scan hidden APs.:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp#L72

I or someone can try changing it but I didn't check if underlying mechanism will support hidden APs.

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 19, 2019

That's what I ask to you (and I don't know if you tried).
Can you please change the (true) to (true, true) or try my proposal above in your local copy and report back ?

@sezeryalcin
Copy link

Ok, I will try now

@sezeryalcin
Copy link

It did not work by just changing to scan hidden. Here it's doing processing by ssid and in this case there is none:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp#L100

It's really surprising that hidden networks were not considered while doing wifimulti.It needs a detailed look without breaking existing functionality.

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 24, 2020

@sezeryalcin This request is now pushed to 3.0.0.
A day will come when maintainers propose a fix,
or luckily a fix from you before that day, or from someone else feeling brave :)

@d-a-v d-a-v removed the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Feb 24, 2020
@d-a-v d-a-v modified the milestones: 2.7.0, 3.0.0 Feb 24, 2020
@d-a-v d-a-v added the help wanted Help needed from the community label Feb 24, 2020
@Erriez
Copy link
Contributor

Erriez commented Oct 3, 2020

I've redesigned the implementation of the ESP8266WiFiMulti library. I've added support for hidden SSID's in PR: #7629.

@d-a-v d-a-v modified the milestones: 3.0.0, 3.0.1 Mar 31, 2021
@d-a-v d-a-v modified the milestones: 3.0.1, 3.1 Jun 16, 2021
@d-a-v
Copy link
Collaborator

d-a-v commented Jun 11, 2022

Already solved by #7629

@d-a-v d-a-v closed this as completed Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests