diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index 281c15f3f..6c335bcff 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -128,7 +128,7 @@ void TestHeap(uint32_t Id) DEBUG_V(String("Allocate JSON document. Size = ") + String(20 * 1024)); DEBUG_V(String("Heap Before: ") + ESP.getFreeHeap()); { - DynamicJsonDocument jsonDoc(20 * 1024); + JsonDocument jsonDoc; } DEBUG_V(String(" Heap After: ") + ESP.getFreeHeap()); } @@ -371,11 +371,11 @@ bool deserializeCore (JsonObject & json) return DataHasBeenAccepted; } -void deserializeCoreHandler (DynamicJsonDocument & jsonDoc) +void deserializeCoreHandler (JsonDocument & jsonDoc) { // DEBUG_START; - // extern void PrettyPrint(DynamicJsonDocument & jsonStuff, String Name); + // extern void PrettyPrint(JsonDocument & jsonStuff, String Name); // PrettyPrint(jsonDoc, "deserializeCoreHandler"); JsonObject json = jsonDoc.as(); @@ -392,8 +392,8 @@ void SaveConfig() ConfigSaveNeeded = false; // Create buffer and root object - DynamicJsonDocument jsonConfigDoc(2048); - JsonObject JsonConfig = jsonConfigDoc.createNestedObject(CN_system); + JsonDocument jsonConfigDoc; + JsonObject JsonConfig = jsonConfigDoc[CN_system].to(); GetConfig(JsonConfig); @@ -438,7 +438,7 @@ void GetConfig (JsonObject & json) json[CN_cfgver] = CurrentConfigVersion; // Device - JsonObject device = json.createNestedObject(CN_device); + JsonObject device = json[CN_device].to(); device[CN_id] = config.id; device[CN_blanktime] = config.BlankDelay; @@ -459,8 +459,8 @@ String serializeCore(bool pretty) // DEBUG_START; // Create buffer and root object - DynamicJsonDocument jsonConfigDoc(2048); - JsonObject JsonConfig = jsonConfigDoc.createNestedObject(); + JsonDocument jsonConfigDoc; + JsonObject JsonConfig = jsonConfigDoc.add(); String jsonConfigString; diff --git a/ESPixelStick/src/ESPixelStick.h b/ESPixelStick/src/ESPixelStick.h index e8bd29591..3c800217e 100644 --- a/ESPixelStick/src/ESPixelStick.h +++ b/ESPixelStick/src/ESPixelStick.h @@ -72,7 +72,7 @@ typedef struct { } config_t; String serializeCore (bool pretty = false); -void deserializeCoreHandler (DynamicJsonDocument& jsonDoc); +void deserializeCoreHandler (JsonDocument& jsonDoc); bool deserializeCore (JsonObject & json); bool dsDevice (JsonObject & json); bool dsNetwork (JsonObject & json); diff --git a/ESPixelStick/src/FileMgr.cpp b/ESPixelStick/src/FileMgr.cpp index 1c6abf231..10eeb1730 100644 --- a/ESPixelStick/src/FileMgr.cpp +++ b/ESPixelStick/src/FileMgr.cpp @@ -606,21 +606,9 @@ bool c_FileMgr::LoadFlashFile (const String& FileName, DeserializationHandler Ha size_t JsonDocSize = file.size () * 3; // DEBUG_V(String("Allocate JSON document. Size = ") + String(JsonDocSize)); // DEBUG_V(String("Heap: ") + ESP.getFreeHeap()); - DynamicJsonDocument jsonDoc(JsonDocSize); + JsonDocument jsonDoc; // DEBUG_V(String("jsonDoc.capacity: ") + String(jsonDoc.capacity())); - // did we get enough memory? - if(jsonDoc.capacity() < JsonDocSize) - { - logcon (String(CN_stars) + CfgFileMessagePrefix + String (F ("Could Not Allocate enough memory to process config ")) + CN_stars); - - // DEBUG_V(String("Allocate JSON document. Size = ") + String(JsonDocSize)); - // DEBUG_V(String("Heap: ") + ESP.getFreeHeap()); - // DEBUG_V(String("jsonDoc.capacity: ") + String(jsonDoc.capacity())); - file.close (); - break; - } - // DEBUG_V ("Convert File to JSON document"); DeserializationError error = deserializeJson (jsonDoc, file); file.close (); @@ -639,12 +627,10 @@ bool c_FileMgr::LoadFlashFile (const String& FileName, DeserializationHandler Ha break; } - // extern void PrettyPrint(DynamicJsonDocument & jsonStuff, String Name); + // extern void PrettyPrint(JsonDocument & jsonStuff, String Name); // PrettyPrint(jsonDoc, CfgFileMessagePrefix); // DEBUG_V (); - jsonDoc.garbageCollect (); - logcon (CfgFileMessagePrefix + String (F ("loaded."))); // DEBUG_V (); diff --git a/ESPixelStick/src/FileMgr.hpp b/ESPixelStick/src/FileMgr.hpp index 6d6e22e46..68944e829 100644 --- a/ESPixelStick/src/FileMgr.hpp +++ b/ESPixelStick/src/FileMgr.hpp @@ -58,7 +58,7 @@ class c_FileMgr bool handleFileUpload (const String & filename, size_t index, uint8_t * data, size_t len, bool final, uint32_t totalLen); - typedef std::function DeserializationHandler; + typedef std::function DeserializationHandler; typedef enum { diff --git a/ESPixelStick/src/WebMgr.cpp b/ESPixelStick/src/WebMgr.cpp index db3db56a4..4cff28798 100644 --- a/ESPixelStick/src/WebMgr.cpp +++ b/ESPixelStick/src/WebMgr.cpp @@ -45,7 +45,7 @@ static EFUpdate efupdate; /// EFU Update Handler static AsyncWebServer webServer (HTTP_PORT); // Web Server //----------------------------------------------------------------------------- -void PrettyPrint(DynamicJsonDocument &jsonStuff, String Name) +void PrettyPrint(JsonDocument &jsonStuff, String Name) { // DEBUG_V ("---------------------------------------------"); LOG_PORT.println (String (F ("---- Pretty Print: '")) + Name + "'"); @@ -557,14 +557,9 @@ void c_WebMgr::GetDeviceOptions () // set up a framework to get the option data WebJsonDoc->clear (); - if (0 == WebJsonDoc->capacity ()) - { - logcon (F ("ERROR: Failed to allocate memory for the GetDeviceOptions web request response.")); - } - // DEBUG_V (""); - JsonObject WebOptions = WebJsonDoc->createNestedObject (F ("options")); - JsonObject JsonDeviceOptions = WebOptions.createNestedObject (CN_device); + JsonObject WebOptions = (*WebJsonDoc)[F ("options")].to(); + JsonObject JsonDeviceOptions = WebOptions[CN_device].to (); // DEBUG_V(""); // PrettyPrint (WebOptions); @@ -585,8 +580,8 @@ void c_WebMgr::CreateAdminInfoFile () { // DEBUG_START; - DynamicJsonDocument AdminJsonDoc(1024); - JsonObject jsonAdmin = AdminJsonDoc.createNestedObject (F ("admin")); + JsonDocument AdminJsonDoc; + JsonObject jsonAdmin = AdminJsonDoc[F ("admin")].to (); jsonAdmin[CN_version] = VERSION; jsonAdmin["built"] = BUILD_DATE; @@ -722,10 +717,10 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client) { // DEBUG_START; - DynamicJsonDocument WebJsonDoc(STATUS_DOC_SIZE); + JsonDocument WebJsonDoc; WebJsonDoc.clear (); - JsonObject status = WebJsonDoc.createNestedObject (CN_status); - JsonObject system = status.createNestedObject (CN_system); + JsonObject status = WebJsonDoc[CN_status].to (); + JsonObject system = status[CN_system].to (); system[F ("freeheap")] = ESP.getFreeHeap (); system[F ("uptime")] = millis (); diff --git a/ESPixelStick/src/WebMgr.hpp b/ESPixelStick/src/WebMgr.hpp index 94dc017a5..db6f2e3cb 100644 --- a/ESPixelStick/src/WebMgr.hpp +++ b/ESPixelStick/src/WebMgr.hpp @@ -95,7 +95,7 @@ class c_WebMgr using WebJsonDocument = BasicJsonDocument; #else - using WebJsonDocument = DynamicJsonDocument; + using WebJsonDocument = JsonDocument; #endif // def BOARD_HAS_PSRAM WebJsonDocument *WebJsonDoc = nullptr; diff --git a/ESPixelStick/src/input/InputAlexa.cpp b/ESPixelStick/src/input/InputAlexa.cpp index e64a0856c..cf5b92e53 100644 --- a/ESPixelStick/src/input/InputAlexa.cpp +++ b/ESPixelStick/src/input/InputAlexa.cpp @@ -95,10 +95,6 @@ void c_InputAlexa::GetConfig (JsonObject & jsonConfig) void c_InputAlexa::GetStatus (JsonObject& /* jsonStatus */) { // DEBUG_START; - - // JsonObject mqttStatus = jsonStatus.createNestedObject (F ("mqtt")); - // mqttStatus["unifirst"] = startUniverse; - // DEBUG_END; } // GetStatus @@ -170,8 +166,8 @@ void c_InputAlexa::onMessage(EspalexaDevice * pDevice) // DEBUG_V (String ("pDevice->getG: ") + String (pDevice->getG ())); // DEBUG_V (String ("pDevice->getB: ") + String (pDevice->getB ())); - DynamicJsonDocument JsonConfigDoc (1024); - JsonObject JsonConfig = JsonConfigDoc.createNestedObject (CN_config); + JsonDocument JsonConfigDoc; + JsonObject JsonConfig = JsonConfigDoc[CN_config].to (); JsonConfig[CN_EffectSpeed] = 1; JsonConfig[CN_EffectReverse] = false; diff --git a/ESPixelStick/src/input/InputArtnet.cpp b/ESPixelStick/src/input/InputArtnet.cpp index 54672a3ae..33eaaab1b 100644 --- a/ESPixelStick/src/input/InputArtnet.cpp +++ b/ESPixelStick/src/input/InputArtnet.cpp @@ -85,7 +85,7 @@ void c_InputArtnet::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - JsonObject ArtnetStatus = jsonStatus.createNestedObject (F ("Artnet")); + JsonObject ArtnetStatus = jsonStatus[F ("Artnet")].to (); ArtnetStatus[CN_unifirst] = startUniverse; ArtnetStatus[CN_unilast] = LastUniverse; ArtnetStatus[CN_unichanlim] = ChannelsPerUniverse; @@ -97,11 +97,11 @@ void c_InputArtnet::GetStatus (JsonObject & jsonStatus) ArtnetStatus[CN_last_clientIP] = pArtnet->getRemoteIP().toString (); ArtnetStatus[CN_PollCounter] = PollCounter; - JsonArray ArtnetUniverseStatus = ArtnetStatus.createNestedArray (CN_channels); + JsonArray ArtnetUniverseStatus = ArtnetStatus[CN_channels].to (); for (auto & CurrentUniverse : UniverseArray) { - JsonObject ArtnetCurrentUniverseStatus = ArtnetUniverseStatus.createNestedObject (); + JsonObject ArtnetCurrentUniverseStatus = ArtnetUniverseStatus.add (); ArtnetCurrentUniverseStatus[CN_errors] = CurrentUniverse.SequenceErrorCounter; ArtnetCurrentUniverseStatus[CN_num_packets] = CurrentUniverse.num_packets; diff --git a/ESPixelStick/src/input/InputDDP.cpp b/ESPixelStick/src/input/InputDDP.cpp index 11957916a..f348d9714 100644 --- a/ESPixelStick/src/input/InputDDP.cpp +++ b/ESPixelStick/src/input/InputDDP.cpp @@ -89,7 +89,7 @@ void c_InputDDP::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject ddpStatus = jsonStatus.createNestedObject (F ("ddp")); + JsonObject ddpStatus = jsonStatus[F ("ddp")].to (); // DEBUG_V (""); ddpStatus["packetsreceived"] = stats.packetsReceived; @@ -317,8 +317,8 @@ void c_InputDDP::ProcessReceivedQuery () { // DEBUG_V ("DDP_ID_CONFIG query"); - DynamicJsonDocument JsonConfigDoc (2048); - JsonObject JsonConfig = JsonConfigDoc.createNestedObject (CN_config); + JsonDocument JsonConfigDoc; + JsonObject JsonConfig = JsonConfigDoc[CN_config].to (); String hostname; NetworkMgr.GetHostname (hostname); JsonConfig[CN_hostname] = hostname; diff --git a/ESPixelStick/src/input/InputDisabled.cpp b/ESPixelStick/src/input/InputDisabled.cpp index 166dba302..dfaa455fa 100644 --- a/ESPixelStick/src/input/InputDisabled.cpp +++ b/ESPixelStick/src/input/InputDisabled.cpp @@ -58,7 +58,7 @@ void c_InputDisabled::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - JsonObject Status = jsonStatus.createNestedObject (F ("disabled")); + JsonObject Status = jsonStatus[F ("disabled")].to (); Status[CN_id] = InputChannelId; // DEBUG_END; diff --git a/ESPixelStick/src/input/InputE131.cpp b/ESPixelStick/src/input/InputE131.cpp index 13a4c75dd..8dd505d00 100644 --- a/ESPixelStick/src/input/InputE131.cpp +++ b/ESPixelStick/src/input/InputE131.cpp @@ -92,7 +92,7 @@ void c_InputE131::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - JsonObject e131Status = jsonStatus.createNestedObject (F ("e131")); + JsonObject e131Status = jsonStatus[F ("e131")].to (); e131Status[CN_id] = InputChannelId; e131Status[CN_unifirst] = startUniverse; e131Status[CN_unilast ] = LastUniverse; @@ -102,11 +102,11 @@ void c_InputE131::GetStatus (JsonObject & jsonStatus) e131Status[CN_last_clientIP] = uint32_t(e131->stats.last_clientIP); // DEBUG_V (""); - JsonArray e131UniverseStatus = e131Status.createNestedArray (CN_channels); + JsonArray e131UniverseStatus = e131Status[CN_channels].to (); uint32_t TotalErrors = e131->stats.packet_errors; for (auto & CurrentUniverse : UniverseArray) { - JsonObject e131CurrentUniverseStatus = e131UniverseStatus.createNestedObject (); + JsonObject e131CurrentUniverseStatus = e131UniverseStatus.add (); e131CurrentUniverseStatus[CN_errors] = CurrentUniverse.SequenceErrorCounter; TotalErrors += CurrentUniverse.SequenceErrorCounter; diff --git a/ESPixelStick/src/input/InputEffectEngine.cpp b/ESPixelStick/src/input/InputEffectEngine.cpp index bd1767957..2ff3ef24b 100644 --- a/ESPixelStick/src/input/InputEffectEngine.cpp +++ b/ESPixelStick/src/input/InputEffectEngine.cpp @@ -162,31 +162,31 @@ void c_InputEffectEngine::GetConfig (JsonObject& jsonConfig) // DEBUG_V (""); - JsonArray EffectsArray = jsonConfig.createNestedArray (CN_effects); + JsonArray EffectsArray = jsonConfig[CN_effects].to (); // DEBUG_V (""); for (EffectDescriptor_t currentEffect : ListOfEffects) { // DEBUG_V (""); - JsonObject currentJsonEntry = EffectsArray.createNestedObject (); + JsonObject currentJsonEntry = EffectsArray.add (); currentJsonEntry[CN_name] = currentEffect.name; } - JsonArray TransitionsArray = jsonConfig.createNestedArray (CN_transitions); + JsonArray TransitionsArray = jsonConfig[CN_transitions].to (); for (auto currentTransition : TransitionColorTable) { // DEBUG_V (""); - JsonObject currentJsonEntry = TransitionsArray.createNestedObject (); + JsonObject currentJsonEntry = TransitionsArray.add (); currentJsonEntry["r"] = currentTransition.r; currentJsonEntry["g"] = currentTransition.g; currentJsonEntry["b"] = currentTransition.b; } - JsonArray MarqueeGroupArray = jsonConfig.createNestedArray (CN_MarqueeGroups); + JsonArray MarqueeGroupArray = jsonConfig[CN_MarqueeGroups].to (); for(auto CurrentMarqueeGroup : MarqueueGroupTable) { - JsonObject currentJsonEntry = MarqueeGroupArray.createNestedObject (); - JsonObject currentJsonEntryColor = currentJsonEntry.createNestedObject (CN_color); + JsonObject currentJsonEntry = MarqueeGroupArray.add (); + JsonObject currentJsonEntryColor = currentJsonEntry[CN_color].to (); currentJsonEntryColor["r"] = CurrentMarqueeGroup.Color.r; currentJsonEntryColor["g"] = CurrentMarqueeGroup.Color.g; currentJsonEntryColor["b"] = CurrentMarqueeGroup.Color.b; @@ -203,7 +203,7 @@ void c_InputEffectEngine::GetConfig (JsonObject& jsonConfig) void c_InputEffectEngine::GetMqttEffectList (JsonObject& jsonConfig) { // DEBUG_START; - JsonArray EffectsArray = jsonConfig.createNestedArray (CN_effect_list); + JsonArray EffectsArray = jsonConfig[CN_effect_list].to (); for (EffectDescriptor_t currentEffect : ListOfEffects) { @@ -236,7 +236,7 @@ void c_InputEffectEngine::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject Status = jsonStatus.createNestedObject (F ("effects")); + JsonObject Status = jsonStatus[F ("effects")].to (); Status[CN_currenteffect] = ActiveEffect->name; Status[CN_id] = InputChannelId; diff --git a/ESPixelStick/src/input/InputFPPRemote.cpp b/ESPixelStick/src/input/InputFPPRemote.cpp index 169fc4799..eccc79e54 100644 --- a/ESPixelStick/src/input/InputFPPRemote.cpp +++ b/ESPixelStick/src/input/InputFPPRemote.cpp @@ -87,7 +87,7 @@ void c_InputFPPRemote::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject LocalPlayerStatus = jsonStatus.createNestedObject (F ("Player")); + JsonObject LocalPlayerStatus = jsonStatus[F ("Player")].to (); LocalPlayerStatus[CN_id] = InputChannelId; LocalPlayerStatus[CN_active] = PlayingFile (); @@ -98,7 +98,7 @@ void c_InputFPPRemote::GetStatus (JsonObject& jsonStatus) else if (PlayingFile ()) { - JsonObject PlayerObjectStatus = LocalPlayerStatus.createNestedObject (StatusType); + JsonObject PlayerObjectStatus = LocalPlayerStatus[StatusType].to (); pInputFPPRemotePlayItem->GetStatus (PlayerObjectStatus); } diff --git a/ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.cpp b/ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.cpp index 66f980df0..fa261f0e2 100644 --- a/ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.cpp +++ b/ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.cpp @@ -53,9 +53,9 @@ void fsm_PlayEffect_state_Idle::Start (String & ConfigString, float ) // DEBUG_V (String ("ConfigString: '") + ConfigString + "'"); p_InputFPPRemotePlayEffect->PlayEffectTimer.StartTimer(1000 * p_InputFPPRemotePlayEffect->PlayDurationSec); - + // tell the effect engine what it is supposed to be doing - DynamicJsonDocument EffectConfig (512); + JsonDocument EffectConfig; DeserializationError error = deserializeJson ((EffectConfig), (const String)ConfigString); // DEBUG_V ("Error Check"); diff --git a/ESPixelStick/src/input/InputFPPRemotePlayList.cpp b/ESPixelStick/src/input/InputFPPRemotePlayList.cpp index 950d080cb..09c01ec55 100644 --- a/ESPixelStick/src/input/InputFPPRemotePlayList.cpp +++ b/ESPixelStick/src/input/InputFPPRemotePlayList.cpp @@ -108,7 +108,7 @@ bool c_InputFPPRemotePlayList::ProcessPlayListEntry () // DEBUG_START; bool response = false; - DynamicJsonDocument JsonPlayListDoc (2048); + JsonDocument JsonPlayListDoc; extern void PrettyPrint (JsonArray & jsonStuff, String Name); extern void PrettyPrint (JsonObject & jsonStuff, String Name); diff --git a/ESPixelStick/src/input/InputFPPRemotePlayListFsm.cpp b/ESPixelStick/src/input/InputFPPRemotePlayListFsm.cpp index 27d406bf8..9f896f212 100644 --- a/ESPixelStick/src/input/InputFPPRemotePlayListFsm.cpp +++ b/ESPixelStick/src/input/InputFPPRemotePlayListFsm.cpp @@ -84,7 +84,7 @@ void fsm_PlayList_state_WaitForStart::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - // JsonObject FileStatus = jsonStatus.createNestedObject (CN_Idle); + // JsonObject FileStatus = jsonStatus[CN_Idle].to (); // DEBUG_END; @@ -144,7 +144,7 @@ void fsm_PlayList_state_Idle::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - // JsonObject FileStatus = jsonStatus.createNestedObject (CN_Idle); + // JsonObject FileStatus = jsonStatus[CN_Idle].to (); // DEBUG_END; @@ -220,7 +220,7 @@ void fsm_PlayList_state_PlayingFile::GetStatus (JsonObject& jsonStatus) jsonStatus[F ("repeat")] = pInputFPPRemotePlayList->pInputFPPRemotePlayItem->GetRepeatCount (); - JsonObject FileStatus = jsonStatus.createNestedObject (CN_File); + JsonObject FileStatus = jsonStatus[CN_File].to (); pInputFPPRemotePlayList->pInputFPPRemotePlayItem->GetStatus (FileStatus); // DEBUG_END; @@ -299,7 +299,7 @@ void fsm_PlayList_state_PlayingEffect::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject EffectStatus = jsonStatus.createNestedObject (CN_Effect); + JsonObject EffectStatus = jsonStatus[CN_Effect].to (); pInputFPPRemotePlayList->pInputFPPRemotePlayItem->GetStatus (EffectStatus); // DEBUG_END; @@ -363,7 +363,7 @@ void fsm_PlayList_state_Paused::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject PauseStatus = jsonStatus.createNestedObject (CN_Paused); + JsonObject PauseStatus = jsonStatus[CN_Paused].to (); time_t SecondsRemaining = pInputFPPRemotePlayList->PauseDelayTimer.GetTimeRemaining() / 1000u; diff --git a/ESPixelStick/src/input/InputMQTT.cpp b/ESPixelStick/src/input/InputMQTT.cpp index fec67db71..debedc3aa 100644 --- a/ESPixelStick/src/input/InputMQTT.cpp +++ b/ESPixelStick/src/input/InputMQTT.cpp @@ -144,7 +144,7 @@ void c_InputMQTT::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - JsonObject Status = jsonStatus.createNestedObject (F ("mqtt")); + JsonObject Status = jsonStatus[F ("mqtt")].to (); Status[CN_id] = InputChannelId; // DEBUG_END; @@ -395,7 +395,7 @@ void c_InputMQTT::onMqttMessage( break; } - DynamicJsonDocument rootDoc (1024); + JsonDocument rootDoc; DeserializationError error = deserializeJson (rootDoc, payload, len); // DEBUG_V ("Set new values"); @@ -618,7 +618,7 @@ void c_InputMQTT::GetEngineConfig (JsonObject & JsonConfig) JsonConfig[CN_brightness] = effectConfig.brightness; JsonConfig[CN_EffectWhiteChannel] = effectConfig.whiteChannel; - JsonObject color = JsonConfig.createNestedObject (CN_color); + JsonObject color = JsonConfig[CN_color].to (); color[CN_r] = effectConfig.color.r; color[CN_g] = effectConfig.color.g; color[CN_b] = effectConfig.color.b; @@ -688,7 +688,7 @@ void c_InputMQTT::publishHA() if (hadisco) { // DEBUG_V (""); - DynamicJsonDocument root(1024); + JsonDocument root; JsonObject JsonConfig = root.to (); JsonConfig[F ("platform")] = F ("MQTT"); @@ -708,7 +708,7 @@ void c_InputMQTT::publishHA() // to enable integration support in HomeAssistant. JsonConfig[F ("unique_id")] = CN_ESPixelStick + chipId; - JsonObject device = JsonConfig.createNestedObject (CN_device); + JsonObject device = JsonConfig[CN_device].to (); device[F ("identifiers")] = WiFi.macAddress (); device[F ("manufacturer")] = F ("Forkineye"); device[F ("model")] = CN_ESPixelStick; @@ -736,8 +736,8 @@ void c_InputMQTT::publishState() { // DEBUG_START; - DynamicJsonDocument root(1024); - JsonObject JsonConfig = root.createNestedObject(F ("MQTT")); + JsonDocument root; + JsonObject JsonConfig = root[F ("MQTT")].to(); JsonConfig[CN_state] = (true == stateOn) ? String(ON) : String(OFF); diff --git a/ESPixelStick/src/input/InputMgr.cpp b/ESPixelStick/src/input/InputMgr.cpp index 3a321b5cb..8ee15d532 100644 --- a/ESPixelStick/src/input/InputMgr.cpp +++ b/ESPixelStick/src/input/InputMgr.cpp @@ -155,7 +155,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) else { // DEBUG_V (""); - InputMgrButtonData = jsonConfig.createNestedObject (IM_EffectsControlButtonName); + InputMgrButtonData = jsonConfig[IM_EffectsControlButtonName].to (); } // DEBUG_V (""); // extern void PrettyPrint (JsonObject & jsonStuff, String Name); @@ -177,7 +177,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) { // add our section header // DEBUG_V (""); - InputMgrChannelsData = jsonConfig.createNestedObject (CN_channels); + InputMgrChannelsData = jsonConfig[CN_channels].to (); } // add the channel configurations @@ -203,7 +203,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) { // add our section header // DEBUG_V (""); - ChannelConfigData = InputMgrChannelsData.createNestedObject (sChannelId); + ChannelConfigData = InputMgrChannelsData[sChannelId].to (); } // save the name as the selected channel type @@ -220,7 +220,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) { // add our section header // DEBUG_V (""); - ChannelConfigByTypeData = ChannelConfigData.createNestedObject (DriverTypeId); + ChannelConfigByTypeData = ChannelConfigData[DriverTypeId].to (); } // ask the channel to add its data to the record @@ -255,10 +255,10 @@ void c_InputMgr::CreateNewConfig () // create a place to save the config // DEBUG_V(String("Heap: ") + String(ESP.getFreeHeap())); - DynamicJsonDocument JsonConfigDoc(IM_JSON_SIZE); + JsonDocument JsonConfigDoc; // DEBUG_V(""); - JsonObject JsonConfig = JsonConfigDoc.createNestedObject(CN_input_config); + JsonObject JsonConfig = JsonConfigDoc[CN_input_config].to(); // DEBUG_V(""); JsonConfig[CN_cfgver] = CurrentConfigVersion; @@ -317,18 +317,18 @@ void c_InputMgr::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject InputButtonStatus = jsonStatus.createNestedObject (F ("inputbutton")); + JsonObject InputButtonStatus = jsonStatus[F ("inputbutton")].to (); ExternalInput.GetStatistics (InputButtonStatus); - JsonArray InputStatus = jsonStatus.createNestedArray (F ("input")); + JsonArray InputStatus = jsonStatus[F ("input")].to (); for (auto & CurrentInput : InputChannelDrivers) { - if(nullptr == CurrentInput.pInputChannelDriver) + if(nullptr == CurrentInput.pInputChannelDriver) { continue; } - JsonObject channelStatus = InputStatus.createNestedObject (); + JsonObject channelStatus = InputStatus.add (); CurrentInput.pInputChannelDriver->GetStatus (channelStatus); // DEBUG_V(""); } @@ -616,7 +616,7 @@ void c_InputMgr::LoadConfig () ConfigLoadNeeded = NO_CONFIG_NEEDED; configInProgress = true; // try to load and process the config file - if (!FileMgr.LoadFlashFile (ConfigFileName, [this](DynamicJsonDocument & JsonConfigDoc) + if (!FileMgr.LoadFlashFile (ConfigFileName, [this](JsonDocument & JsonConfigDoc) { // DEBUG_V (""); JsonObject JsonConfig = JsonConfigDoc.as (); diff --git a/ESPixelStick/src/network/NetworkMgr.cpp b/ESPixelStick/src/network/NetworkMgr.cpp index 4a54ddc77..0468613cc 100644 --- a/ESPixelStick/src/network/NetworkMgr.cpp +++ b/ESPixelStick/src/network/NetworkMgr.cpp @@ -92,17 +92,17 @@ void c_NetworkMgr::GetConfig (JsonObject & json) { // DEBUG_START; - JsonObject NetworkConfig = json.createNestedObject (CN_network); + JsonObject NetworkConfig = json[CN_network].to (); NetworkConfig[CN_hostname] = hostname; - JsonObject NetworkWiFiConfig = NetworkConfig.createNestedObject (CN_wifi); + JsonObject NetworkWiFiConfig = NetworkConfig[CN_wifi].to (); WiFiDriver.GetConfig (NetworkWiFiConfig); #ifdef SUPPORT_ETHERNET NetworkConfig[CN_weus] = AllowWiFiAndEthUpSimultaneously; - JsonObject NetworkEthConfig = NetworkConfig.createNestedObject (CN_eth); + JsonObject NetworkEthConfig = NetworkConfig[CN_eth].to (); EthernetDriver.GetConfig (NetworkEthConfig); #endif // def SUPPORT_ETHERNET @@ -121,16 +121,16 @@ void c_NetworkMgr::GetStatus (JsonObject & json) { // DEBUG_START; - JsonObject NetworkStatus = json.createNestedObject (CN_network); + JsonObject NetworkStatus = json[CN_network].to (); String name; GetHostname (name); NetworkStatus[CN_hostname] = name; - JsonObject NetworkWiFiStatus = NetworkStatus.createNestedObject (CN_wifi); + JsonObject NetworkWiFiStatus = NetworkStatus[CN_wifi].to (); WiFiDriver.GetStatus (NetworkWiFiStatus); #ifdef SUPPORT_ETHERNET - JsonObject NetworkEthStatus = NetworkStatus.createNestedObject (CN_eth); + JsonObject NetworkEthStatus = NetworkStatus[CN_eth].to (); EthernetDriver.GetStatus (NetworkEthStatus); #endif // def SUPPORT_ETHERNET diff --git a/ESPixelStick/src/network/WiFiDriver.cpp b/ESPixelStick/src/network/WiFiDriver.cpp index b0a915770..0315e10a1 100644 --- a/ESPixelStick/src/network/WiFiDriver.cpp +++ b/ESPixelStick/src/network/WiFiDriver.cpp @@ -130,7 +130,7 @@ void c_WiFiDriver::Begin () if (FileMgr.SdCardIsInstalled()) { - DynamicJsonDocument jsonConfigDoc(1024); + JsonDocument jsonConfigDoc; // DEBUG_V ("read the sdcard config"); if (FileMgr.ReadSdFile (F("wificonfig.json"), jsonConfigDoc)) { diff --git a/ESPixelStick/src/output/OutputGECEUart.cpp b/ESPixelStick/src/output/OutputGECEUart.cpp index 1302f3f31..e13968eff 100644 --- a/ESPixelStick/src/output/OutputGECEUart.cpp +++ b/ESPixelStick/src/output/OutputGECEUart.cpp @@ -126,7 +126,7 @@ void c_OutputGECEUart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef GECE_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("GECE UART Debug"); + JsonObject debugStatus = jsonStatus["GECE UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/output/OutputGS8208Uart.cpp b/ESPixelStick/src/output/OutputGS8208Uart.cpp index d1e2c0b9d..e64b5d2fb 100644 --- a/ESPixelStick/src/output/OutputGS8208Uart.cpp +++ b/ESPixelStick/src/output/OutputGS8208Uart.cpp @@ -127,7 +127,7 @@ void c_OutputGS8208Uart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef GS8208_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("GS8208 UART Debug"); + JsonObject debugStatus = jsonStatus["GS8208 UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/output/OutputMgr.cpp b/ESPixelStick/src/output/OutputMgr.cpp index c64246694..6d7f8b615 100644 --- a/ESPixelStick/src/output/OutputMgr.cpp +++ b/ESPixelStick/src/output/OutputMgr.cpp @@ -302,7 +302,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) if (!jsonConfig.containsKey (CN_channels)) { // DEBUG_V (); - jsonConfig.createNestedObject (CN_channels); + jsonConfig[CN_channels].to (); } OutputMgrChannelsData = jsonConfig[CN_channels]; @@ -322,7 +322,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) else { // DEBUG_V (String ("add our channel section header. Chan: ") + sChannelId); - ChannelConfigData = OutputMgrChannelsData.createNestedObject (sChannelId); + ChannelConfigData = OutputMgrChannelsData[sChannelId].to (); } // save the name as the selected channel type @@ -338,7 +338,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) else { // DEBUG_V (String("Add Channel Type Data for chan: ") + sChannelId + " Type: " + DriverTypeId); - ChannelConfigByTypeData = ChannelConfigData.createNestedObject (DriverTypeId); + ChannelConfigByTypeData = ChannelConfigData[DriverTypeId].to (); } // DEBUG_V (); @@ -389,11 +389,11 @@ void c_OutputMgr::CreateNewConfig () BuildingNewConfig = true; // create a place to save the config - DynamicJsonDocument JsonConfigDoc (OM_MAX_CONFIG_SIZE); + JsonDocument JsonConfigDoc; // DEBUG_V (); // DEBUG_V("Create a new output config structure."); - JsonObject JsonConfig = JsonConfigDoc.createNestedObject (CN_output_config); + JsonObject JsonConfig = JsonConfigDoc[CN_output_config].to (); // DEBUG_V (); JsonConfig[CN_cfgver] = CurrentConfigVersion; @@ -490,11 +490,11 @@ void c_OutputMgr::GetStatus (JsonObject & jsonStatus) // jsonStatus["PollCount"] = PollCount; #endif // defined(ARDUINO_ARCH_ESP32) - JsonArray OutputStatus = jsonStatus.createNestedArray (CN_output); + JsonArray OutputStatus = jsonStatus[CN_output].to (); for (auto & CurrentOutput : OutputChannelDrivers) { // DEBUG_V (); - JsonObject channelStatus = OutputStatus.createNestedObject (); + JsonObject channelStatus = OutputStatus.add (); CurrentOutput.pOutputChannelDriver->GetStatus(channelStatus); // DEBUG_V (); } @@ -1000,9 +1000,9 @@ void c_OutputMgr::LoadConfig () ConfigInProgress = true; // try to load and process the config file - if (!FileMgr.LoadFlashFile(ConfigFileName, [this](DynamicJsonDocument &JsonConfigDoc) + if (!FileMgr.LoadFlashFile(ConfigFileName, [this](JsonDocument &JsonConfigDoc) { - // extern void PrettyPrint(DynamicJsonDocument & jsonStuff, String Name); + // extern void PrettyPrint(JsonDocument & jsonStuff, String Name); // PrettyPrint(JsonConfigDoc, "OM Load Config"); // DEBUG_V (); @@ -1033,7 +1033,7 @@ void c_OutputMgr::LoadConfig () } // LoadConfig //----------------------------------------------------------------------------- -bool c_OutputMgr::FindJsonChannelConfig (DynamicJsonDocument& jsonConfig, +bool c_OutputMgr::FindJsonChannelConfig (JsonDocument& jsonConfig, e_OutputChannelIds ChanId, e_OutputType Type, JsonObject& ChanConfig) @@ -1126,7 +1126,7 @@ bool c_OutputMgr::FindJsonChannelConfig (DynamicJsonDocument& jsonConfig, } // FindChannelJsonConfig //----------------------------------------------------------------------------- -bool c_OutputMgr::ProcessJsonConfig (DynamicJsonDocument& jsonConfig) +bool c_OutputMgr::ProcessJsonConfig (JsonDocument& jsonConfig) { // DEBUG_START; bool Response = false; diff --git a/ESPixelStick/src/output/OutputMgr.hpp b/ESPixelStick/src/output/OutputMgr.hpp index 15d8ee205..cdfd95836 100644 --- a/ESPixelStick/src/output/OutputMgr.hpp +++ b/ESPixelStick/src/output/OutputMgr.hpp @@ -238,13 +238,13 @@ class c_OutputMgr bool IsOutputPaused = false; bool BuildingNewConfig = false; - bool ProcessJsonConfig (DynamicJsonDocument & jsonConfig); + bool ProcessJsonConfig (JsonDocument & 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); + bool FindJsonChannelConfig (JsonDocument& jsonConfig, e_OutputChannelIds ChanId, e_OutputType Type, JsonObject& ChanConfig); String ConfigFileName; diff --git a/ESPixelStick/src/output/OutputPixel.cpp b/ESPixelStick/src/output/OutputPixel.cpp index cb586535c..674c162e3 100644 --- a/ESPixelStick/src/output/OutputPixel.cpp +++ b/ESPixelStick/src/output/OutputPixel.cpp @@ -74,7 +74,7 @@ void c_OutputPixel::GetStatus (ArduinoJson::JsonObject& jsonStatus) c_OutputCommon::GetStatus (jsonStatus); #ifdef USE_PIXEL_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("Pixel Debug"); + JsonObject debugStatus = jsonStatus["Pixel Debug"].to(); debugStatus["NumIntensityBytesPerPixel"] = NumIntensityBytesPerPixel; debugStatus["PixelsToSend"] = PixelsToSend; debugStatus["FrameStartCounter"] = FrameStartCounter; diff --git a/ESPixelStick/src/output/OutputRelay.cpp b/ESPixelStick/src/output/OutputRelay.cpp index 66ed7e84a..affbd73d3 100644 --- a/ESPixelStick/src/output/OutputRelay.cpp +++ b/ESPixelStick/src/output/OutputRelay.cpp @@ -304,12 +304,12 @@ void c_OutputRelay::GetConfig (ArduinoJson::JsonObject & jsonConfig) jsonConfig[OM_RELAY_UPDATE_INTERVAL_NAME] = UpdateInterval; - JsonArray JsonChannelList = jsonConfig.createNestedArray (CN_channels); + JsonArray JsonChannelList = jsonConfig[CN_channels].to (); uint8_t ChannelId = 0; for (RelayChannel_t & currentRelay : OutputList) { - JsonObject JsonChannelData = JsonChannelList.createNestedObject (); + JsonObject JsonChannelData = JsonChannelList.add (); JsonChannelData[CN_id] = ChannelId; JsonChannelData[OM_RELAY_CHANNEL_ENABLED_NAME] = currentRelay.Enabled; @@ -341,12 +341,12 @@ void c_OutputRelay::GetStatus(ArduinoJson::JsonObject &jsonStatus) // DEBUG_START; c_OutputCommon::GetStatus(jsonStatus); - JsonArray JsonChannelList = jsonStatus.createNestedArray (CN_Relay); + JsonArray JsonChannelList = jsonStatus[CN_Relay].to (); uint8_t ChannelId = 0; for (RelayChannel_t & currentRelay : OutputList) { - JsonObject JsonChannelData = JsonChannelList.createNestedObject (); + JsonObject JsonChannelData = JsonChannelList.add (); JsonChannelData[CN_id] = ChannelId; JsonChannelData[CN_activevalue] = currentRelay.previousValue; diff --git a/ESPixelStick/src/output/OutputRmt.cpp b/ESPixelStick/src/output/OutputRmt.cpp index 740747da0..3ae48764c 100644 --- a/ESPixelStick/src/output/OutputRmt.cpp +++ b/ESPixelStick/src/output/OutputRmt.cpp @@ -234,7 +234,7 @@ void c_OutputRmt::GetStatus (ArduinoJson::JsonObject& jsonStatus) jsonStatus[F("NumRmtSlotOverruns")] = NumRmtSlotOverruns; #ifdef USE_RMT_DEBUG_COUNTERS jsonStatus[F("OutputIsPaused")] = OutputIsPaused; - JsonObject debugStatus = jsonStatus.createNestedObject("RMT Debug"); + JsonObject debugStatus = jsonStatus["RMT Debug"].to(); debugStatus["RmtChannelId"] = OutputRmtConfig.RmtChannelId; debugStatus["GPIO"] = OutputRmtConfig.DataPin; debugStatus["conf0"] = String(RMT.conf_ch[OutputRmtConfig.RmtChannelId].conf0.val, HEX); diff --git a/ESPixelStick/src/output/OutputSerial.cpp b/ESPixelStick/src/output/OutputSerial.cpp index b0cbbe593..dce23d062 100644 --- a/ESPixelStick/src/output/OutputSerial.cpp +++ b/ESPixelStick/src/output/OutputSerial.cpp @@ -84,7 +84,7 @@ void c_OutputSerial::GetStatus (ArduinoJson::JsonObject& jsonStatus) c_OutputCommon::GetStatus (jsonStatus); #ifdef USE_SERIAL_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("Serial Debug"); + JsonObject debugStatus = jsonStatus["Serial Debug"].to(); debugStatus["Num_Channels"] = Num_Channels; debugStatus["NextIntensityToSend"] = String(int(NextIntensityToSend), HEX); debugStatus["IntensityBytesSent"] = IntensityBytesSent; diff --git a/ESPixelStick/src/output/OutputServoPCA9685.cpp b/ESPixelStick/src/output/OutputServoPCA9685.cpp index b382026b2..486d15f61 100644 --- a/ESPixelStick/src/output/OutputServoPCA9685.cpp +++ b/ESPixelStick/src/output/OutputServoPCA9685.cpp @@ -220,12 +220,12 @@ void c_OutputServoPCA9685::GetConfig (ArduinoJson::JsonObject & jsonConfig) jsonConfig[OM_SERVO_PCA9685_UPDATE_INTERVAL_NAME] = UpdateFrequency; - JsonArray JsonChannelList = jsonConfig.createNestedArray (OM_SERVO_PCA9685_CHANNELS_NAME); + JsonArray JsonChannelList = jsonConfig[OM_SERVO_PCA9685_CHANNELS_NAME].to (); uint8_t ChannelId = 0; for (ServoPCA9685Channel_t & currentServoPCA9685 : OutputList) { - JsonObject JsonChannelData = JsonChannelList.createNestedObject (); + JsonObject JsonChannelData = JsonChannelList.add (); JsonChannelData[OM_SERVO_PCA9685_CHANNEL_ID_NAME] = ChannelId; JsonChannelData[OM_SERVO_PCA9685_CHANNEL_ENABLED_NAME] = currentServoPCA9685.Enabled; diff --git a/ESPixelStick/src/output/OutputTM1814Uart.cpp b/ESPixelStick/src/output/OutputTM1814Uart.cpp index 24221ef37..214069341 100644 --- a/ESPixelStick/src/output/OutputTM1814Uart.cpp +++ b/ESPixelStick/src/output/OutputTM1814Uart.cpp @@ -116,7 +116,7 @@ void c_OutputTM1814Uart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef TM1814_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("TM1814 UART Debug"); + JsonObject debugStatus = jsonStatus["TM1814 UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/output/OutputUCS1903Uart.cpp b/ESPixelStick/src/output/OutputUCS1903Uart.cpp index fba479a3c..6733f2e81 100644 --- a/ESPixelStick/src/output/OutputUCS1903Uart.cpp +++ b/ESPixelStick/src/output/OutputUCS1903Uart.cpp @@ -115,7 +115,7 @@ void c_OutputUCS1903Uart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef UCS1903_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("UCS1903 UART Debug"); + JsonObject debugStatus = jsonStatus["UCS1903 UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/output/OutputUCS8903Uart.cpp b/ESPixelStick/src/output/OutputUCS8903Uart.cpp index a53e53f64..991dfd487 100644 --- a/ESPixelStick/src/output/OutputUCS8903Uart.cpp +++ b/ESPixelStick/src/output/OutputUCS8903Uart.cpp @@ -131,7 +131,7 @@ void c_OutputUCS8903Uart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef UCS8903_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("UCS8903 UART Debug"); + JsonObject debugStatus = jsonStatus["UCS8903 UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/output/OutputUart.cpp b/ESPixelStick/src/output/OutputUart.cpp index 0f988d6be..080c4e8d9 100644 --- a/ESPixelStick/src/output/OutputUart.cpp +++ b/ESPixelStick/src/output/OutputUart.cpp @@ -296,7 +296,7 @@ void c_OutputUart::GetStatus(ArduinoJson::JsonObject &jsonStatus) // DEBUG_START; #ifdef USE_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("UART Debug"); + JsonObject debugStatus = jsonStatus["UART Debug"].to(); debugStatus["ChannelId"] = OutputUartConfig.ChannelId; debugStatus["RxIsr"] = RxIsr; debugStatus["FiFoISRcounter"] = FiFoISRcounter; diff --git a/ESPixelStick/src/output/OutputWS2811Uart.cpp b/ESPixelStick/src/output/OutputWS2811Uart.cpp index 45e0acc75..0340c6bd7 100644 --- a/ESPixelStick/src/output/OutputWS2811Uart.cpp +++ b/ESPixelStick/src/output/OutputWS2811Uart.cpp @@ -122,7 +122,7 @@ void c_OutputWS2811Uart::GetStatus(ArduinoJson::JsonObject &jsonStatus) Uart.GetStatus(jsonStatus); #ifdef WS2811_UART_DEBUG_COUNTERS - JsonObject debugStatus = jsonStatus.createNestedObject("WS2811 UART Debug"); + JsonObject debugStatus = jsonStatus["WS2811 UART Debug"].to(); debugStatus["NewFrameCounter"] = NewFrameCounter; debugStatus["TimeSinceLastFrameMS"] = TimeSinceLastFrameMS; debugStatus["TimeLastFrameStartedMS"] = TimeLastFrameStartedMS; diff --git a/ESPixelStick/src/service/FPPDiscovery.cpp b/ESPixelStick/src/service/FPPDiscovery.cpp index e0ec8fe59..3d5c6f32e 100644 --- a/ESPixelStick/src/service/FPPDiscovery.cpp +++ b/ESPixelStick/src/service/FPPDiscovery.cpp @@ -174,7 +174,7 @@ void c_FPPDiscovery::GetStatus (JsonObject & jsonStatus) #endif // def FPP_DEBUG_ENABLED // DEBUG_V ("Is Enabled"); - JsonObject MyJsonStatus = jsonStatus.createNestedObject (F ("FPPDiscovery")); + JsonObject MyJsonStatus = jsonStatus[F ("FPPDiscovery")].to (); MyJsonStatus[F ("FppRemoteIp")] = FppRemoteIp.toString (); if (InputFPPRemotePlayFile) { @@ -528,7 +528,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St { // DEBUG_START; - DynamicJsonDocument JsonDoc (4*1024); + JsonDocument JsonDoc; JsonObject JsonData = JsonDoc.to (); FSEQRawHeader fsqHeader; @@ -574,7 +574,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St if (0 != fsqHeader.numSparseRanges) { - JsonArray JsonDataRanges = JsonData.createNestedArray (F ("Ranges")); + JsonArray JsonDataRanges = JsonData[F ("Ranges")].to (); maxChannel = 0; @@ -590,7 +590,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St uint32_t RangeStart = read24 (CurrentFSEQRangeEntry->Start); uint32_t RangeLength = read24 (CurrentFSEQRangeEntry->Length); - JsonObject JsonRange = JsonDataRanges.createNestedObject (); + JsonObject JsonRange = JsonDataRanges.add (); JsonRange[F ("Start")] = String (RangeStart); JsonRange[F ("Length")] = String (RangeLength); @@ -614,7 +614,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St if (FileOffsetToCurrentHeaderRecord < FileOffsetToStartOfSequenceData) { - JsonArray JsonDataHeaders = JsonData.createNestedArray (F ("variableHeaders")); + JsonArray JsonDataHeaders = JsonData[F ("variableHeaders")].to (); char FSEQVariableDataHeaderBuffer[sizeof (FSEQRawVariableDataHeader) + 1]; memset ((uint8_t*)FSEQVariableDataHeaderBuffer, 0x00, sizeof (FSEQVariableDataHeaderBuffer)); @@ -636,7 +636,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St FileMgr.ReadSdFile (fseq, (byte*)VariableDataHeaderDataBuffer, VariableDataHeaderDataLength, FileOffsetToCurrentHeaderRecord); - JsonObject JsonDataHeader = JsonDataHeaders.createNestedObject (); + JsonObject JsonDataHeader = JsonDataHeaders.add (); JsonDataHeader[HeaderTypeCode] = String (VariableDataHeaderDataBuffer); free (VariableDataHeaderDataBuffer); @@ -707,7 +707,7 @@ void c_FPPDiscovery::ProcessGET (AsyncWebServerRequest* request) else if (path.startsWith (F ("/api/system/status"))) { String Response; - DynamicJsonDocument JsonDoc (2048); + JsonDocument JsonDoc; JsonObject JsonData = JsonDoc.to (); GetStatusJSON(JsonData, true); serializeJson (JsonDoc, Response); @@ -718,7 +718,7 @@ void c_FPPDiscovery::ProcessGET (AsyncWebServerRequest* request) else if (path.startsWith (F ("/api/system/info"))) { String Response; - DynamicJsonDocument JsonDoc (2048); + JsonDocument JsonDoc; JsonObject JsonData = JsonDoc.to (); GetSysInfoJSON(JsonData); serializeJson (JsonDoc, Response); @@ -915,12 +915,12 @@ void c_FPPDiscovery::GetSysInfoJSON (JsonObject & jsonResponse) jsonResponse[F ("minorVersion")] = (uint16_t)atoi (&version[2]); jsonResponse[F ("typeId")] = FPP_TYPE_ID; - JsonObject jsonResponseUtilization = jsonResponse.createNestedObject (F ("Utilization")); + JsonObject jsonResponseUtilization = jsonResponse[F ("Utilization")].to (); jsonResponseUtilization[F ("MemoryFree")] = ESP.getFreeHeap (); jsonResponseUtilization[F ("Uptime")] = millis (); jsonResponse[CN_rssi] = WiFi.RSSI (); - JsonArray jsonResponseIpAddresses = jsonResponse.createNestedArray (F ("IPS")); + JsonArray jsonResponseIpAddresses = jsonResponse[F ("IPS")].to (); jsonResponseIpAddresses.add(WiFi.localIP ().toString ()); // DEBUG_END; @@ -930,12 +930,12 @@ void c_FPPDiscovery::GetSysInfoJSON (JsonObject & jsonResponse) void c_FPPDiscovery::GetStatusJSON (JsonObject & JsonData, bool adv) { // DEBUG_START; - JsonObject JsonDataMqtt = JsonData.createNestedObject(F ("MQTT")); + JsonObject JsonDataMqtt = JsonData[F ("MQTT")].to(); JsonDataMqtt[F ("configured")] = false; JsonDataMqtt[F ("connected")] = false; - JsonObject JsonDataCurrentPlaylist = JsonData.createNestedObject (F ("current_playlist")); + JsonObject JsonDataCurrentPlaylist = JsonData[F ("current_playlist")].to (); JsonDataCurrentPlaylist[CN_count] = "0"; JsonDataCurrentPlaylist[F ("description")] = ""; @@ -994,7 +994,7 @@ void c_FPPDiscovery::GetStatusJSON (JsonObject & JsonData, bool adv) if (adv) { // DEBUG_V(); - JsonObject JsonDataAdvancedView = JsonData.createNestedObject (F ("advancedView")); + JsonObject JsonDataAdvancedView = JsonData[F ("advancedView")].to (); GetSysInfoJSON (JsonDataAdvancedView); // DEBUG_V(); } @@ -1019,7 +1019,7 @@ void c_FPPDiscovery::ProcessFPPJson (AsyncWebServerRequest* request) break; } - DynamicJsonDocument JsonDoc (2048); + JsonDocument JsonDoc; JsonObject JsonData = JsonDoc.to (); String command = request->getParam (ulrCommand)->value (); diff --git a/ESPixelStick/src/service/SensorDS18B20.cpp b/ESPixelStick/src/service/SensorDS18B20.cpp index 76eb94ed5..f9e4224da 100644 --- a/ESPixelStick/src/service/SensorDS18B20.cpp +++ b/ESPixelStick/src/service/SensorDS18B20.cpp @@ -40,11 +40,11 @@ void c_SensorDS18B20::Begin () } // Begin //----------------------------------------------------------------------------- -void c_SensorDS18B20::GetConfig (JsonObject& json) +void c_SensorDS18B20::GetConfig (JsonObject& json) { // DEBUG_START; - JsonObject SensorConfig = json.createNestedObject (CN_sensor); + JsonObject SensorConfig = json[CN_sensor].to (); SensorConfig[CN_units] = TempUnit; @@ -93,7 +93,7 @@ void c_SensorDS18B20::GetStatus (JsonObject& json) break; } - JsonObject SensorStatus = json.createNestedObject (CN_sensor); + JsonObject SensorStatus = json[CN_sensor].to (); SensorStatus[CN_reading] = String(LastReading) + ((TempUnit == TempUnit_t::TempUnitCentegrade) ? " C" : " F"); diff --git a/platformio.ini b/platformio.ini index ab41b62c6..109b01d98 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,7 +23,7 @@ upload_speed = 921600 lib_compat_mode = strict lib_deps = adafruit/Adafruit PWM Servo Driver Library @ 2.4.0 - bblanchon/ArduinoJson @ 6.18.5 + https://github.com/bblanchon/ArduinoJson @ 7.1.0 djgrrr/Int64String @ 1.1.1 https://github.com/esphome/ESPAsyncWebServer#4fd0a1fdf421664214a27373c0eb0247f94b7a79 https://github.com/forkineye/ESPAsyncE131