From e929332c440abe11638296906566695e1e4deae9 Mon Sep 17 00:00:00 2001 From: Shelby Merrick Date: Tue, 28 Sep 2021 18:43:30 -0400 Subject: [PATCH] Fixed hostname setting for ESP8266 --- ESPixelStick/ESPixelStick.ino | 2 +- ESPixelStick/src/ESPixelStick.h | 2 -- ESPixelStick/src/WebMgr.cpp | 2 ++ ESPixelStick/src/WiFiMgr.cpp | 16 +++++++++++++--- ESPixelStick/src/service/fseq.h | 3 ++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index f1655c7b9..2b4b78687 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -322,7 +322,7 @@ bool deserializeCore (JsonObject & json) do // once { - uint8_t TempVersion; + uint8_t TempVersion = 0; setFromJSON (TempVersion, json, CN_cfgver); if (TempVersion != CurrentConfigVersion) { diff --git a/ESPixelStick/src/ESPixelStick.h b/ESPixelStick/src/ESPixelStick.h index fdc820c83..198f6321c 100644 --- a/ESPixelStick/src/ESPixelStick.h +++ b/ESPixelStick/src/ESPixelStick.h @@ -23,12 +23,10 @@ #if defined(ARDUINO_ARCH_ESP8266) # include # include -# include # include #elif defined(ARDUINO_ARCH_ESP32) # include # include -# include # include #else # error "Unsupported CPU type" diff --git a/ESPixelStick/src/WebMgr.cpp b/ESPixelStick/src/WebMgr.cpp index 45c31480e..3dd727657 100644 --- a/ESPixelStick/src/WebMgr.cpp +++ b/ESPixelStick/src/WebMgr.cpp @@ -141,6 +141,8 @@ void c_WebMgr::init () }); // JSON Config Handler +//TODO: This is only being used by FPP to get the hostname. Will submit PR to change FPP and remove this +// https://github.com/FalconChristmas/fpp/blob/ae10a0b6fb1e32d1982c2296afac9af92e4da908/src/NetworkController.cpp#L248 webServer.on ("/conf", HTTP_GET, [this](AsyncWebServerRequest* request) { // DEBUG_V (CN_Heap_colon + String (ESP.getFreeHeap ())); diff --git a/ESPixelStick/src/WiFiMgr.cpp b/ESPixelStick/src/WiFiMgr.cpp index 8bd927f39..cc765f4f9 100644 --- a/ESPixelStick/src/WiFiMgr.cpp +++ b/ESPixelStick/src/WiFiMgr.cpp @@ -158,15 +158,24 @@ void c_WiFiMgr::connectWifi (const String & ssid, const String & passphrase) if (ResetWiFi) return; - // disconnect just in case + // Hostname must be set after the mode on ESP8266 and before on ESP32 #ifdef ARDUINO_ARCH_ESP8266 WiFi.disconnect (); + + // Switch to station mode + WiFi.mode (WIFI_STA); + // DEBUG_V (""); + + // DEBUG_V (String ("config->hostname: ") + config->hostname); + if (0 != config->hostname.length ()) + { + // DEBUG_V (String ("Setting WiFi hostname: ") + config->hostname); + WiFi.hostname (config->hostname); + } #else WiFi.persistent (false); // DEBUG_V (""); WiFi.disconnect (true); -#endif - // DEBUG_V (""); // DEBUG_V (String ("config->hostname: ") + config->hostname); if (0 != config->hostname.length ()) @@ -178,6 +187,7 @@ void c_WiFiMgr::connectWifi (const String & ssid, const String & passphrase) // Switch to station mode WiFi.mode (WIFI_STA); // DEBUG_V (""); +#endif logcon (String(F ("WiFi Connecting to '")) + ssid + diff --git a/ESPixelStick/src/service/fseq.h b/ESPixelStick/src/service/fseq.h index b641251de..1227ba765 100644 --- a/ESPixelStick/src/service/fseq.h +++ b/ESPixelStick/src/service/fseq.h @@ -81,9 +81,10 @@ struct FSEQRangeEntry } __attribute__ ((packed)); +// https://github.com/FalconChristmas/fpp/blob/master/docs/FSEQ_Sequence_File_Format.txt struct FSEQHeader { - uint8_t header[4]; // FSEQ + uint8_t header[4]; // PSEQ uint16_t dataOffset; uint8_t minorVersion; uint8_t majorVersion;