Maybe this is a dumb question, but is there a way to test for wrong Wifi password?
I know you can do WL_CONNECT to check if the password works, but is there a command for checking if the password is wrong? Not just by waiting.
The information is available on SDK level. If you include #include "user_interface.h"
, you can use function wifi_station_get_connect_status()
. It returns one of:
STATION_GOT_IP
STATION_NO_AP_FOUND
STATION_CONNECT_FAIL
STATION_WRONG_PASSWORD
STATION_IDLE
The WiFi.status()
function uses function wifi_station_get_connect_status()
, but returns WL_CONNECT_FAILED for STATION_WRONG_PASSWORD.
one can check for wrong password using the following code snippet
if (WiFi.status() == WL_CONNECTED)
{
Serial.println("Connected successfully");
}
else if (WiFi.status() == WL_NO_SSID_AVAIL)
{
Serial.println("Wifi network is not avaliable");
}
else
{
Serial.println("Password is not correct");
}
more information can be found on GitHub here: https://github.com/aeonSolutions/aeonlabs-ESP32-C-Base-Firmware-Libraries
WiFi
class does not return the info even though it's available. It simply returns an error.