diff --git a/src/WiFiSettingsService.cpp b/src/WiFiSettingsService.cpp index 05292c88..a9c1296e 100644 --- a/src/WiFiSettingsService.cpp +++ b/src/WiFiSettingsService.cpp @@ -64,15 +64,17 @@ void WiFiSettingsService::reconfigureWiFiConnection() { // configure static ip config for station mode (if set) if (_staticIPConfig) { WiFi.config(_localIP, _gatewayIP, _subnetMask, _dnsIP1, _dnsIP2); - } - - // connect to the network -#if defined(ESP8266) - WiFi.hostname(_hostname); + } else { // else setting dynamic ip config and hostname +#if defined(ESP8266) + WiFi.config(INADDR_ANY, INADDR_ANY, INADDR_ANY); + WiFi.hostname(_hostname); #elif defined(ESP_PLATFORM) - WiFi.setHostname(_hostname.c_str()); + WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); + WiFi.setHostname(_hostname.c_str()); #endif + } + // connect to the network WiFi.begin(_ssid.c_str(), _password.c_str()); }