From e7b1e358dc3224f97d199ef345f2ead2e1714316 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Sat, 9 Oct 2021 10:01:33 -0400 Subject: [PATCH 01/11] Added forced config save when a config from the upload utility is detected. This corrects issues with the config and fills in missing fields. --- ESPixelStick/ESPixelStick.ino | 14 ++++++++++---- ESPixelStick/src/ConstNames.cpp | 1 + ESPixelStick/src/ConstNames.hpp | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index 4500e4cf0..f381f6a94 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -89,6 +89,7 @@ uint32_t lastUpdate; // Update timeout tracker bool ResetWiFi = false; bool InitializeConfig = false; // Configuration initialization flag bool ConfigLoadNeeded = false; +bool NeedAutoConfig = true; ///////////////////////////////////////////////////////// // @@ -231,6 +232,7 @@ bool dsDevice(JsonObject & json) JsonObject JsonDeviceConfig = json[CN_device]; //TODO: Add configuration upgrade handling - cfgver moved to root level + setFromJSON (NeedAutoConfig, json, CN_NeedAutoConfig); ConfigChanged |= setFromJSON (config.id, JsonDeviceConfig, CN_id); ConfigChanged |= setFromJSON (config.BlankDelay, JsonDeviceConfig, CN_blanktime); @@ -327,6 +329,7 @@ bool deserializeCore (JsonObject & json) { //TODO: Add configuration update handler logcon (String (F ("Incorrect Config Version ID"))); + NeedAutoConfig = true; } setFromJSON (InitializeConfig, json, CN_init); @@ -379,8 +382,9 @@ void loadConfig() String temp; // DEBUG_V (""); FileMgr.LoadConfigFile (ConfigFileName, &deserializeCoreHandler); - if (!validateConfig()) + if ((!validateConfig()) || (NeedAutoConfig)) { + // DEBUG_V (String ("NeedAutoConfig: ") + String (NeedAutoConfig)); SaveConfig(); } @@ -403,10 +407,12 @@ void GetConfig (JsonObject & json) // Config Version json[CN_cfgver] = CurrentConfigVersion; + // Device - JsonObject device = json.createNestedObject(CN_device); - device[CN_id] = config.id; - device[CN_blanktime] = config.BlankDelay; + JsonObject device = json.createNestedObject(CN_device); + device[CN_id] = config.id; + device[CN_blanktime] = config.BlankDelay; + json[CN_NeedAutoConfig] = false; FileMgr.GetConfig (device); diff --git a/ESPixelStick/src/ConstNames.cpp b/ESPixelStick/src/ConstNames.cpp index 11980da3d..f279b461c 100644 --- a/ESPixelStick/src/ConstNames.cpp +++ b/ESPixelStick/src/ConstNames.cpp @@ -109,6 +109,7 @@ const char CN_mode_name [] = "mode_name"; const char CN_mosi_pin [] = "mosi_pin"; const char CN_multicast [] = "multicast"; const char CN_name [] = "name"; +const char CN_NeedAutoConfig [] = "NeedAutoConfig"; const char CN_netmask [] = "netmask"; const char CN_network [] = "network"; const char CN_num_chan [] = "num_chan"; diff --git a/ESPixelStick/src/ConstNames.hpp b/ESPixelStick/src/ConstNames.hpp index 99b78a5b2..b8f20e59b 100644 --- a/ESPixelStick/src/ConstNames.hpp +++ b/ESPixelStick/src/ConstNames.hpp @@ -111,6 +111,7 @@ extern const char CN_mode_name []; extern const char CN_mosi_pin[]; extern const char CN_multicast []; extern const char CN_name []; +extern const char CN_NeedAutoConfig []; extern const char CN_netmask []; extern const char CN_network []; extern const char CN_num_chan[]; From 5e05d67dfcdd54f378b1380f156b7dd36e4a957d Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Sat, 9 Oct 2021 12:57:24 -0400 Subject: [PATCH 02/11] Added the ability to configure the port used by E1.31 --- ESPixelStick/src/input/InputE131.cpp | 28 +++++++++++++++++++++------- ESPixelStick/src/input/InputE131.hpp | 2 ++ html/e1_31.html | 7 +++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ESPixelStick/src/input/InputE131.cpp b/ESPixelStick/src/input/InputE131.cpp index 4e6a2122f..fe4061113 100644 --- a/ESPixelStick/src/input/InputE131.cpp +++ b/ESPixelStick/src/input/InputE131.cpp @@ -82,6 +82,7 @@ void c_InputE131::GetConfig (JsonObject & jsonConfig) jsonConfig[CN_universe] = startUniverse; jsonConfig[CN_universe_limit] = ChannelsPerUniverse; jsonConfig[CN_universe_start] = FirstUniverseChannelOffset; + jsonConfig[CN_port] = PortId; // DEBUG_END; @@ -258,9 +259,19 @@ bool c_InputE131::SetConfig (ArduinoJson::JsonObject& jsonConfig) { // DEBUG_START; + ESPAsyncE131PortId OldPortId = PortId; + setFromJSON (startUniverse, jsonConfig, CN_universe); setFromJSON (ChannelsPerUniverse, jsonConfig, CN_universe_limit); setFromJSON (FirstUniverseChannelOffset, jsonConfig, CN_universe_start); + setFromJSON (PortId, jsonConfig, CN_port); + + if ((OldPortId != PortId) && (ESPAsyncE131Initialized)) + { + // ask for a reboot. + reboot = true; + logcon (String (F ("Requesting reboot on change of UDP port."))); + } validateConfiguration (); @@ -344,9 +355,9 @@ void c_InputE131::NetworkStateChanged (bool IsConnected, bool ReBootAllowed) if (IsConnected) { // Get on with business - if (e131->begin (E131_MULTICAST, startUniverse, LastUniverse - startUniverse + 1)) + if (e131->begin (e131_listen_t::E131_MULTICAST, PortId, startUniverse, LastUniverse - startUniverse + 1)) { - logcon (String (F ("Multicast enabled"))); + // logcon (String (F ("Multicast enabled"))); } else { @@ -355,9 +366,9 @@ void c_InputE131::NetworkStateChanged (bool IsConnected, bool ReBootAllowed) // DEBUG_V (""); - if (e131->begin (E131_UNICAST)) + if (e131->begin (e131_listen_t::E131_UNICAST, PortId, startUniverse, LastUniverse - startUniverse + 1)) { - logcon (String (F ("Listening on port ")) + E131_DEFAULT_PORT); + // logcon (String (F ("Listening on port ")) + PortId); } else { @@ -365,14 +376,17 @@ void c_InputE131::NetworkStateChanged (bool IsConnected, bool ReBootAllowed) } logcon (String (F ("Listening for ")) + InputDataBufferSize + - F (" channels from Universe ") + startUniverse + - F (" to ") + LastUniverse); + F (" channels from Universe ") + startUniverse + + F (" to ") + LastUniverse + + F (" on port ") + PortId); + + ESPAsyncE131Initialized = true; } else if (ReBootAllowed) { // handle a disconnect // E1.31 does not do this gracefully. A loss of connection needs a reboot - extern bool reboot; + // extern bool reboot; reboot = true; logcon (String (F ("Input requesting reboot on loss of WiFi connection."))); } diff --git a/ESPixelStick/src/input/InputE131.hpp b/ESPixelStick/src/input/InputE131.hpp index f36aa11bb..ecd8acd9f 100644 --- a/ESPixelStick/src/input/InputE131.hpp +++ b/ESPixelStick/src/input/InputE131.hpp @@ -36,6 +36,8 @@ class c_InputE131 : public c_InputCommon uint16_t LastUniverse = 1; ///< Last Universe to listen for uint16_t ChannelsPerUniverse = 512; ///< Universe boundary limit uint16_t FirstUniverseChannelOffset = 1; ///< Channel to start listening at - 1 based + ESPAsyncE131PortId PortId = E131_DEFAULT_PORT; + bool ESPAsyncE131Initialized = false; /// from sketch globals uint16_t channel_count = 0; ///< Number of channels. Derived from output module configuration. diff --git a/html/e1_31.html b/html/e1_31.html index b76321380..9115b935f 100644 --- a/html/e1_31.html +++ b/html/e1_31.html @@ -17,4 +17,11 @@ + + \ No newline at end of file From 706c930a44668628abc9a88d5980882d50bd1cab Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Sat, 9 Oct 2021 16:00:30 -0400 Subject: [PATCH 03/11] Updated to use latest ESP Async E131 library --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 322d1497c..b35045e3e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,7 +26,7 @@ lib_deps = bblanchon/StreamUtils @ 1.6.1 djgrrr/Int64String @ 1.1.1 esphome/ESPAsyncWebServer-esphome @ 1.3.0 - forkineye/ESPAsyncE131 @ 1.0.2 + forkineye/ESPAsyncE131 @ 1.0.3 ottowinter/AsyncMqttClient-esphome @ 0.8.5 https://github.com/natcl/Artnet ; pull latest https://github.com/MartinMueller2003/Espalexa ; pull latest From d2f9d1afdd375c32cfdb30b5e8f79936e9b7c50b Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Sun, 10 Oct 2021 13:32:58 -0400 Subject: [PATCH 04/11] Updated E131 lib to 1.0.4 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index b35045e3e..2eeb49ca5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,7 +26,7 @@ lib_deps = bblanchon/StreamUtils @ 1.6.1 djgrrr/Int64String @ 1.1.1 esphome/ESPAsyncWebServer-esphome @ 1.3.0 - forkineye/ESPAsyncE131 @ 1.0.3 + forkineye/ESPAsyncE131 @ 1.0.4 ottowinter/AsyncMqttClient-esphome @ 0.8.5 https://github.com/natcl/Artnet ; pull latest https://github.com/MartinMueller2003/Espalexa ; pull latest From ef4f6ebb6d6fc045de0eed87e808b764cfe2c358 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Sun, 10 Oct 2021 13:39:51 -0400 Subject: [PATCH 05/11] Renamed InitializeConfig to IsBooting to control output at boot time. Reworked trigger to save device config when element exists that is created by the flash tool. --- ESPixelStick/ESPixelStick.ino | 73 ++++++++++++++---------- ESPixelStick/src/ESPixelStick.h | 2 +- ESPixelStick/src/FileMgr.cpp | 2 +- ESPixelStick/src/WebMgr.cpp | 6 +- ESPixelStick/src/WiFiMgr.cpp | 8 --- ESPixelStick/src/WiFiMgr.hpp | 6 +- ESPixelStick/src/input/InputMgr.cpp | 8 +-- ESPixelStick/src/output/OutputMgr.cpp | 39 +++++++------ ESPixelStick/src/output/OutputMgr.hpp | 1 + ESPixelStick/src/output/OutputSerial.cpp | 2 +- ESPixelStick/src/output/OutputSpi.cpp | 2 +- 11 files changed, 82 insertions(+), 67 deletions(-) diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index f381f6a94..b7684dcff 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -87,9 +87,9 @@ config_t config; // Current configuration bool reboot = false; // Reboot flag uint32_t lastUpdate; // Update timeout tracker bool ResetWiFi = false; -bool InitializeConfig = false; // Configuration initialization flag +bool IsBooting = true; // Configuration initialization flag bool ConfigLoadNeeded = false; -bool NeedAutoConfig = true; +bool ConfigSaveNeeded = false; ///////////////////////////////////////////////////////// // @@ -168,7 +168,8 @@ void setup() // DEBUG_END; // Done with initialization - InitializeConfig = false; + IsBooting = false; + } // setup ///////////////////////////////////////////////////////// @@ -191,12 +192,6 @@ bool validateConfig() String chipId = int64String (ESP.getEfuseMac (), HEX); #endif - // Initialization - Force save - if (InitializeConfig) { - logcon (CN_stars + String (F (" Configuration Initialization ")) + CN_stars); - configValid = false; - } - // Device defaults if (!config.id.length ()) { @@ -232,8 +227,6 @@ bool dsDevice(JsonObject & json) JsonObject JsonDeviceConfig = json[CN_device]; //TODO: Add configuration upgrade handling - cfgver moved to root level - setFromJSON (NeedAutoConfig, json, CN_NeedAutoConfig); - ConfigChanged |= setFromJSON (config.id, JsonDeviceConfig, CN_id); ConfigChanged |= setFromJSON (config.BlankDelay, JsonDeviceConfig, CN_blanktime); } @@ -295,15 +288,13 @@ bool dsNetwork(JsonObject & json) } // dsNetwork // Save the config and schedule a load operation -void SetConfig (JsonObject & json, const char * DataString) +void SetConfig (const char * DataString) { // DEBUG_START; //TODO: This is being called from c_WebMgr::processCmdSet() with no validation // of the data. Chance for 3rd party software to muck up the configuraton // if they send bad json data. - // Set config version - json[CN_cfgver] = CurrentConfigVersion; FileMgr.SaveConfigFile (ConfigFileName, DataString); ConfigLoadNeeded = true; @@ -323,21 +314,33 @@ bool deserializeCore (JsonObject & json) do // once { - uint8_t TempVersion = 0; - setFromJSON (TempVersion, json, CN_cfgver); - if (TempVersion != CurrentConfigVersion) + if (json.containsKey(CN_cfgver)) { - //TODO: Add configuration update handler - logcon (String (F ("Incorrect Config Version ID"))); - NeedAutoConfig = true; + uint8_t TempVersion = uint8_t(-1); + setFromJSON (TempVersion, json, CN_cfgver); + if (TempVersion != CurrentConfigVersion) + { + //TODO: Add configuration update handler + logcon (String (F ("Incorrect Config Version ID"))); + } + } + else + { + logcon (String (F ("Missing Config Version ID"))); } - setFromJSON (InitializeConfig, json, CN_init); + // is this an initial config from the flash tool? + if (json.containsKey (CN_init)) + { + // trigger a save operation + ConfigSaveNeeded = true; + } dsDevice (json); FileMgr.SetConfig (json); ResetWiFi = dsNetwork (json); DataHasBeenAccepted = true; + } while (false); // DEBUG_END; @@ -360,6 +363,8 @@ void SaveConfig() { // DEBUG_START; + ConfigSaveNeeded = false; + // Save Config String DataToSave = serializeCore (false); // DEBUG_V ("ConfigFileName: " + ConfigFileName); @@ -382,11 +387,8 @@ void loadConfig() String temp; // DEBUG_V (""); FileMgr.LoadConfigFile (ConfigFileName, &deserializeCoreHandler); - if ((!validateConfig()) || (NeedAutoConfig)) - { - // DEBUG_V (String ("NeedAutoConfig: ") + String (NeedAutoConfig)); - SaveConfig(); - } + + ConfigSaveNeeded |= !validateConfig (); // DEBUG_START; } // loadConfig @@ -407,12 +409,10 @@ void GetConfig (JsonObject & json) // Config Version json[CN_cfgver] = CurrentConfigVersion; - // Device JsonObject device = json.createNestedObject(CN_device); device[CN_id] = config.id; device[CN_blanktime] = config.BlankDelay; - json[CN_NeedAutoConfig] = false; FileMgr.GetConfig (device); @@ -524,6 +524,11 @@ void loop() loadConfig (); } + if (ConfigSaveNeeded) + { + SaveConfig (); + } + if (true == ResetWiFi) { ResetWiFi = false; @@ -534,6 +539,16 @@ void loop() void _logcon (String & DriverName, String Message) { - LOG_PORT.println ("[" + DriverName + "] " + Message); + char Spaces[] = { " " }; + if (DriverName.length() < (sizeof(Spaces)-1)) + { + Spaces[(sizeof (Spaces) - 1) - DriverName.length ()] = '\0'; + } + else + { + Spaces[0] = '\0'; + } + + LOG_PORT.println ("[" + String (Spaces) + DriverName + "] " + Message); LOG_PORT.flush (); } // logcon diff --git a/ESPixelStick/src/ESPixelStick.h b/ESPixelStick/src/ESPixelStick.h index 198f6321c..4e2016094 100644 --- a/ESPixelStick/src/ESPixelStick.h +++ b/ESPixelStick/src/ESPixelStick.h @@ -76,7 +76,7 @@ bool deserializeCore (JsonObject & json); bool dsDevice (JsonObject & json); bool dsNetwork (JsonObject & json); extern bool reboot; -extern bool InitializeConfig; +extern bool IsBooting; extern bool ResetWiFi; static const String ConfigFileName = "/config.json"; diff --git a/ESPixelStick/src/FileMgr.cpp b/ESPixelStick/src/FileMgr.cpp index 81d1d3a5c..ec8c66059 100644 --- a/ESPixelStick/src/FileMgr.cpp +++ b/ESPixelStick/src/FileMgr.cpp @@ -232,7 +232,7 @@ bool c_FileMgr::LoadConfigFile (const String& FileName, DeserializationHandler H fs::File file = LittleFS.open (FileName.c_str (), "r"); if (!file) { - if (!InitializeConfig) { + if (!IsBooting) { logcon (String (CN_stars) + CfgFileMessagePrefix + String (F (" Could not open file for reading ")) + CN_stars); } break; diff --git a/ESPixelStick/src/WebMgr.cpp b/ESPixelStick/src/WebMgr.cpp index 54a7226f8..17312c52f 100644 --- a/ESPixelStick/src/WebMgr.cpp +++ b/ESPixelStick/src/WebMgr.cpp @@ -945,9 +945,9 @@ bool c_WebMgr::processCmdSet (JsonObject & jsonCmd) if ((jsonCmd.containsKey (CN_device)) || (jsonCmd.containsKey (CN_network))) { // DEBUG_V ("device/network"); - extern void SetConfig (JsonObject &, const char* DataString); + extern void SetConfig (const char* DataString); serializeJson (jsonCmd, WebSocketFrameCollectionBuffer, sizeof (WebSocketFrameCollectionBuffer) - 1); - SetConfig (jsonCmd, WebSocketFrameCollectionBuffer); + SetConfig (WebSocketFrameCollectionBuffer); pAlexaDevice->setName (config.id); // DEBUG_V ("device/network: Done"); @@ -987,7 +987,7 @@ bool c_WebMgr::processCmdSet (JsonObject & jsonCmd) break; } - logcon (" "); + // logcon (" "); PrettyPrint (jsonCmd, String(CN_stars) + F (" ERROR: Undhandled Set request type. ") + CN_stars ); strcat (WebSocketFrameCollectionBuffer, "ERROR"); diff --git a/ESPixelStick/src/WiFiMgr.cpp b/ESPixelStick/src/WiFiMgr.cpp index 202891921..3339cd97b 100644 --- a/ESPixelStick/src/WiFiMgr.cpp +++ b/ESPixelStick/src/WiFiMgr.cpp @@ -158,7 +158,6 @@ void c_WiFiMgr::connectWifi (const String & ssid, const String & passphrase) if (ResetWiFi) return; - LOG_PORT.println(); SetUpIp (); // Hostname must be set after the mode on ESP8266 and before on ESP32 @@ -362,7 +361,6 @@ void c_WiFiMgr::AnnounceState () String StateName; pCurrentFsmState->GetStateName (StateName); - LOG_PORT.println (""); logcon (String (F ("WiFi Entering State: ")) + StateName); // DEBUG_END; @@ -429,7 +427,6 @@ void fsm_WiFi_state_ConnectingUsingConfig::Poll () { if (CurrentTimeMS - WiFiMgr.GetFsmStartTime() > (1000 * WiFiMgr.GetConfigPtr()->sta_timeout)) { - LOG_PORT.println (""); logcon (F ("WiFi Failed to connect using Configured Credentials")); fsm_WiFi_state_ConnectingDefault_imp.Init (); } @@ -487,7 +484,6 @@ void fsm_WiFi_state_ConnectingUsingDefaults::Poll () { if (CurrentTimeMS - WiFiMgr.GetFsmStartTime () > (1000 * WiFiMgr.GetConfigPtr ()->sta_timeout)) { - LOG_PORT.println (""); logcon (F ("WiFi Failed to connect using default Credentials")); fsm_WiFi_state_ConnectingAsAP_imp.Init (); } @@ -539,11 +535,8 @@ void fsm_WiFi_state_ConnectingAsAP::Poll () } else { - LOG_PORT.print ("."); - if (millis () - WiFiMgr.GetFsmStartTime () > (1000 * WiFiMgr.GetConfigPtr ()->ap_timeout)) { - LOG_PORT.println (""); logcon (F ("WiFi STA Failed to connect")); fsm_WiFi_state_ConnectionFailed_imp.Init (); } @@ -680,7 +673,6 @@ void fsm_WiFi_state_ConnectedToSta::Init () WiFiMgr.setIpAddress (WiFi.softAPIP ()); WiFiMgr.setIpSubNetMask (IPAddress (255, 255, 255, 0)); - LOG_PORT.println (""); logcon (String (F ("Connected to STA with IP: ")) + WiFiMgr.getIpAddress ().toString ()); WiFiMgr.SetIsWiFiConnected (true); diff --git a/ESPixelStick/src/WiFiMgr.hpp b/ESPixelStick/src/WiFiMgr.hpp index d217643e7..4f5a9d717 100644 --- a/ESPixelStick/src/WiFiMgr.hpp +++ b/ESPixelStick/src/WiFiMgr.hpp @@ -133,7 +133,7 @@ class fsm_WiFi_state_ConnectingUsingConfig : public fsm_WiFi_state virtual void Init (void); virtual void GetStateName (String& sName) { sName = F ("Connecting Using Config Credentials"); } virtual void OnConnect (void); - virtual void OnDisconnect (void) { LOG_PORT.print ("."); } + virtual void OnDisconnect (void) {} }; // fsm_WiFi_state_ConnectingUsingConfig @@ -145,7 +145,7 @@ class fsm_WiFi_state_ConnectingUsingDefaults : public fsm_WiFi_state virtual void Init (void); virtual void GetStateName (String& sName) { sName = F ("Connecting Using Default Credentials"); } virtual void OnConnect (void); - virtual void OnDisconnect (void) { LOG_PORT.print ("."); } + virtual void OnDisconnect (void) {} }; // fsm_WiFi_state_ConnectingUsingConfig @@ -169,7 +169,7 @@ class fsm_WiFi_state_ConnectingAsAP : public fsm_WiFi_state virtual void Init (void); virtual void GetStateName (String& sName) { sName = F ("Connecting As AP"); } virtual void OnConnect (void); - virtual void OnDisconnect (void) { LOG_PORT.print ("."); } + virtual void OnDisconnect (void) {} }; // fsm_WiFi_state_ConnectingAsAP diff --git a/ESPixelStick/src/input/InputMgr.cpp b/ESPixelStick/src/input/InputMgr.cpp index 4bcdf7980..ff96f6787 100644 --- a/ESPixelStick/src/input/InputMgr.cpp +++ b/ESPixelStick/src/input/InputMgr.cpp @@ -245,7 +245,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) void c_InputMgr::CreateNewConfig () { // DEBUG_START; - if (!InitializeConfig) + if (!IsBooting) { logcon (String (F ("--- WARNING: Creating a new Input Manager configuration Data set ---"))); } @@ -405,7 +405,7 @@ void c_InputMgr::InstantiateNewInputChannel (e_InputChannelIds ChannelIndex, e_I pInputChannelDrivers[ChannelIndex]->GetDriverName (DriverName); rebootNeeded |= pInputChannelDrivers[ChannelIndex]->isShutDownRebootNeeded(); // DEBUG_V (String ("rebootNeeded: ") + String (rebootNeeded)); - if (!InitializeConfig) { + if (!IsBooting) { logcon (String(F("Shutting Down '")) + DriverName + String(F("' on Input: ")) + String(ChannelIndex)); } @@ -534,7 +534,7 @@ void c_InputMgr::InstantiateNewInputChannel (e_InputChannelIds ChannelIndex, e_I default: { - if (!InitializeConfig) + if (!IsBooting) { logcon (CN_stars + String (F (" Unknown Input type for channel '")) + ChannelIndex + String(F ("'. Using disabled. ")) + CN_stars); } @@ -585,7 +585,7 @@ void c_InputMgr::LoadConfig () // DEBUG_V (""); })) { - if (!InitializeConfig) { + if (!IsBooting) { logcon (CN_stars + String (F (" Error loading Input Manager Config File ")) + CN_stars); } diff --git a/ESPixelStick/src/output/OutputMgr.cpp b/ESPixelStick/src/output/OutputMgr.cpp index 499e283b4..8da4cb5b4 100644 --- a/ESPixelStick/src/output/OutputMgr.cpp +++ b/ESPixelStick/src/output/OutputMgr.cpp @@ -276,11 +276,13 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) void c_OutputMgr::CreateNewConfig () { // DEBUG_START; - if (!InitializeConfig) + if (!IsBooting) { - logcon (String (F ("--- WARNING: Creating a new Output Manager configuration Data set ---"))); + logcon (String (F ("--- WARNING: Creating a new Output Manager configuration Data set ---"))); } + BuildingNewConfig = true; + // create a place to save the config DynamicJsonDocument JsonConfigDoc (OM_MAX_CONFIG_SIZE); // DEBUG_V (""); @@ -331,6 +333,9 @@ void c_OutputMgr::CreateNewConfig () // DEBUG_V (String ("ConfigData: ") + ConfigData); // logcon (String (F ("--- WARNING: Creating a new Output Manager configuration Data set - Done ---"))); + + BuildingNewConfig = true; + // DEBUG_END; } // CreateNewConfig @@ -411,7 +416,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, String DriverName; pOutputChannelDrivers[ChannelIndex]->GetDriverName (DriverName); - if (!InitializeConfig) + if (!IsBooting) { logcon (String (F (" Shutting Down '")) + DriverName + String (F ("' on Output: ")) + String (ChannelIndex)); } @@ -447,7 +452,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start DMX for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start DMX for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); break; @@ -464,7 +469,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start GECE for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start GECE for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); @@ -482,7 +487,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start Generic Serial for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start Generic Serial for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); @@ -500,9 +505,10 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start Renard for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start Renard for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); + break; } @@ -518,9 +524,10 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start RELAY for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start RELAY for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); + break; } @@ -535,7 +542,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, } // DEBUG_V (""); - logcon (CN_stars + String (F (" Cannot Start Servo PCA9685 for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start Servo PCA9685 for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); break; @@ -562,7 +569,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, break; } - logcon (CN_stars + String (F (" Cannot Start WS2811 for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start WS2811 for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); @@ -590,7 +597,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, break; } - logcon (CN_stars + String (F (" Cannot Start WS2811 for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start WS2811 for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); break; @@ -608,7 +615,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, break; } - logcon (CN_stars + String (F (" Cannot Start WS2801 for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start WS2801 for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); @@ -625,7 +632,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, break; } - logcon (CN_stars + String (F (" Cannot Start WS2801 for channel '")) + ChannelIndex + "'. " + CN_stars); + if (!BuildingNewConfig) { logcon (CN_stars + String (F (" Cannot Start WS2801 for channel '")) + ChannelIndex + "'. " + CN_stars); } pOutputChannelDrivers[ChannelIndex] = new c_OutputDisabled (ChannelIndex, dataPin, UartId, OutputType_Disabled); // DEBUG_V (""); @@ -636,7 +643,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, default: { - if (!InitializeConfig) + if (!IsBooting) { logcon (CN_stars + String (F (" Unknown output type: '")) + String (NewOutputChannelType) + String(F(" for channel '")) + ChannelIndex + String(F("'. Using disabled. ")) + CN_stars ); } @@ -649,7 +656,7 @@ void c_OutputMgr::InstantiateNewOutputChannel (e_OutputChannelIds ChannelIndex, // DEBUG_V (""); String sDriverName; pOutputChannelDrivers[ChannelIndex]->GetDriverName (sDriverName); - if (!InitializeConfig) + if (!IsBooting) { logcon ("'" + sDriverName + F ("' Initialization for Output: ") + String (ChannelIndex)); } @@ -690,7 +697,7 @@ void c_OutputMgr::LoadConfig () // DEBUG_V (""); })) { - if (!InitializeConfig) { + if (!IsBooting) { logcon (CN_stars + String (F (" Error loading Output Manager Config File ")) + CN_stars); } diff --git a/ESPixelStick/src/output/OutputMgr.hpp b/ESPixelStick/src/output/OutputMgr.hpp index b5f3ab27d..30fb45803 100644 --- a/ESPixelStick/src/output/OutputMgr.hpp +++ b/ESPixelStick/src/output/OutputMgr.hpp @@ -138,6 +138,7 @@ class c_OutputMgr bool HasBeenInitialized = false; bool ConfigLoadNeeded = false; bool IsOutputPaused = false; + bool BuildingNewConfig = false; bool ProcessJsonConfig (JsonObject & jsonConfig); void CreateJsonConfig (JsonObject & jsonConfig); diff --git a/ESPixelStick/src/output/OutputSerial.cpp b/ESPixelStick/src/output/OutputSerial.cpp index fc31c8beb..24d3366d6 100644 --- a/ESPixelStick/src/output/OutputSerial.cpp +++ b/ESPixelStick/src/output/OutputSerial.cpp @@ -441,7 +441,7 @@ void c_OutputSerial::Render () } // delayMicroseconds (1000000); -// LOG_PORT.println ("4"); +// DEBUG_V ("4"); // start the next frame switch (OutputType) diff --git a/ESPixelStick/src/output/OutputSpi.cpp b/ESPixelStick/src/output/OutputSpi.cpp index 372cfd350..8ac596691 100644 --- a/ESPixelStick/src/output/OutputSpi.cpp +++ b/ESPixelStick/src/output/OutputSpi.cpp @@ -42,7 +42,7 @@ static void IRAM_ATTR spi_transfer_callback (spi_transaction_t * param) } else { - LOG_PORT.println (F ("SPI User Parm is null.")); + logcon (F ("SPI User Parm is null.")); } } } // spi_transfer_callback From e4f3ca24f61361de84a13e31ec8f1934c854cb1c Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Mon, 11 Oct 2021 10:20:44 -0400 Subject: [PATCH 06/11] Updated a debug comment --- html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.html b/html/index.html index 445d4e950..20c722522 100644 --- a/html/index.html +++ b/html/index.html @@ -491,7 +491,7 @@