Skip to content

Commit 2131d86

Browse files
maurodeluccarjwats
authored andcommitted
[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)
1 parent 520f761 commit 2131d86

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/WiFiSettingsService.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ void WiFiSettingsService::reconfigureWiFiConnection() {
6464
// configure static ip config for station mode (if set)
6565
if (_staticIPConfig) {
6666
WiFi.config(_localIP, _gatewayIP, _subnetMask, _dnsIP1, _dnsIP2);
67-
}
68-
69-
// connect to the network
70-
#if defined(ESP8266)
71-
WiFi.hostname(_hostname);
67+
} else { // else setting dynamic ip config and hostname
68+
#if defined(ESP8266)
69+
WiFi.config(INADDR_ANY, INADDR_ANY, INADDR_ANY);
70+
WiFi.hostname(_hostname);
7271
#elif defined(ESP_PLATFORM)
73-
WiFi.setHostname(_hostname.c_str());
72+
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
73+
WiFi.setHostname(_hostname.c_str());
7474
#endif
75+
}
7576

77+
// connect to the network
7678
WiFi.begin(_ssid.c_str(), _password.c_str());
7779
}
7880

0 commit comments

Comments
 (0)