mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
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:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user