diff --git a/lib/ota/ota.cpp b/lib/ota/ota.cpp index 667251e..9d1622d 100644 --- a/lib/ota/ota.cpp +++ b/lib/ota/ota.cpp @@ -57,7 +57,13 @@ void OTA::otaSetup(const char * const otaPassword) { else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); else if (error == OTA_END_ERROR) Serial.println("End Failed"); }); - ArduinoOTA.begin(); +#ifdef ESP8266 + ArduinoOTA.begin(false); +#endif +#if ESP32 + ArduinoOTA.setMdnsEnabled(false); + ArduinoOTA.begin(); +#endif Serial.println("[NOTICE] OTA updates allowed"); } diff --git a/src/network/wifihandler.cpp b/src/network/wifihandler.cpp index 0f9a527..f19ba62 100644 --- a/src/network/wifihandler.cpp +++ b/src/network/wifihandler.cpp @@ -63,10 +63,24 @@ void WiFiNetwork::setWiFiCredentials(const char* SSID, const char* pass) { IPAddress WiFiNetwork::getAddress() { return WiFi.localIP(); } void WiFiNetwork::setUp() { + static constexpr auto hostnamePrefix = "SlimeVR-FBT-Tracker-"; + uint8_t mac[6]; + WiFi.macAddress(mac); + String hostname = hostnamePrefix + String(mac[3], HEX) + String(mac[4], HEX) + + String(mac[5], HEX); + + // Disable auto connect on boot. Else we start connecting before we set up + // everything +#if ESP8266 + if (WiFi.getAutoConnect()) { + WiFi.setAutoConnect(false); + } +#endif + wifiHandlerLogger.info("Setting up WiFi"); WiFi.persistent(true); WiFi.mode(WIFI_STA); - WiFi.hostname("SlimeVR FBT Tracker"); + WiFi.hostname(hostname.c_str()); wifiHandlerLogger.info( "Loaded credentials for SSID '%s' and pass length %d", getSSID().c_str(),