Skip to content

Commit

Permalink
Fix reconnect failure after a long disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
weilinfox committed Sep 11, 2022
1 parent 8e1a7b2 commit c456b45
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void setup() {
WiFi.config(local_ip, gateway, netmask, IPAddress(223, 5, 5, 5), gateway);
#endif
WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true);
//WiFi.setAutoReconnect(true);
//WiFi.persistent(true);
WiFi.setSleep(false);
WiFi.setHostname(hostname);
// TODO: Realize permanent config over serial or hotspot
Expand Down Expand Up @@ -171,7 +172,8 @@ void loop() {
wg.end();
uart0.println("done.");
uart0.println("Reconnect wifi.");
WiFi.reconnect();
WiFi.disconnect();
WiFi.begin(ssid, password);
}
if (WiFi.isConnected() && ! wg.is_initialized()) {
uart0.println("Wifi connection established.");
Expand Down

0 comments on commit c456b45

Please sign in to comment.