Update OTA setup and WiFi hostname configuration

- Modify OTA setup for ESP8266 and ESP32 to disable mDNS and adjust initialization.
- Change WiFi hostname to include MAC address for unique identification.
- Disable auto connect on boot for ESP8266 to ensure proper setup.
This commit is contained in:
unlogisch04
2025-12-23 01:25:45 +01:00
parent 6cd29c7cea
commit 6d06b60897
2 changed files with 22 additions and 2 deletions

View File

@@ -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");
}

View File

@@ -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(),