esp8266 / esp8266/Arduino

[BUG]: No Return of status `WRONG_PASSWORD` during WiFi Connect

Open
#8,233 17 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [x] I have tested that the issue is present in current master branch (aka latest git).
- [x] I have searched the issue tracker for a similar issue.
- [ ] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.

#### Platform

- Hardware: [ESP-12]
- Core Version: [latest git hash or date]
- Development Env: [Arduino IDE]
- Operating System: [Windows|]

### Settings in IDE

- Module: [Wemos D1 mini]
- Flash Mode: []
- Flash Size: [4MB]
- lwip Variant: []
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|]
- Upload Using: [SERIAL]
- Upload Speed: [115200)

### Problem Description

When try to provoke the return off info `WL_WRONG_PASSWORD` this does not happen.
sketch is provided.

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```ruby
#include
#include
#include "wifi_secrets.h"

constexpr int LED {5};

wl_status_t get_wifi_status(void) {
// keep in mind
/*
WL_NO_SHIELD = 255, // for compatibility with WiFi Shield library
WL_IDLE_STATUS = 0,
WL_NO_SSID_AVAIL = 1,
WL_SCAN_COMPLETED = 2,
WL_CONNECTED = 3,
WL_CONNECT_FAILED = 4,
WL_CONNECTION_LOST = 5,
WL_WRONG_PASSWORD = 6,
WL_DISCONNECTED = 7
*/
wl_status_t status = WiFi.status();
if (status == WL_NO_SHIELD) {
Serial.println(F("\n WiFI.status == NO_SHIELD"));
}
else if (status == WL_IDLE_STATUS) {
Serial.println(F("\n WiFI.status == IDLE_STATUS"));
}
else if (status == WL_NO_SSID_AVAIL) {
Serial.println(F("\n WiFI.status == NO_SSID_AVAIL"));
}
else if (status == WL_SCAN_COMPLETED) {
Serial.println(F("\n WiFI.status == SCAN_COMPLETED"));
}
else if (status == WL_CONNECTED) {
Serial.println(F("\n WiFI.status == CONNECTED"));
}
else if (status == WL_CONNECT_FAILED) {
Serial.println(F("\n WiFI.status == CONNECT_FAILED"));
}
else if (status == WL_CONNECTION_LOST) {
Serial.println(F("\n WiFI.status == CONNECTION_LOST"));
}
else if (status == WL_WRONG_PASSWORD) {
Serial.println(F("\n WiFI.status == WRONG_PASSWORD"));
}
else if (status == WL_DISCONNECTED) {
Serial.println(F("\n WiFI.status == DISCONNECTED"));
}
else {
Serial.println(F("\n No appropriate Status available!"));
}
return status;
}

bool wifi_connect(const char *_SSID, const char * _PASSWORD, const char *_hostname = nullptr){
Serial.printf("Set WiFi mode to WIFI_STA - %d\n", WiFi.mode(WIFI_STA));
if (_hostname != nullptr) WiFi.hostname(_hostname);
// Warte auf Verbindung
WiFi.begin(_SSID, "test");
while (WiFi.status() != WL_CONNECTED) {
// Status function from API
uint8_t status_API = wifi_station_get_connect_status();
Serial.printf(" 1 - Wifi status API:\t%d\n", status_API);

// Status from Arduino core
wl_status_t status_CORE = WiFi.status();
Serial.printf(" 2 - Wifi status core:\t%d\n", status_CORE);

Serial.printf(" 3 - Wifi status:\t%d\n", get_wifi_status());

if ((status_API == STATION_WRONG_PASSWORD) || (status_CORE == WL_WRONG_PASSWORD)){
return true;
}
delayMicroseconds(100);
}
return true;
}
/*
* if (WiFi.waitForConnectResult() == WL_CONNECTED) {
Serial.printf(" Wifi status: %d\n", get_wifi_status());
Serial.println("\n Connection - success! <<<");
return true;
}
else {
Serial.printf(" Wifi status: %d\n", WiFi.status());
Serial.printf(" Wifi status: %d\n", get_wifi_status());
Serial.println("\n Connection - failed! <<<");
return false;
}
}
*/

void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
while (!Serial) yield();
Serial.print("\n\n");
WiFi.printDiag(Serial);
//WiFi.setAutoReconnect(false);
WiFi.setAutoConnect(false);
WiFi.persistent(false);

time_t tic {millis()};
digitalWrite(LED, HIGH);
if (wifi_connect(SSID, PASSWORD)) {
Serial.printf("time until connect: %0.3f s\n", (millis() - tic)/1000.0);
WiFi.disconnect();
digitalWrite(LED, LOW);
delay(1000);
}
}

void loop() {
// put your main code here, to run repeatedly:

}
```

### Debug Messages

```
Debug messages go here
```

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.