Commit d1507ae6 authored by Eric Duminil's avatar Eric Duminil
Browse files

Setting Hostname (more) reliably

parent 98427bcf
Pipeline #5888 passed with stage
in 2 minutes and 17 seconds
......@@ -93,13 +93,7 @@ bool IotWebConf::init()
this->_apTimeoutMs = atoi(this->_apTimeoutStr) * 1000;
// -- Setup mdns
#ifdef ESP8266
WiFi.hostname(this->_thingName);
#elif defined(ESP32)
WiFi.setHostname(this->_thingName);
#endif
#ifdef IOTWEBCONF_CONFIG_USE_MDNS
//TODO: What is _thingName set to at this point??
MDNS.begin(this->_thingName);
MDNS.addService("http", "tcp", IOTWEBCONF_CONFIG_USE_MDNS);
#endif
......@@ -729,6 +723,9 @@ void IotWebConf::stateChanged(NetworkState oldState, NetworkState newState)
#endif
this->_wifiConnectionStart = millis();
WiFi.mode(WIFI_STA);
// Hostname must be set right before WiFi.begin in order to work reliably,
// and will be set only once WiFi.begin has been called.
WiFi.setHostname(this->_thingName);
this->_wifiConnectionHandler(
this->_wifiAuthInfo.ssid, this->_wifiAuthInfo.password);
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment