Open hasenradball opened 3 years ago
See the following shot for example...
15 min until the ESP raises WRONG_PASSWORD
Does it have different results replacing
- WiFi.setAutoConnect(false);
+ WiFi.setAutoConnect(true);
? (maybe also reconnect)
edit: is this related to the https://github.com/esp8266/Arduino/issues/7432?
I will try
Does it have different results replacing
- WiFi.setAutoConnect(false); + WiFi.setAutoConnect(true);
? (maybe also reconnect)
edit: is this related to the #7432?
see also this Note:
With the setting WiFi.setAutoConnect(true);
no positive changes --> after nearly 60 min detection of WRONG_PASSWORD
.
So is this Emum not usable.
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 1
2 - Wifi status core: 7
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 1
2 - Wifi status core: 6
WiFI.status == WRONG_PASSWORD
3 - Wifi status: 6
time until connect: 3498.974 s
With the setting WiFi.setAutoReConnect(true);
no positive changes --> after nearly 60 min detection of WRONG_PASSWORD.
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 1
2 - Wifi status core: 7
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 1
2 - Wifi status core: 7
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 1
2 - Wifi status core: 7
WiFI.status == DISCONNECTED
3 - Wifi status: 7
1 - Wifi status API: 2
2 - Wifi status core: 6
WiFI.status == WRONG_PASSWORD
3 - Wifi status: 6
time until connect: 3522.949 s
looking at the event handler, it does not see the invalid psk reason as well
int reason{0};
// insert this in the connect-check loop
void dump_reason() {
if (reason > 0) {
int copy{reason};
reason = 0;
Serial.printf(" 4 - WiFi disconnect event: %d\n", copy);
}
}
void setup() {
static auto disconnected = WiFi.onStationModeDisconnected([](const auto& event) {
reason = event.reason;
});
... the rest ...
}
4 - WiFi disconnect event: 2
while on the ap box, hostapd logs psk mismatch
hostapd: wlan1-1: AP-STA-POSSIBLE-PSK-MISMATCH xx:xx:xx:xx:xx:xx
also note the invalid psk test should be at least 8bytes long i.e. something like testtest
Do I have it implemented Correctly?
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, "testtest");
while (WiFi.status() != WL_CONNECTED) {
dump_reason();
// 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;
}
void setup() {
static auto disconnected = WiFi.onStationModeDisconnected([](const auto& event) {
reason = event.reason;
});
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);
}
}
@mcspr your event will not be print in my code, maybee I implemented it wrong?
the reason seems to be always 0
as I modified it to run - https://gist.github.com/mcspr/c7b40fea7dd1323c11ad45b08103b979 different led and wifi_connect func receives the actual real SSID and invalid PASSWORD ("testtesttest")
Thanks for Your Update :-)
Here is the result:
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == DISCONNECTED
1 - Wifi status API: 1
2 - Wifi status core: 7
3 - Wifi status: 7
WiFI.status == WRONG_PASSWORD
1 - Wifi status API: 2
2 - Wifi status core: 6
3 - Wifi status: 6
4 - reason: 204
time until connect: 5427.494 s
after 5400 s the WRONG PASSWORD rises... :-(
how could we proceed now?
from the examples above, imo it's a duplicate of the #7432
So you mean the introduced Enum WRONG_PASSWORD in core 3.0.0 has no intention to get the info of a wrong password within a few ms?
this might be a historical feature that was never implemented / broken? one mention of it is here - https://github.com/tzapu/WiFiManager/issues/528#issuecomment-366836252 although, @tablatronix might have a better explanation about the STATION_WRONG_PASSWORD and when it actually happens, since https://github.com/esp8266/Arduino/issues/4152 and https://github.com/esp8266/Arduino/pull/7652 don't go into much details and there's also https://github.com/espressif/ESP8266_NONOS_SDK/issues/218
Good to see its not a me problem, I was going crazy with this. I get 4 as the result of WiFi.status()
when I purposefully enter the wrong password, simply a connection failed error.
Basic Infos
Platform
Settings in IDE
Problem Description
When try to provoke the return off info
WL_WRONG_PASSWORD
this does not happen. sketch is provided.MCVE Sketch
Debug Messages