Skip to content

Commit

Permalink
BREAKING: Add Wrong Password wifi status case (esp8266#7652)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
devyte authored Oct 15, 2020
1 parent 79ea883 commit 1c624dd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
5 changes: 3 additions & 2 deletions doc/esp8266wifi/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ This function returns following codes to describe what is going on with Wi-Fi co
* 0 : ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses
* 1 : ``WL_NO_SSID_AVAIL``\ in case configured SSID cannot be reached
* 3 : ``WL_CONNECTED`` after successful connection is established
* 4 : ``WL_CONNECT_FAILED`` if password is incorrect
* 6 : ``WL_DISCONNECTED`` if module is not configured in station mode
* 4 : ``WL_CONNECT_FAILED`` if connection failed
* 6 : ``WL_CONNECT_WRONG_PASSWORD`` if password is incorrect
* 7 : ``WL_DISCONNECTED`` if module is not configured in station mode

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

Expand Down
5 changes: 3 additions & 2 deletions doc/esp8266wifi/station-class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ Wait until module connects to the access point. This function is intended for mo
Function returns one of the following connection statuses:

- ``WL_CONNECTED`` after successful connection is established
- ``WL_NO_SSID_AVAIL`` in case configured SSID cannot be reached
- ``WL_CONNECT_FAILED`` if password is incorrect
- ``WL_NO_SSID_AVAIL`` in case configured SSID cannot be reached
- ``WL_CONNECT_FAILED`` if connection failed
- ``WL_CONNECT_WRONG_PASSWORD`` if password is incorrect
- ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses
- ``WL_DISCONNECTED`` if module is not configured in station mode
- ``-1`` on timeout
Expand Down
10 changes: 8 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,21 @@ bool ESP8266WiFiGenericClass::resumeFromShutdown (WiFiState* state)
}
}
// state->state.fwconfig.bssid is not real bssid (it's what user may have provided when bssid_set==1)
if (WiFi.begin((const char*)state->state.fwconfig.ssid,
auto beginResult = WiFi.begin((const char*)state->state.fwconfig.ssid,
(const char*)state->state.fwconfig.password,
state->state.channel,
nullptr/*(const uint8_t*)state->state.fwconfig.bssid*/, // <- try with gw's mac address?
true) == WL_CONNECT_FAILED)
true);
if (beginResult == WL_CONNECT_FAILED)
{
DEBUG_WIFI("core: resume: WiFi.begin failed\n");
return false;
}
if (beginResult == WL_WRONG_PASSWORD)
{
DEBUG_WIFI("core: resume: WiFi.begin wrong password\n");
return false;
}
}

if (state->state.mode & WIFI_AP)
Expand Down
3 changes: 3 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ static void printWiFiStatus(wl_status_t status)
case WL_CONNECT_FAILED:
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed.\n");
break;
case WL_WRONG_PASSWORD:
DEBUG_WIFI_MULTI("[WIFIM] Wrong password.\n");
break;
default:
DEBUG_WIFI_MULTI("[WIFIM] Connecting failed (%d).\n", status);
break;
Expand Down
3 changes: 2 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,9 @@ wl_status_t ESP8266WiFiSTAClass::status() {
case STATION_NO_AP_FOUND:
return WL_NO_SSID_AVAIL;
case STATION_CONNECT_FAIL:
case STATION_WRONG_PASSWORD:
return WL_CONNECT_FAILED;
case STATION_WRONG_PASSWORD:
return WL_WRONG_PASSWORD;
case STATION_IDLE:
return WL_IDLE_STATUS;
default:
Expand Down
3 changes: 2 additions & 1 deletion libraries/ESP8266WiFi/src/include/wl_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ typedef enum {
WL_CONNECTED = 3,
WL_CONNECT_FAILED = 4,
WL_CONNECTION_LOST = 5,
WL_DISCONNECTED = 6
WL_WRONG_PASSWORD = 6,
WL_DISCONNECTED = 7
} wl_status_t;

/* Encryption modes */
Expand Down
3 changes: 2 additions & 1 deletion libraries/esp8266/examples/interactive/interactive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void setup() {
"WL_CONNECTED = 3\n"
"WL_CONNECT_FAILED = 4\n"
"WL_CONNECTION_LOST = 5\n"
"WL_DISCONNECTED = 6\n"
"WL_WRONG_PASSWORD = 6\n"
"WL_DISCONNECTED = 7\n"
);
}

Expand Down

0 comments on commit 1c624dd

Please sign in to comment.