Skip to content

Commit

Permalink
[wifi] Added connectionCheckHandler() to force reconnect when needed
Browse files Browse the repository at this point in the history
Example taken from [this issue discussion](esp8266/Arduino#4445)
  • Loading branch information
TD-er committed Apr 28, 2018
1 parent c3e0153 commit 9705702
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ESPEasy-Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,24 @@ enum WiFiDisconnectReason
#endif


#ifndef ESP32
// To do some reconnection check.
#include <Ticker.h>
bool reconnectChecker = false;
Ticker connectionCheck;
void connectionCheckHandler()
{

if (reconnectChecker == false && WiFi.status() != WL_CONNECTED){
reconnectChecker = true;
WiFi.reconnect();
}
else if (WiFi.status() == WL_CONNECTED && reconnectChecker == true){
reconnectChecker = false;
}
}
#endif

bool useStaticIP();

// WiFi related data
Expand Down
3 changes: 3 additions & 0 deletions src/ESPEasy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ void setup()
}
#endif

#ifndef ESP32
connectionCheck.attach(240, connectionCheckHandler);
#endif
}

#ifdef USE_RTOS_MULTITASKING
Expand Down

0 comments on commit 9705702

Please sign in to comment.