From a0d176bd629075909460f07ef59d17d3f3e1b36a Mon Sep 17 00:00:00 2001 From: david gauchard Date: Mon, 6 May 2019 22:06:50 +0200 Subject: [PATCH] stop dhcp client before starting it this is a lighter workaround for #5527 and may require better understanding of the issue --- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index aae7aec7d2..6ea37bed60 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -204,6 +204,18 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, } if(!_useStaticIp) { + + // This is a lighter workaround for + // https://github.com/esp8266/Arduino/issues/5527#issuecomment-489324157 + // Stopping dhcp client allows restarting it again without needing + // to disconnect WiFi as a workaround + // XXXTODO: properly detect a previously connected network and + // behave nicely when waking up from deepsleep with + // persistence enabled, wifi started and dhcp called before + // actual user call to ::begin() + wifi_station_dhcpc_stop(); + // workaround end + wifi_station_dhcpc_start(); }