Skip to content

Commit

Permalink
[WiFi] Reset wifi when IP is set to 0.0.0.0
Browse files Browse the repository at this point in the history
As being described a few times and a screenshot shown here: letscontrolit#1302 (comment)
It looks like a DHCP request may fail resulting in a cleared IP setup. The web server then still replies to requests, but no new connections can be made then.

This patch should detect such a situation and then reset the wifi and make a new connection.
  • Loading branch information
TD-er committed Jul 11, 2018
1 parent f5b026e commit ad06cbc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ESPEasyWifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,16 @@ void WifiCheck()
return;

processDisableAPmode();
IPAddress ip = WiFi.localIP();
if (!useStaticIP()) {
if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) {
if (WiFiConnected()) {
// Some strange situation where the DHCP renew probably has failed and erased the config.
resetWiFi();
}
}
}

if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
if (timeOutReached(last_wifi_connect_attempt_moment + (1000 + wifi_connect_attempt * 200))) {
WiFiConnectRelaxed();
Expand Down

0 comments on commit ad06cbc

Please sign in to comment.