diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index c6dee0267..b1bda0a1f 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -173,7 +173,7 @@ void setup() // TestHeap(uint32_t(10)); // DEBUG_V(""); FileMgr.Begin(); - +#ifdef SUPPORT_CONFIG_MERGE if(FileMgr.FlashFileExists (RestoredConfigFileName)) { // DEBUG_V("Setting Restored Config flag to true"); @@ -183,6 +183,7 @@ void setup() { // DEBUG_V("Setting Restored Config flag to false"); } +#endif // def SUPPORT_CONFIG_MERGE // Load configuration from the File System and set Hostname // TestHeap(uint32_t(15)); // DEBUG_V(String("LoadConfig Heap: ") + String(ESP.getFreeHeap())); diff --git a/ESPixelStick/src/ConstNames.cpp b/ESPixelStick/src/ConstNames.cpp index c12034774..25eff2c61 100644 --- a/ESPixelStick/src/ConstNames.cpp +++ b/ESPixelStick/src/ConstNames.cpp @@ -63,6 +63,8 @@ const CN_PROGMEM char CN_Default [] = "Default"; const CN_PROGMEM char CN_device [] = "device"; const CN_PROGMEM char CN_dhcp [] = "dhcp"; const CN_PROGMEM char CN_Disabled [] = "Disabled"; +const CN_PROGMEM char CN_dnsp [] = "dnsp"; +const CN_PROGMEM char CN_dnss [] = "dnss"; const CN_PROGMEM char CN_DMX [] = "DMX"; const CN_PROGMEM char CN_Dotfseq [] = ".fseq"; const CN_PROGMEM char CN_Dotjson [] = ".json"; diff --git a/ESPixelStick/src/ConstNames.hpp b/ESPixelStick/src/ConstNames.hpp index ba9ddff8c..60c9611dd 100644 --- a/ESPixelStick/src/ConstNames.hpp +++ b/ESPixelStick/src/ConstNames.hpp @@ -72,6 +72,8 @@ extern const CN_PROGMEM char CN_device []; extern const CN_PROGMEM char CN_dhcp []; extern const CN_PROGMEM char CN_Default []; extern const CN_PROGMEM char CN_Disabled []; +extern const CN_PROGMEM char CN_dnsp []; +extern const CN_PROGMEM char CN_dnss []; extern const CN_PROGMEM char CN_Dotfseq []; extern const CN_PROGMEM char CN_Dotjson []; extern const CN_PROGMEM char CN_Dotpl []; diff --git a/ESPixelStick/src/input/InputMgr.cpp b/ESPixelStick/src/input/InputMgr.cpp index c71591456..4b076c3e4 100644 --- a/ESPixelStick/src/input/InputMgr.cpp +++ b/ESPixelStick/src/input/InputMgr.cpp @@ -265,13 +265,14 @@ void c_InputMgr::CreateNewConfig () // do we create a clean config or do we merge from a restored config? if(RestoredConfig) { - // DEBUG_V("Merge a Restored Config"); + DEBUG_V("Merge a Restored Input Config"); // read the existing file and add to it as needed FileMgr.ReadFlashFile(ConfigFileName, JsonConfigDoc); } if(!JsonConfigDoc.containsKey(CN_input_config)) { + DEBUG_V("Add missing input config fields"); JsonConfigDoc.createNestedObject(CN_input_config); } JsonObject JsonConfig = JsonConfigDoc[CN_input_config]; @@ -746,16 +747,16 @@ void c_InputMgr::ProcessButtonActions (c_ExternalInput::InputValue_t value) } // ProcessButtonActions //----------------------------------------------------------------------------- -/* - check the contents of the config and send - the proper portion of the config to the currently instantiated channels -*/ -bool c_InputMgr::ProcessJsonConfig (JsonObject & jsonConfig) +bool c_InputMgr::FindJsonChannelConfig (JsonObject& jsonConfig, + e_InputChannelIds ChanId, + JsonObject& ChanConfig) { // DEBUG_START; bool Response = false; + // DEBUG_V (); - // DEBUG_V ("InputDataBufferSize: " + String (InputDataBufferSize)); + // extern void PrettyPrint(JsonObject & jsonStuff, String Name); + // PrettyPrint(jsonConfig, "ProcessJsonConfig"); do // once { @@ -805,21 +806,52 @@ bool c_InputMgr::ProcessJsonConfig (JsonObject & jsonConfig) JsonObject InputChannelArray = InputChannelMgrData[CN_channels]; // DEBUG_V (""); + // get access to the channel config + if (false == InputChannelArray.containsKey (String (ChanId))) + { + // if not, flag an error and stop processing + logcon (String (F ("No Input Settings Found for Channel '")) + ChanId + String (F ("'. Using Defaults"))); + continue; + } + ChanConfig = InputChannelArray[String(ChanId)]; + // DEBUG_V (); + + // all went well + Response = true; + + } while (false); + + // DEBUG_END; + return Response; + +} // FindChannelJsonConfig + +//----------------------------------------------------------------------------- +/* + check the contents of the config and send + the proper portion of the config to the currently instantiated channels +*/ +bool c_InputMgr::ProcessJsonConfig (JsonObject & jsonConfig) +{ + // DEBUG_START; + bool Response = false; + + // DEBUG_V ("InputDataBufferSize: " + String (InputDataBufferSize)); + + do // once + { // for each Input channel for (uint32_t ChannelIndex = uint32_t (InputChannelId_Start); ChannelIndex < uint32_t (InputChannelId_End); ChannelIndex++) { - // get access to the channel config - if (false == InputChannelArray.containsKey (String (ChannelIndex))) + JsonObject InputChannelConfig; + // DEBUG_V (""); + if(!FindJsonChannelConfig(jsonConfig, e_InputChannelIds(ChannelIndex), InputChannelConfig)) { - // if not, flag an error and stop processing - logcon (String (F ("No Input Settings Found for Channel '")) + ChannelIndex + String (F ("'. Using Defaults"))); + DEBUG_V("Did not find the desired channel configuration"); continue; } - JsonObject InputChannelConfig = InputChannelArray[String (ChannelIndex)]; - // DEBUG_V (""); - // set a default value for channel type uint32_t ChannelType = uint32_t (InputType_Default); setFromJSON (ChannelType, InputChannelConfig, CN_type); diff --git a/ESPixelStick/src/input/InputMgr.hpp b/ESPixelStick/src/input/InputMgr.hpp index 8f1a18eaf..040ddb320 100644 --- a/ESPixelStick/src/input/InputMgr.hpp +++ b/ESPixelStick/src/input/InputMgr.hpp @@ -111,6 +111,7 @@ class c_InputMgr void CreateJsonConfig (JsonObject & jsonConfig); bool ProcessJsonChannelConfig (JsonObject & jsonConfig, uint32_t ChannelIndex); bool InputTypeIsAllowedOnChannel (e_InputType type, e_InputChannelIds ChannelId); + bool FindJsonChannelConfig (JsonObject& jsonConfig, e_InputChannelIds ChanId, JsonObject& ChanConfig); String ConfigFileName; bool rebootNeeded = false; diff --git a/ESPixelStick/src/network/EthernetDriver.cpp b/ESPixelStick/src/network/EthernetDriver.cpp index cb6b18d51..cbdbdd035 100644 --- a/ESPixelStick/src/network/EthernetDriver.cpp +++ b/ESPixelStick/src/network/EthernetDriver.cpp @@ -131,6 +131,8 @@ void c_EthernetDriver::GetConfig (JsonObject& json) json[CN_ip] = ip.toString (); json[CN_netmask] = netmask.toString (); json[CN_gateway] = gateway.toString (); + json[CN_dnsp] = primaryDns.toString (); + json[CN_dnss] = secondaryDns.toString (); json[CN_dhcp] = UseDhcp; json[CN_type] = phy_type; @@ -321,10 +323,14 @@ bool c_EthernetDriver::SetConfig (JsonObject & json) String sIP = ip.toString (); String sGateway = gateway.toString (); String sNetmask = netmask.toString (); + String sDnsp = primaryDns.toString (); + String sDnss = secondaryDns.toString (); ConfigChanged |= setFromJSON (sIP, json, CN_ip); ConfigChanged |= setFromJSON (sNetmask, json, CN_netmask); ConfigChanged |= setFromJSON (sGateway, json, CN_gateway); + ConfigChanged |= setFromJSON (sDnsp, json, CN_dnsp); + ConfigChanged |= setFromJSON (sDnss, json, CN_dnss); ConfigChanged |= setFromJSON (UseDhcp, json, CN_dhcp); ConfigChanged |= setFromJSON (phy_addr, json, CN_addr); @@ -339,7 +345,9 @@ bool c_EthernetDriver::SetConfig (JsonObject & json) ip.fromString (sIP); gateway.fromString (sGateway); netmask.fromString (sNetmask); - + primaryDns.fromString (sDnsp); + secondaryDns.fromString (sDnss); + // DEBUG_V (String (" sip: ") + ip.toString ()); // DEBUG_V (String ("sgateway: ") + gateway.toString ()); // DEBUG_V (String ("snetmask: ") + netmask.toString ()); @@ -397,10 +405,14 @@ void c_EthernetDriver::SetUpIp () // DEBUG_V ("netmask: " + netmask.toString ()); // DEBUG_V ("gateway: " + gateway.toString ()); + if(primaryDns == INADDR_NONE) + { + primaryDns = gateway; + } // We didn't use DNS, so just set it to our configured gateway // https://github.com/espressif/arduino-esp32/issues/5733 - add delay delay(100); - ETH.config (ip, gateway, netmask, gateway); + ETH.config (ip, gateway, netmask, primaryDns, secondaryDns); logcon (F ("Connecting to Ethernet with Static IP")); diff --git a/ESPixelStick/src/network/EthernetDriver.hpp b/ESPixelStick/src/network/EthernetDriver.hpp index dd6e35264..861187c91 100644 --- a/ESPixelStick/src/network/EthernetDriver.hpp +++ b/ESPixelStick/src/network/EthernetDriver.hpp @@ -88,6 +88,8 @@ class c_EthernetDriver IPAddress ip = INADDR_NONE; IPAddress netmask = INADDR_NONE; IPAddress gateway = INADDR_NONE; + IPAddress primaryDns = INADDR_NONE; + IPAddress secondaryDns = INADDR_NONE; bool UseDhcp = true; uint32_t phy_addr = DEFAULT_ETH_ADDR; gpio_num_t power_pin = DEFAULT_ETH_POWER_PIN; diff --git a/ESPixelStick/src/network/WiFiDriver.cpp b/ESPixelStick/src/network/WiFiDriver.cpp index 231c875b5..da2ebbbba 100644 --- a/ESPixelStick/src/network/WiFiDriver.cpp +++ b/ESPixelStick/src/network/WiFiDriver.cpp @@ -327,10 +327,16 @@ void c_WiFiDriver::GetConfig (JsonObject& json) json[CN_netmask] = Temp.toString (); Temp = gateway; json[CN_gateway] = Temp.toString (); + Temp = primaryDns; + json[CN_dnsp] = Temp.toString (); + Temp = secondaryDns; + json[CN_dnss] = Temp.toString (); #else json[CN_ip] = ip.toString (); json[CN_netmask] = netmask.toString (); json[CN_gateway] = gateway.toString (); + json[CN_dnsp] = primaryDns.toString (); + json[CN_dnss] = secondaryDns.toString (); #endif // !def ARDUINO_ARCH_ESP8266 json[CN_StayInApMode] = StayInApMode; @@ -481,11 +487,16 @@ bool c_WiFiDriver::SetConfig (JsonObject & json) String sIp = ip.toString (); String sGateway = gateway.toString (); String sNetmask = netmask.toString (); + String sdnsp = primaryDns.toString (); + String sdnss = secondaryDns.toString (); + ConfigChanged |= setFromJSON (ssid, json, CN_ssid); ConfigChanged |= setFromJSON (passphrase, json, CN_passphrase); ConfigChanged |= setFromJSON (sIp, json, CN_ip); ConfigChanged |= setFromJSON (sNetmask, json, CN_netmask); ConfigChanged |= setFromJSON (sGateway, json, CN_gateway); + ConfigChanged |= setFromJSON (sdnsp, json, CN_dnsp); + ConfigChanged |= setFromJSON (sdnss, json, CN_dnss); ConfigChanged |= setFromJSON (UseDhcp, json, CN_dhcp); ConfigChanged |= setFromJSON (ap_ssid, json, CN_ap_ssid); ConfigChanged |= setFromJSON (ap_passphrase, json, CN_ap_passphrase); @@ -507,6 +518,8 @@ bool c_WiFiDriver::SetConfig (JsonObject & json) ip.fromString (sIp); gateway.fromString (sGateway); netmask.fromString (sNetmask); + primaryDns.fromString (sdnsp); + secondaryDns.fromString (sdnss); if((passphrase.length() < 8) && (passphrase.length() > 0)) { @@ -591,8 +604,15 @@ void c_WiFiDriver::SetUpIp () // correct IP is already set break; } + + // use gateway if primary DNS is not defined + if(primaryDns == INADDR_NONE) + { + primaryDns = gateway; + } + // We didn't use DNS, so just set it to our configured gateway - WiFi.config (ip, gateway, netmask, gateway); + WiFi.config (ip, gateway, netmask, primaryDns, secondaryDns); logcon (F ("Using Static IP")); diff --git a/ESPixelStick/src/network/WiFiDriver.hpp b/ESPixelStick/src/network/WiFiDriver.hpp index 31bab0825..1628fc9ba 100644 --- a/ESPixelStick/src/network/WiFiDriver.hpp +++ b/ESPixelStick/src/network/WiFiDriver.hpp @@ -105,9 +105,11 @@ class c_WiFiDriver String passphrase; String ap_ssid; String ap_passphrase; - IPAddress ip = IPAddress ((uint32_t)0); - IPAddress netmask = IPAddress ((uint32_t)0); - IPAddress gateway = IPAddress ((uint32_t)0); + IPAddress ip = INADDR_NONE; + IPAddress netmask = INADDR_NONE; + IPAddress gateway = INADDR_NONE; + IPAddress primaryDns = INADDR_NONE; + IPAddress secondaryDns = INADDR_NONE; bool UseDhcp = true; uint8_t ap_channelNumber = 1; bool ap_fallbackIsEnabled = true; diff --git a/ESPixelStick/src/output/OutputMgr.cpp b/ESPixelStick/src/output/OutputMgr.cpp index 4a6371d5a..1e6dc58d9 100644 --- a/ESPixelStick/src/output/OutputMgr.cpp +++ b/ESPixelStick/src/output/OutputMgr.cpp @@ -245,7 +245,7 @@ void c_OutputMgr::Begin () if (0 == OutputChannelId_End) { - logcon("ERROR: No output Channels defined. Rebooting"); + logcon("ERROR: No compiled output Channels defined. Rebooting"); RequestReboot(100000); break; } @@ -267,15 +267,15 @@ void c_OutputMgr::Begin () // DEBUG_V(String("init index: ") + String(index) + " Done"); } + // DEBUG_V("load up the configuration from the saved file. This also starts the drivers"); + LoadConfig(); + if(RestoredConfig) { // DEBUG_V("create a merged config"); CreateNewConfig(); } - // DEBUG_V("load up the configuration from the saved file. This also starts the drivers"); - LoadConfig(); - // Preset the output memory memset((void*)&OutputBuffer[0], 0x00, sizeof(OutputBuffer)); @@ -293,7 +293,7 @@ void c_OutputMgr::Begin () //----------------------------------------------------------------------------- void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) { - // DEBUG_START; + DEBUG_START; // extern void PrettyPrint (JsonObject&, String); // PrettyPrint (jsonConfig, String ("jsonConfig")); @@ -320,13 +320,12 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) String sChannelId = String(CurrentChannel.pOutputChannelDriver->GetOutputChannelId()); if (true == OutputMgrChannelsData.containsKey (sChannelId)) { - // DEBUG_V (); + // DEBUG_V (String("Channel Exists: ") + sChannelId); ChannelConfigData = OutputMgrChannelsData[sChannelId]; } else { - // add our section header - // DEBUG_V (); + // DEBUG_V (String ("add our channel section header. Chan: ") + sChannelId); ChannelConfigData = OutputMgrChannelsData.createNestedObject (sChannelId); } @@ -337,13 +336,12 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) JsonObject ChannelConfigByTypeData; if (true == ChannelConfigData.containsKey (String (DriverTypeId))) { + // DEBUG_V (String("Channel Type Data exists for chan: ") + sChannelId + " Type: " + DriverTypeId); ChannelConfigByTypeData = ChannelConfigData[DriverTypeId]; - // DEBUG_V (); } else { - // add our section header - // DEBUG_V (); + // DEBUG_V (String("Add Channel Type Data for chan: ") + sChannelId + " Type: " + DriverTypeId); ChannelConfigByTypeData = ChannelConfigData.createNestedObject (DriverTypeId); } @@ -356,7 +354,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) // Populate the driver name String DriverName = ""; CurrentChannel.pOutputChannelDriver->GetDriverName(DriverName); - // DEBUG_V (String ("DriverName: ") + DriverName); + DEBUG_V (String ("DriverName: ") + DriverName); ChannelConfigByTypeData[CN_type] = DriverName; @@ -376,7 +374,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) // PrettyPrint (jsonConfig, String ("jsonConfig")); // smile. Your done - // DEBUG_END; + DEBUG_END; } // CreateJsonConfig //----------------------------------------------------------------------------- @@ -403,11 +401,13 @@ void c_OutputMgr::CreateNewConfig () { logcon("Merging Restored Output Config File"); FileMgr.ReadFlashFile(ConfigFileName, JsonConfigDoc); + // extern void PrettyPrint(DynamicJsonDocument & jsonStuff, String Name); + // PrettyPrint(JsonConfigDoc, "New OutputMgr"); } if(!JsonConfigDoc.containsKey(CN_output_config)) { - // DEBUG_V("Create a new output config area."); + DEBUG_V("Create a new output config structure."); JsonConfigDoc.createNestedObject (CN_output_config); } JsonObject JsonConfig = JsonConfigDoc[CN_output_config]; @@ -416,7 +416,24 @@ void c_OutputMgr::CreateNewConfig () JsonConfig[CN_cfgver] = CurrentConfigVersion; JsonConfig[CN_MaxChannels] = sizeof(OutputBuffer); - // Collect the all ports disabled config first + e_OutputType SavedOutputTypes[OutputChannelId_End]; + DEBUG_V("Collect the restored config channel types"); + for (DriverInfo_t & CurrentOutputChannelDriver : OutputChannelDrivers) + { + e_OutputChannelIds ChanId = CurrentOutputChannelDriver.DriverId; + + JsonObject OutputChannelConfig; + if(!FindJsonChannelConfig(JsonConfigDoc, ChanId, e_OutputType::OutputType_End, OutputChannelConfig)) + { + DEBUG_V(String("Could not find channel config for channel: ") + String(ChanId)); + continue; + } + + setFromJSON (SavedOutputTypes[ChanId], OutputChannelConfig, CN_type); + DEBUG_V(String("Saved channel: ") + String(ChanId) + " Type: " + String(SavedOutputTypes[ChanId])); + } + + DEBUG_V("Collect the all ports disabled config first"); CreateJsonConfig (JsonConfig); // DEBUG_V ("for each output type"); @@ -428,6 +445,34 @@ void c_OutputMgr::CreateNewConfig () { // DEBUG_V (String("DriverId: ") + String(CurrentOutputChannelDriver.DriverId)); InstantiateNewOutputChannel(CurrentOutputChannelDriver, CurrentOutputType.id, false); + if(RestoredConfig) + { + JsonObject OutputChannelConfig; + if(!FindJsonChannelConfig(JsonConfigDoc, CurrentOutputChannelDriver.DriverId, e_OutputType::OutputType_End, OutputChannelConfig)) + { + DEBUG_V(String("Could not find channel config for channel: ") + String(CurrentOutputChannelDriver.DriverId)); + } + else + { + uint32_t ChannelType = CurrentOutputType.id; + // DEBUG_V (); + + // do we have a configuration for the channel type? + if (false == OutputChannelConfig.containsKey (String (ChannelType))) + { + // if not, flag an error and stop processing + continue; + } + + DEBUG_V (); + + JsonObject OutputChannelDriverConfig = OutputChannelConfig[String (ChannelType)]; + // PrettyPrint(OutputChannelConfig, "ProcessJson Channel Config"); + + CurrentOutputChannelDriver.pOutputChannelDriver->SetConfig(OutputChannelDriverConfig); + } + } + // DEBUG_V (); } // end for each interface @@ -449,11 +494,24 @@ void c_OutputMgr::CreateNewConfig () // DEBUG_V (); } // end for each output type - // DEBUG_V ("leave the outputs disabled"); - for (auto & CurrentOutputChannelDriver : OutputChannelDrivers) + if(RestoredConfig) + { + DEBUG_V ("Restore the outputs"); + for (DriverInfo_t & CurrentOutputChannelDriver : OutputChannelDrivers) + { + InstantiateNewOutputChannel(CurrentOutputChannelDriver, + SavedOutputTypes[CurrentOutputChannelDriver.DriverId], + false); + } + } + else { - InstantiateNewOutputChannel(CurrentOutputChannelDriver, e_OutputType::OutputType_Disabled); - }// end for each interface + // DEBUG_V ("leave the outputs disabled"); + for (auto & CurrentOutputChannelDriver : OutputChannelDrivers) + { + InstantiateNewOutputChannel(CurrentOutputChannelDriver, e_OutputType::OutputType_Disabled); + }// end for each interface + } // PrettyPrint(JsonConfig, "Complete OutputMgr"); @@ -1022,12 +1080,10 @@ void c_OutputMgr::LoadConfig () // PrettyPrint(JsonConfigDoc, "OM Load Config"); // DEBUG_V (); - JsonObject JsonConfig = JsonConfigDoc.as (); - // extern void PrettyPrint(JsonObject & jsonStuff, String Name); // PrettyPrint(JsonConfig, "OM Load Config"); // DEBUG_V (); - this->ProcessJsonConfig(JsonConfig); + this->ProcessJsonConfig(JsonConfigDoc); // DEBUG_V (); })) { @@ -1051,21 +1107,13 @@ void c_OutputMgr::LoadConfig () } // LoadConfig //----------------------------------------------------------------------------- -/* - check the contents of the config and send - the proper portion of the config to the currently instantiated channels - - needs - ref to data from config file - returns - true - config was properly processes - false - config had an error. -*/ -bool c_OutputMgr::ProcessJsonConfig (JsonObject& jsonConfig) +bool c_OutputMgr::FindJsonChannelConfig (DynamicJsonDocument& jsonConfig, + e_OutputChannelIds ChanId, + e_OutputType Type, + JsonObject& ChanConfig) { // DEBUG_START; bool Response = false; - // DEBUG_V (); // extern void PrettyPrint(JsonObject & jsonStuff, String Name); @@ -1073,9 +1121,9 @@ bool c_OutputMgr::ProcessJsonConfig (JsonObject& jsonConfig) do // once { - if (false == jsonConfig.containsKey (CN_output_config)) + if (!jsonConfig.containsKey (CN_output_config)) { - logcon(String(MN_16) + MN_18); + logcon(String(MN_16) + MN_18); break; } JsonObject OutputChannelMgrData = jsonConfig[CN_output_config]; @@ -1095,7 +1143,7 @@ bool c_OutputMgr::ProcessJsonConfig (JsonObject& jsonConfig) } // do we have a channel configuration array? - if (false == OutputChannelMgrData.containsKey (CN_channels)) + if (!OutputChannelMgrData.containsKey (CN_channels)) { // if not, flag an error and stop processing logcon(String(MN_16) + MN_18); @@ -1104,17 +1152,75 @@ bool c_OutputMgr::ProcessJsonConfig (JsonObject& jsonConfig) JsonObject OutputChannelArray = OutputChannelMgrData[CN_channels]; // DEBUG_V (); + // get access to the channel config + if (false == OutputChannelArray.containsKey(String(ChanId))) + { + // if not, flag an error and stop processing + logcon(String(MN_16) + ChanId + MN_18); + break; + } + + // do we need to go deeper into the config? + if(e_OutputType::OutputType_End == Type) + { + // only looking for the overall channel config + ChanConfig = OutputChannelArray[String(ChanId)]; + Response = true; + break; + } + // go deeper and get the config for the specific channel type + + // DEBUG_V (); + JsonObject OutputChannelConfig = OutputChannelArray[String(ChanId)]; + + // do we have a configuration for the channel type? + if (!OutputChannelConfig.containsKey (String (Type))) + { + // Not found + logcon(String(MN_16) + ChanId + MN_18); + break; + } + + // DEBUG_V (); + // PrettyPrint(OutputChannelConfig, "ProcessJson Channel Config"); + + ChanConfig = OutputChannelConfig[String (Type)]; + // DEBUG_V (); + // PrettyPrint(ChanConfig, "ProcessJson Channel Driver Config before driver create"); + // DEBUG_V (); + + // all went well + Response = true; + + } while (false); + + // DEBUG_END; + return Response; + +} // FindChannelJsonConfig + +//----------------------------------------------------------------------------- +bool c_OutputMgr::ProcessJsonConfig (DynamicJsonDocument& jsonConfig) +{ + // DEBUG_START; + bool Response = false; + + // DEBUG_V (); + + // extern void PrettyPrint(JsonObject & jsonStuff, String Name); + // PrettyPrint(jsonConfig, "ProcessJsonConfig"); + + do // once + { // for each output channel for (auto & CurrentOutputChannelDriver : OutputChannelDrivers) { - // get access to the channel config - if (false == OutputChannelArray.containsKey(String(CurrentOutputChannelDriver.DriverId).c_str())) + JsonObject OutputChannelConfig; + if(!FindJsonChannelConfig (jsonConfig, CurrentOutputChannelDriver.DriverId, e_OutputType::OutputType_End, OutputChannelConfig)) { - // if not, flag an error and stop processing - logcon(String(MN_16) + CurrentOutputChannelDriver.DriverId + MN_18); - break; + DEBUG_V(String("cant find config for channel: ") + String(CurrentOutputChannelDriver.DriverId)); + continue; } - JsonObject OutputChannelConfig = OutputChannelArray[String(CurrentOutputChannelDriver.DriverId).c_str()]; // DEBUG_V (); // extern void PrettyPrint (JsonObject& jsonStuff, String Name); diff --git a/ESPixelStick/src/output/OutputMgr.hpp b/ESPixelStick/src/output/OutputMgr.hpp index d583ba04a..15d8ee205 100644 --- a/ESPixelStick/src/output/OutputMgr.hpp +++ b/ESPixelStick/src/output/OutputMgr.hpp @@ -192,12 +192,11 @@ class c_OutputMgr # define OM_MAX_NUM_CHANNELS (1200 * 3) # define OM_MAX_CONFIG_SIZE ((uint32_t)(3 * 1024)) #else // ARDUINO_ARCH_ESP32 +# define OM_MAX_CONFIG_SIZE ((uint32_t)(20 * 1024)) # ifdef BOARD_HAS_PSRAM # define OM_MAX_NUM_CHANNELS (7000 * 3) -# define OM_MAX_CONFIG_SIZE ((uint32_t)(20 * 1024)) # else # define OM_MAX_NUM_CHANNELS (3000 * 3) -# define OM_MAX_CONFIG_SIZE ((uint32_t)(13 * 1024)) # endif // !def BOARD_HAS_PSRAM #endif // !def ARDUINO_ARCH_ESP32 @@ -239,12 +238,13 @@ class c_OutputMgr bool IsOutputPaused = false; bool BuildingNewConfig = false; - bool ProcessJsonConfig (JsonObject & jsonConfig); + bool ProcessJsonConfig (DynamicJsonDocument & jsonConfig); void CreateJsonConfig (JsonObject & jsonConfig); void UpdateDisplayBufferReferences (void); void InstantiateNewOutputChannel(DriverInfo_t &ChannelIndex, e_OutputType NewChannelType, bool StartDriver = true); void CreateNewConfig(); void SetSerialUart(); + bool FindJsonChannelConfig (DynamicJsonDocument& jsonConfig, e_OutputChannelIds ChanId, e_OutputType Type, JsonObject& ChanConfig); String ConfigFileName; diff --git a/html/index.html b/html/index.html index ff023c63e..31dc8a8f5 100644 --- a/html/index.html +++ b/html/index.html @@ -471,6 +471,24 @@ value="0.0.0.0" title="Static Gateway"> +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+