Skip to content

Commit 1c624dd

Browse files
authored
BREAKING: Add Wrong Password wifi status case (#7652)
* Add Wrong Password wifi status case * Add wrong password case for status return * Add wrong password case for debug * Add Wrong password case to interactive example * Add case for wrong password to station doc * Add case for wrong password to resumeFromShutdown * Add wrong password case to wifi readme * Update ESP8266WiFiGeneric.cpp
1 parent 79ea883 commit 1c624dd

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

doc/esp8266wifi/readme.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ This function returns following codes to describe what is going on with Wi-Fi co
260260
* 0 : ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses
261261
* 1 : ``WL_NO_SSID_AVAIL``\ in case configured SSID cannot be reached
262262
* 3 : ``WL_CONNECTED`` after successful connection is established
263-
* 4 : ``WL_CONNECT_FAILED`` if password is incorrect
264-
* 6 : ``WL_DISCONNECTED`` if module is not configured in station mode
263+
* 4 : ``WL_CONNECT_FAILED`` if connection failed
264+
* 6 : ``WL_CONNECT_WRONG_PASSWORD`` if password is incorrect
265+
* 7 : ``WL_DISCONNECTED`` if module is not configured in station mode
265266

266267
It is a good practice to display and check information returned by functions. Application development and troubleshooting will be easier with that.
267268

doc/esp8266wifi/station-class.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ Wait until module connects to the access point. This function is intended for mo
250250
Function returns one of the following connection statuses:
251251

252252
- ``WL_CONNECTED`` after successful connection is established
253-
- ``WL_NO_SSID_AVAIL`` in case configured SSID cannot be reached
254-
- ``WL_CONNECT_FAILED`` if password is incorrect
253+
- ``WL_NO_SSID_AVAIL`` in case configured SSID cannot be reached
254+
- ``WL_CONNECT_FAILED`` if connection failed
255+
- ``WL_CONNECT_WRONG_PASSWORD`` if password is incorrect
255256
- ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses
256257
- ``WL_DISCONNECTED`` if module is not configured in station mode
257258
- ``-1`` on timeout

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,21 @@ bool ESP8266WiFiGenericClass::resumeFromShutdown (WiFiState* state)
827827
}
828828
}
829829
// state->state.fwconfig.bssid is not real bssid (it's what user may have provided when bssid_set==1)
830-
if (WiFi.begin((const char*)state->state.fwconfig.ssid,
830+
auto beginResult = WiFi.begin((const char*)state->state.fwconfig.ssid,
831831
(const char*)state->state.fwconfig.password,
832832
state->state.channel,
833833
nullptr/*(const uint8_t*)state->state.fwconfig.bssid*/, // <- try with gw's mac address?
834-
true) == WL_CONNECT_FAILED)
834+
true);
835+
if (beginResult == WL_CONNECT_FAILED)
835836
{
836837
DEBUG_WIFI("core: resume: WiFi.begin failed\n");
837838
return false;
838839
}
840+
if (beginResult == WL_WRONG_PASSWORD)
841+
{
842+
DEBUG_WIFI("core: resume: WiFi.begin wrong password\n");
843+
return false;
844+
}
839845
}
840846

841847
if (state->state.mode & WIFI_AP)

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ static void printWiFiStatus(wl_status_t status)
6060
case WL_CONNECT_FAILED:
6161
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed.\n");
6262
break;
63+
case WL_WRONG_PASSWORD:
64+
DEBUG_WIFI_MULTI("[WIFIM] Wrong password.\n");
65+
break;
6366
default:
6467
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed (%d).\n", status);
6568
break;

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,9 @@ wl_status_t ESP8266WiFiSTAClass::status() {
624624
case STATION_NO_AP_FOUND:
625625
return WL_NO_SSID_AVAIL;
626626
case STATION_CONNECT_FAIL:
627-
case STATION_WRONG_PASSWORD:
628627
return WL_CONNECT_FAILED;
628+
case STATION_WRONG_PASSWORD:
629+
return WL_WRONG_PASSWORD;
629630
case STATION_IDLE:
630631
return WL_IDLE_STATUS;
631632
default:

libraries/ESP8266WiFi/src/include/wl_definitions.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ typedef enum {
5555
WL_CONNECTED = 3,
5656
WL_CONNECT_FAILED = 4,
5757
WL_CONNECTION_LOST = 5,
58-
WL_DISCONNECTED = 6
58+
WL_WRONG_PASSWORD = 6,
59+
WL_DISCONNECTED = 7
5960
} wl_status_t;
6061

6162
/* Encryption modes */

libraries/esp8266/examples/interactive/interactive.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ void setup() {
4242
"WL_CONNECTED = 3\n"
4343
"WL_CONNECT_FAILED = 4\n"
4444
"WL_CONNECTION_LOST = 5\n"
45-
"WL_DISCONNECTED = 6\n"
45+
"WL_WRONG_PASSWORD = 6\n"
46+
"WL_DISCONNECTED = 7\n"
4647
);
4748
}
4849

0 commit comments

Comments
 (0)