[ESP8266/ESP32] Problem setting hostname while on dynamic ip. (#17)

20 - Device does not change from static IP mode correctly
21 - DHCP hostname is not correctly configured (ESP32 & esp8266)
This commit is contained in:
pcniatic 2019-04-28 03:19:33 -04:00 committed by rjwats
parent 520f761f74
commit 2131d86224

View File

@ -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);
} 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.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.setHostname(_hostname.c_str());
#endif
}
// connect to the network
#if defined(ESP8266)
WiFi.hostname(_hostname);
#elif defined(ESP_PLATFORM)
WiFi.setHostname(_hostname.c_str());
#endif
WiFi.begin(_ssid.c_str(), _password.c_str());
}