From 8888777a47dd218de1c41c83fda12569d512169e Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 7 Jan 2025 17:10:05 -0500 Subject: [PATCH] Changes to support ArduinoJson 7.3.0 --- include/ConstNames.hpp | 1 + include/ESPixelStick.h | 10 +- platformio.ini | 2 +- src/ConstNames.cpp | 1 + src/FileMgr.cpp | 18 +- src/WebMgr.cpp | 32 ++-- src/input/InputAlexa.cpp | 18 +- src/input/InputArtnet.cpp | 28 +-- src/input/InputDDP.cpp | 30 ++-- src/input/InputDisabled.cpp | 2 +- src/input/InputE131.cpp | 28 +-- src/input/InputEffectEngine.cpp | 80 ++++----- src/input/InputFPPRemote.cpp | 14 +- src/input/InputFPPRemotePlayEffectFsm.cpp | 4 +- src/input/InputFPPRemotePlayFile.cpp | 25 ++- src/input/InputFPPRemotePlayList.cpp | 8 +- src/input/InputFPPRemotePlayListFsm.cpp | 10 +- src/input/InputMQTT.cpp | 92 +++++----- src/input/InputMgr.cpp | 16 +- src/input/externalInput.cpp | 16 +- src/main.cpp | 20 +-- src/network/EthernetDriver.cpp | 44 +++-- src/network/NetworkMgr.cpp | 26 +-- src/network/WiFiDriver.cpp | 57 +++--- src/output/OutputCommon.cpp | 16 +- src/output/OutputGrinch.cpp | 2 +- src/output/OutputMgr.cpp | 20 +-- src/output/OutputPixel.cpp | 18 +- src/output/OutputRelay.cpp | 26 +-- src/output/OutputSerial.cpp | 10 +- src/output/OutputServoPCA9685.cpp | 22 +-- src/output/OutputSpi.cpp | 6 +- src/output/OutputTM1814.cpp | 2 +- src/output/OutputUart.cpp | 2 +- src/service/FPPDiscovery.cpp | 205 +++++++++++----------- 35 files changed, 452 insertions(+), 459 deletions(-) diff --git a/include/ConstNames.hpp b/include/ConstNames.hpp index e6c0a055c..de8452ccf 100644 --- a/include/ConstNames.hpp +++ b/include/ConstNames.hpp @@ -92,6 +92,7 @@ extern const CN_PROGMEM char CN_Effect []; extern const CN_PROGMEM char CN_effects []; extern const CN_PROGMEM char CN_en []; extern const CN_PROGMEM char CN_enabled []; +extern const CN_PROGMEM char CN_entry []; extern const CN_PROGMEM char CN_errors []; extern const CN_PROGMEM char CN_ESP32 []; extern const CN_PROGMEM char CN_ESP8266 []; diff --git a/include/ESPixelStick.h b/include/ESPixelStick.h index 7b9243dc6..335949454 100644 --- a/include/ESPixelStick.h +++ b/include/ESPixelStick.h @@ -92,9 +92,9 @@ bool setFromJSON (T& OutValue, JsonObject & Json, N Name) { bool HasBeenModified = false; - if (Json[Name].template is()) + if (Json[(char*)Name].template is()) { - T temp = Json[Name]; + T temp = Json[(char*)Name]; if (temp != OutValue) { OutValue = temp; @@ -115,9 +115,9 @@ bool setFromJSON (T& OutValue, JsonVariant & Json, N Name) { bool HasBeenModified = false; - if (Json[Name].template is()) + if (Json[(char*)Name].template is()) { - T temp = Json[Name]; + T temp = Json[(char*)Name]; if (temp != OutValue) { OutValue = temp; @@ -133,6 +133,8 @@ bool setFromJSON (T& OutValue, JsonVariant & Json, N Name) return HasBeenModified; }; +#define JsonWrite(j, n, v) (j)[(char*)(n)] = (v) + #define logcon(msg) \ { \ String DN; \ diff --git a/platformio.ini b/platformio.ini index 9d933e9dc..f3b88f282 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 @ 7.2.1 + bblanchon/ArduinoJson @ 7.3.0 djgrrr/Int64String @ ^1.1.1 forkineye/ESPAsyncE131 @ ^1.0.5 greiman/SdFat @ ^2.2.3 diff --git a/src/ConstNames.cpp b/src/ConstNames.cpp index 043940ae0..d8cf21ef3 100644 --- a/src/ConstNames.cpp +++ b/src/ConstNames.cpp @@ -83,6 +83,7 @@ const CN_PROGMEM char CN_Effect [] = "Effect"; const CN_PROGMEM char CN_effects [] = "effects"; const CN_PROGMEM char CN_en [] = "en"; const CN_PROGMEM char CN_enabled [] = "enabled"; +const CN_PROGMEM char CN_entry [] = "entry"; const CN_PROGMEM char CN_errors [] = "errors"; const CN_PROGMEM char CN_ESP32 [] = "ESP32"; const CN_PROGMEM char CN_ESP8266 [] = "ESP8266"; diff --git a/src/FileMgr.cpp b/src/FileMgr.cpp index 20d42904a..1118d552d 100644 --- a/src/FileMgr.cpp +++ b/src/FileMgr.cpp @@ -228,7 +228,7 @@ bool c_FileMgr::SetConfig (JsonObject & json) // DEBUG_START; bool ConfigChanged = false; - JsonObject JsonDeviceConfig = json[CN_device]; + JsonObject JsonDeviceConfig = json[(char*)CN_device].as(); if (JsonDeviceConfig) { // PrettyPrint (JsonDeviceConfig, "c_FileMgr"); @@ -280,15 +280,15 @@ void c_FileMgr::GetConfig (JsonObject& json) { // DEBUG_START; - json[CN_miso_pin] = miso_pin; - json[CN_mosi_pin] = mosi_pin; - json[CN_clock_pin] = clk_pin; - json[CN_cs_pin] = cs_pin; - json[CN_sdspeed] = MaxSdSpeed; + JsonWrite(json, CN_miso_pin, miso_pin); + JsonWrite(json, CN_mosi_pin, mosi_pin); + JsonWrite(json, CN_clock_pin, clk_pin); + JsonWrite(json, CN_cs_pin, cs_pin); + JsonWrite(json, CN_sdspeed, MaxSdSpeed); - json[CN_user] = FtpUserName; - json[CN_password] = FtpPassword; - json[CN_enabled] = FtpEnabled; + JsonWrite(json, CN_user, FtpUserName); + JsonWrite(json, CN_password, FtpPassword); + JsonWrite(json, CN_enabled, FtpEnabled); // DEBUG_END; diff --git a/src/WebMgr.cpp b/src/WebMgr.cpp index c60a3a0b6..e3ae68a72 100644 --- a/src/WebMgr.cpp +++ b/src/WebMgr.cpp @@ -628,16 +628,16 @@ void c_WebMgr::CreateAdminInfoFile () JsonDocument AdminJsonDoc; JsonObject jsonAdmin = AdminJsonDoc[F ("admin")].to (); - jsonAdmin[CN_version] = VERSION; - jsonAdmin["built"] = BUILD_DATE; - jsonAdmin["realflashsize"] = String (ESP.getFlashChipSize ()); - jsonAdmin["BoardName"] = String(BOARD_NAME); + JsonWrite(jsonAdmin, CN_version, VERSION); + JsonWrite(jsonAdmin, "built", BUILD_DATE); + JsonWrite(jsonAdmin, "realflashsize", String (ESP.getFlashChipSize ())); + JsonWrite(jsonAdmin, "BoardName", String(BOARD_NAME)); #ifdef ARDUINO_ARCH_ESP8266 - jsonAdmin["arch"] = CN_ESP8266; - jsonAdmin["flashchipid"] = String (ESP.getChipId (), HEX); + JsonWrite(jsonAdmin, "arch", String(CN_ESP8266)); + JsonWrite(jsonAdmin, "flashchipid", String (ESP.getChipId (), HEX)); #elif defined (ARDUINO_ARCH_ESP32) - jsonAdmin["arch"] = CN_ESP32; - jsonAdmin["flashchipid"] = int64String (ESP.getEfuseMac (), HEX); + JsonWrite(jsonAdmin, "arch", String(CN_ESP32)); + JsonWrite(jsonAdmin, "flashchipid", int64String (ESP.getEfuseMac (), HEX)); #endif // write to json file @@ -765,14 +765,14 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client) JsonDocument WebJsonDoc; WebJsonDoc.clear (); - JsonObject status = WebJsonDoc[CN_status].to (); - JsonObject system = status[CN_system].to (); - - system[F ("freeheap")] = ESP.getFreeHeap (); - system[F ("uptime")] = millis (); - system[F ("currenttime")] = now (); - system[F ("SDinstalled")] = FileMgr.SdCardIsInstalled (); - system[F ("DiscardedRxData")] = DiscardedRxData; + JsonObject status = WebJsonDoc[(char*)CN_status].to (); + JsonObject system = status[(char*)CN_system].to (); + + JsonWrite(system, F ("freeheap"), ESP.getFreeHeap ()); + JsonWrite(system, F ("uptime"), millis ()); + JsonWrite(system, F ("currenttime"), now ()); + JsonWrite(system, F ("SDinstalled"), FileMgr.SdCardIsInstalled ()); + JsonWrite(system, F ("DiscardedRxData"), DiscardedRxData); // Ask WiFi Stats // DEBUG_V ("NetworkMgr.GetStatus"); diff --git a/src/input/InputAlexa.cpp b/src/input/InputAlexa.cpp index 237a3b8b0..20989d4bf 100644 --- a/src/input/InputAlexa.cpp +++ b/src/input/InputAlexa.cpp @@ -167,15 +167,15 @@ void c_InputAlexa::onMessage(EspalexaDevice * pDevice) // DEBUG_V (String ("pDevice->getB: ") + String (pDevice->getB ())); JsonDocument JsonConfigDoc; - JsonObject JsonConfig = JsonConfigDoc[CN_config].to (); - - JsonConfig[CN_EffectSpeed] = 1; - JsonConfig[CN_EffectReverse] = false; - JsonConfig[CN_EffectMirror] = false; - JsonConfig[CN_EffectAllLeds] = true; - JsonConfig[CN_EffectBrightness] = map (pDevice->getValue (), 0, 255, 0, 100); - JsonConfig[CN_currenteffect] = F ("Solid"); - JsonConfig[CN_EffectColor] = HexColor; + JsonObject JsonConfig = JsonConfigDoc[(char*)CN_config].to (); + + JsonWrite(JsonConfig, CN_EffectSpeed, 1); + JsonWrite(JsonConfig, CN_EffectReverse, false); + JsonWrite(JsonConfig, CN_EffectMirror, false); + JsonWrite(JsonConfig, CN_EffectAllLeds, true); + JsonWrite(JsonConfig, CN_EffectBrightness, map (pDevice->getValue (), 0, 255, 0, 100)); + JsonWrite(JsonConfig, CN_currenteffect, F ("Solid")); + JsonWrite(JsonConfig, CN_EffectColor, HexColor); // DEBUG_V (String ("CN_EffectBrightness: ") + String (pDevice->getValue ())); // DEBUG_V (String ("getState: ") + String (pDevice->getState ())); diff --git a/src/input/InputArtnet.cpp b/src/input/InputArtnet.cpp index a1f5e73b7..5c65a8851 100644 --- a/src/input/InputArtnet.cpp +++ b/src/input/InputArtnet.cpp @@ -73,9 +73,9 @@ void c_InputArtnet::GetConfig (JsonObject & jsonConfig) { // DEBUG_START; - jsonConfig[CN_universe] = startUniverse; - jsonConfig[CN_universe_limit] = ChannelsPerUniverse; - jsonConfig[CN_universe_start] = FirstUniverseChannelOffset; + JsonWrite(jsonConfig, CN_universe, startUniverse); + JsonWrite(jsonConfig, CN_universe_limit, ChannelsPerUniverse); + JsonWrite(jsonConfig, CN_universe_start, FirstUniverseChannelOffset); // DEBUG_END; @@ -87,25 +87,25 @@ void c_InputArtnet::GetStatus (JsonObject & jsonStatus) // DEBUG_START; JsonObject ArtnetStatus = jsonStatus[F ("Artnet")].to (); - ArtnetStatus[CN_unifirst] = startUniverse; - ArtnetStatus[CN_unilast] = LastUniverse; - ArtnetStatus[CN_unichanlim] = ChannelsPerUniverse; + JsonWrite(ArtnetStatus, CN_unifirst, startUniverse); + JsonWrite(ArtnetStatus, CN_unilast, LastUniverse); + JsonWrite(ArtnetStatus, CN_unichanlim, ChannelsPerUniverse); // DEBUG_V (""); - ArtnetStatus[F ("lastData")] = lastData; - ArtnetStatus[CN_num_packets] = num_packets; - ArtnetStatus[CN_packet_errors] = packet_errors; - ArtnetStatus[CN_last_clientIP] = pArtnet->getRemoteIP().toString (); - ArtnetStatus[CN_PollCounter] = PollCounter; + JsonWrite(ArtnetStatus, F ("lastData"), lastData); + JsonWrite(ArtnetStatus, CN_num_packets, num_packets); + JsonWrite(ArtnetStatus, CN_packet_errors, packet_errors); + JsonWrite(ArtnetStatus, CN_last_clientIP, pArtnet->getRemoteIP().toString ()); + JsonWrite(ArtnetStatus, CN_PollCounter, PollCounter); - JsonArray ArtnetUniverseStatus = ArtnetStatus[CN_channels].to (); + JsonArray ArtnetUniverseStatus = ArtnetStatus[(char*)CN_channels].to (); for (auto & CurrentUniverse : UniverseArray) { JsonObject ArtnetCurrentUniverseStatus = ArtnetUniverseStatus.add (); - ArtnetCurrentUniverseStatus[CN_errors] = CurrentUniverse.SequenceErrorCounter; - ArtnetCurrentUniverseStatus[CN_num_packets] = CurrentUniverse.num_packets; + JsonWrite(ArtnetCurrentUniverseStatus, CN_errors, CurrentUniverse.SequenceErrorCounter); + JsonWrite(ArtnetCurrentUniverseStatus, CN_num_packets, CurrentUniverse.num_packets); } // DEBUG_END; diff --git a/src/input/InputDDP.cpp b/src/input/InputDDP.cpp index 75e989b45..b6076146d 100644 --- a/src/input/InputDDP.cpp +++ b/src/input/InputDDP.cpp @@ -92,11 +92,11 @@ void c_InputDDP::GetStatus (JsonObject& jsonStatus) JsonObject ddpStatus = jsonStatus[F ("ddp")].to (); // DEBUG_V (""); - ddpStatus["packetsreceived"] = stats.packetsReceived; - ddpStatus["bytesreceived"] = float(stats.bytesReceived) / 1024.0; - ddpStatus[CN_errors] = stats.errors; - ddpStatus[CN_id] = InputChannelId; - ddpStatus["lastError"] = lastError; + JsonWrite(ddpStatus, F("packetsreceived"), stats.packetsReceived); + JsonWrite(ddpStatus, F("bytesreceived"), float(stats.bytesReceived) / 1024.0); + JsonWrite(ddpStatus, CN_errors, stats.errors); + JsonWrite(ddpStatus, CN_id, InputChannelId); + JsonWrite(ddpStatus, F("lastError"), lastError); // DEBUG_END; @@ -323,21 +323,21 @@ void c_InputDDP::ProcessReceivedQuery () // DEBUG_V ("DDP_ID_CONFIG query"); JsonDocument JsonConfigDoc; - JsonObject JsonConfig = JsonConfigDoc[CN_config].to (); + JsonObject JsonConfig = JsonConfigDoc[(char*)CN_config].to (); String hostname; NetworkMgr.GetHostname (hostname); - JsonConfig[CN_hostname] = hostname; - JsonConfig[CN_id] = config.id; - JsonConfig[CN_ip] = NetworkMgr.GetlocalIP ().toString (); - JsonConfig[CN_version] = VERSION; - JsonConfig["hardwareType"] = FPP_VARIANT_NAME; - JsonConfig[CN_type] = FPP_TYPE_ID; - JsonConfig[CN_num_chan] = InputDataBufferSize; + JsonWrite(JsonConfig, CN_hostname, hostname); + JsonWrite(JsonConfig, CN_id, config.id); + JsonWrite(JsonConfig, CN_ip, NetworkMgr.GetlocalIP ().toString ()); + JsonWrite(JsonConfig, CN_version, VERSION); + JsonWrite(JsonConfig, F("hardwareType"), FPP_VARIANT_NAME); + JsonWrite(JsonConfig, CN_type, FPP_TYPE_ID); + JsonWrite(JsonConfig, CN_num_chan, InputDataBufferSize); uint16_t PixelPortCount; uint16_t SerialPortCount; OutputMgr.GetPortCounts (PixelPortCount, SerialPortCount); - JsonConfig["NumPixelPort"] = PixelPortCount; - JsonConfig["NumSerialPort"] = SerialPortCount; + JsonWrite(JsonConfig, F("NumPixelPort"), PixelPortCount); + JsonWrite(JsonConfig, F("NumSerialPort"), SerialPortCount); String JsonResponse; serializeJson (JsonConfigDoc, JsonResponse); diff --git a/src/input/InputDisabled.cpp b/src/input/InputDisabled.cpp index 7618bd34e..c6fb39932 100644 --- a/src/input/InputDisabled.cpp +++ b/src/input/InputDisabled.cpp @@ -58,7 +58,7 @@ void c_InputDisabled::GetStatus (JsonObject & jsonStatus) // DEBUG_START; JsonObject Status = jsonStatus[F ("disabled")].to (); - Status[CN_id] = InputChannelId; + JsonWrite(Status, CN_id, InputChannelId); // DEBUG_END; diff --git a/src/input/InputE131.cpp b/src/input/InputE131.cpp index 73586da4e..f44c153cf 100644 --- a/src/input/InputE131.cpp +++ b/src/input/InputE131.cpp @@ -78,10 +78,10 @@ void c_InputE131::GetConfig (JsonObject & jsonConfig) { // DEBUG_START; - jsonConfig[CN_universe] = startUniverse; - jsonConfig[CN_universe_limit] = ChannelsPerUniverse; - jsonConfig[CN_universe_start] = FirstUniverseChannelOffset; - jsonConfig[CN_port] = PortId; + JsonWrite(jsonConfig, CN_universe, startUniverse); + JsonWrite(jsonConfig, CN_universe_limit, ChannelsPerUniverse); + JsonWrite(jsonConfig, CN_universe_start, FirstUniverseChannelOffset); + JsonWrite(jsonConfig, CN_port, PortId); // DEBUG_END; @@ -92,27 +92,27 @@ void c_InputE131::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - JsonObject e131Status = jsonStatus[F ("e131")].to (); - e131Status[CN_id] = InputChannelId; - e131Status[CN_unifirst] = startUniverse; - e131Status[CN_unilast ] = LastUniverse; - e131Status[CN_unichanlim] = ChannelsPerUniverse; + JsonObject e131Status = jsonStatus[(char*)F ("e131")].to (); + JsonWrite(e131Status, CN_id, InputChannelId); + JsonWrite(e131Status, CN_unifirst, startUniverse); + JsonWrite(e131Status, CN_unilast, LastUniverse); + JsonWrite(e131Status, CN_unichanlim, ChannelsPerUniverse); - e131Status[CN_num_packets] = e131->stats.num_packets; - e131Status[CN_last_clientIP] = uint32_t(e131->stats.last_clientIP); + JsonWrite(e131Status, CN_num_packets, e131->stats.num_packets); + JsonWrite(e131Status, CN_last_clientIP, uint32_t(e131->stats.last_clientIP)); // DEBUG_V (""); - JsonArray e131UniverseStatus = e131Status[CN_channels].to (); + JsonArray e131UniverseStatus = e131Status[(char*)CN_channels].to (); uint32_t TotalErrors = 0; // e131->stats.packet_errors; for (auto & CurrentUniverse : UniverseArray) { JsonObject e131CurrentUniverseStatus = e131UniverseStatus.add (); - e131CurrentUniverseStatus[CN_errors] = CurrentUniverse.SequenceErrorCounter; + JsonWrite(e131CurrentUniverseStatus, CN_errors, CurrentUniverse.SequenceErrorCounter); TotalErrors += CurrentUniverse.SequenceErrorCounter; } - e131Status[CN_packet_errors] = TotalErrors; + JsonWrite(e131Status, CN_packet_errors, TotalErrors); // DEBUG_END; diff --git a/src/input/InputEffectEngine.cpp b/src/input/InputEffectEngine.cpp index 1d2e7eb62..ca795bda5 100644 --- a/src/input/InputEffectEngine.cpp +++ b/src/input/InputEffectEngine.cpp @@ -141,59 +141,59 @@ void c_InputEffectEngine::GetConfig (JsonObject& jsonConfig) ESP_ERROR_CHECK(saferRgbToHtmlColorString(HexColor, EffectColor.r, EffectColor.g, EffectColor.b)); // DEBUG_V (""); - jsonConfig[CN_currenteffect] = ActiveEffect->name; - jsonConfig[CN_EffectSpeed] = EffectSpeed; - jsonConfig[CN_EffectReverse] = EffectReverse; - jsonConfig[CN_EffectMirror] = EffectMirror; - jsonConfig[CN_EffectAllLeds] = EffectAllLeds; - jsonConfig[CN_EffectBrightness] = uint32_t(EffectBrightness * 100.0); - jsonConfig[CN_EffectWhiteChannel] = EffectWhiteChannel; - jsonConfig[CN_EffectColor] = HexColor; - jsonConfig[CN_pixel_count] = effectMarqueePixelAdvanceCount; - - jsonConfig["FlashEnable"] = FlashInfo.Enable; - jsonConfig["FlashMinInt"] = FlashInfo.MinIntensity; - jsonConfig["FlashMaxInt"] = FlashInfo.MaxIntensity; - jsonConfig["FlashMinDelay"] = FlashInfo.MinDelayMS; - jsonConfig["FlashMaxDelay"] = FlashInfo.MaxDelayMS; - jsonConfig["FlashMinDur"] = FlashInfo.MinDurationMS; - jsonConfig["FlashMaxDur"] = FlashInfo.MaxDurationMS; - jsonConfig["TransCount"] = TransitionInfo.StepsToTarget; - jsonConfig["TransDelay"] = TransitionInfo.TimeAtTargetMs; + JsonWrite(jsonConfig, CN_currenteffect, ActiveEffect->name); + JsonWrite(jsonConfig, CN_EffectSpeed, EffectSpeed); + JsonWrite(jsonConfig, CN_EffectReverse, EffectReverse); + JsonWrite(jsonConfig, CN_EffectMirror, EffectMirror); + JsonWrite(jsonConfig, CN_EffectAllLeds, EffectAllLeds); + JsonWrite(jsonConfig, CN_EffectBrightness, uint32_t(EffectBrightness * 100.0)); + JsonWrite(jsonConfig, CN_EffectWhiteChannel, EffectWhiteChannel); + JsonWrite(jsonConfig, CN_EffectColor, HexColor); + JsonWrite(jsonConfig, CN_pixel_count, effectMarqueePixelAdvanceCount); + + JsonWrite(jsonConfig, "FlashEnable", FlashInfo.Enable); + JsonWrite(jsonConfig, "FlashMinInt", FlashInfo.MinIntensity); + JsonWrite(jsonConfig, "FlashMaxInt", FlashInfo.MaxIntensity); + JsonWrite(jsonConfig, "FlashMinDelay", FlashInfo.MinDelayMS); + JsonWrite(jsonConfig, "FlashMaxDelay", FlashInfo.MaxDelayMS); + JsonWrite(jsonConfig, "FlashMinDur", FlashInfo.MinDurationMS); + JsonWrite(jsonConfig, "FlashMaxDur", FlashInfo.MaxDurationMS); + JsonWrite(jsonConfig, "TransCount", TransitionInfo.StepsToTarget); + JsonWrite(jsonConfig, "TransDelay", TransitionInfo.TimeAtTargetMs); // DEBUG_V (""); - JsonArray EffectsArray = jsonConfig[CN_effects].to (); + JsonArray EffectsArray = jsonConfig[(char*)CN_effects].to (); // DEBUG_V (""); for (EffectDescriptor_t currentEffect : ListOfEffects) { // DEBUG_V (""); JsonObject currentJsonEntry = EffectsArray.add (); - currentJsonEntry[CN_name] = currentEffect.name; + JsonWrite(currentJsonEntry, CN_name, currentEffect.name); } - JsonArray TransitionsArray = jsonConfig[CN_transitions].to (); + JsonArray TransitionsArray = jsonConfig[(char*)CN_transitions].to (); for (auto currentTransition : TransitionColorTable) { // DEBUG_V (""); JsonObject currentJsonEntry = TransitionsArray.add (); - currentJsonEntry["r"] = currentTransition.r; - currentJsonEntry["g"] = currentTransition.g; - currentJsonEntry["b"] = currentTransition.b; + JsonWrite(currentJsonEntry, CN_r, currentTransition.r); + JsonWrite(currentJsonEntry, CN_g, currentTransition.g); + JsonWrite(currentJsonEntry, CN_b, currentTransition.b); } - JsonArray MarqueeGroupArray = jsonConfig[CN_MarqueeGroups].to (); + JsonArray MarqueeGroupArray = jsonConfig[(char*)CN_MarqueeGroups].to (); for(auto CurrentMarqueeGroup : MarqueueGroupTable) { 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; - currentJsonEntry[CN_brightness] = CurrentMarqueeGroup.StartingIntensity; - currentJsonEntry[CN_pixel_count] = CurrentMarqueeGroup.NumPixelsInGroup; - currentJsonEntry[CN_brightnessEnd] = CurrentMarqueeGroup.EndingIntensity; + JsonObject currentJsonEntryColor = currentJsonEntry[(char*)CN_color].to (); + JsonWrite(currentJsonEntryColor, CN_r, CurrentMarqueeGroup.Color.r); + JsonWrite(currentJsonEntryColor, CN_g, CurrentMarqueeGroup.Color.g); + JsonWrite(currentJsonEntryColor, CN_b, CurrentMarqueeGroup.Color.b); + JsonWrite(currentJsonEntry, CN_brightness, CurrentMarqueeGroup.StartingIntensity); + JsonWrite(currentJsonEntry, CN_pixel_count, CurrentMarqueeGroup.NumPixelsInGroup); + JsonWrite(currentJsonEntry, CN_brightnessEnd, CurrentMarqueeGroup.EndingIntensity); } // DEBUG_END; @@ -204,7 +204,7 @@ void c_InputEffectEngine::GetConfig (JsonObject& jsonConfig) void c_InputEffectEngine::GetMqttEffectList (JsonObject& jsonConfig) { // DEBUG_START; - JsonArray EffectsArray = jsonConfig[CN_effect_list].to (); + JsonArray EffectsArray = jsonConfig[(char*)CN_effect_list].to (); for (EffectDescriptor_t currentEffect : ListOfEffects) { @@ -237,9 +237,9 @@ void c_InputEffectEngine::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - JsonObject Status = jsonStatus[F ("effects")].to (); - Status[CN_currenteffect] = ActiveEffect->name; - Status[CN_id] = InputChannelId; + JsonObject Status = jsonStatus[(char*)CN_effects].to (); + JsonWrite(Status, CN_currenteffect, ActiveEffect->name); + JsonWrite(Status, CN_id, InputChannelId); // DEBUG_END; @@ -536,7 +536,7 @@ bool c_InputEffectEngine::SetConfig (ArduinoJson::JsonObject& jsonConfig) FlashInfo.MinIntensity = FlashInfo.MaxIntensity; } - JsonArray TransitionsArray = jsonConfig[CN_transitions]; + JsonArray TransitionsArray = jsonConfig[(char*)CN_transitions]; if(TransitionsArray) { TransitionColorTable.clear(); @@ -557,7 +557,7 @@ bool c_InputEffectEngine::SetConfig (ArduinoJson::JsonObject& jsonConfig) } } - JsonArray MarqueeGroupArray = jsonConfig[CN_MarqueeGroups]; + JsonArray MarqueeGroupArray = jsonConfig[(char*)CN_MarqueeGroups]; if(MarqueeGroupArray) { MarqueueGroupTable.clear(); @@ -567,7 +567,7 @@ bool c_InputEffectEngine::SetConfig (ArduinoJson::JsonObject& jsonConfig) MarqueeGroup NewGroup; JsonObject currentMarqueeGroup = _MarqueeGroup.as(); // DEBUG_V (""); - JsonObject GroupColor = currentMarqueeGroup[CN_color]; + JsonObject GroupColor = currentMarqueeGroup[(char*)CN_color]; setFromJSON (NewGroup.Color.r, GroupColor, "r"); setFromJSON (NewGroup.Color.g, GroupColor, "g"); setFromJSON (NewGroup.Color.b, GroupColor, "b"); diff --git a/src/input/InputFPPRemote.cpp b/src/input/InputFPPRemote.cpp index 6cdb789a5..f8a6bf8c2 100644 --- a/src/input/InputFPPRemote.cpp +++ b/src/input/InputFPPRemote.cpp @@ -67,15 +67,15 @@ void c_InputFPPRemote::GetConfig (JsonObject& jsonConfig) if (PlayingFile ()) { - jsonConfig[JSON_NAME_FILE_TO_PLAY] = pInputFPPRemotePlayItem->GetFileName (); + JsonWrite(jsonConfig, JSON_NAME_FILE_TO_PLAY, pInputFPPRemotePlayItem->GetFileName ()); } else { - jsonConfig[JSON_NAME_FILE_TO_PLAY] = No_LocalFileToPlay; + JsonWrite(jsonConfig, JSON_NAME_FILE_TO_PLAY, No_LocalFileToPlay); } - jsonConfig[CN_SyncOffset] = SyncOffsetMS; - jsonConfig[CN_SendFppSync] = SendFppSync; - jsonConfig[CN_blankOnStop] = FPPDiscovery.GetBlankOnStop(); + JsonWrite(jsonConfig, CN_SyncOffset, SyncOffsetMS); + JsonWrite(jsonConfig, CN_SendFppSync, SendFppSync); + JsonWrite(jsonConfig, CN_blankOnStop, FPPDiscovery.GetBlankOnStop()); // DEBUG_END; @@ -87,8 +87,8 @@ void c_InputFPPRemote::GetStatus (JsonObject& jsonStatus) // DEBUG_START; JsonObject LocalPlayerStatus = jsonStatus[F ("Player")].to (); - LocalPlayerStatus[CN_id] = InputChannelId; - LocalPlayerStatus[CN_active] = PlayingFile (); + JsonWrite(LocalPlayerStatus, CN_id, InputChannelId); + JsonWrite(LocalPlayerStatus, CN_active, PlayingFile ()); if (PlayingRemoteFile ()) { diff --git a/src/input/InputFPPRemotePlayEffectFsm.cpp b/src/input/InputFPPRemotePlayEffectFsm.cpp index f4e6bc35a..6010131d2 100644 --- a/src/input/InputFPPRemotePlayEffectFsm.cpp +++ b/src/input/InputFPPRemotePlayEffectFsm.cpp @@ -109,7 +109,7 @@ void fsm_PlayEffect_state_Idle::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - jsonStatus[CN_TimeRemaining] = F ("00:00"); + JsonWrite(jsonStatus, CN_TimeRemaining, F ("00:00")); // DEBUG_END; @@ -198,7 +198,7 @@ void fsm_PlayEffect_state_PlayingEffect::GetStatus (JsonObject& jsonStatus) char buf[12]; ESP_ERROR_CHECK(saferSecondsToFormattedMinutesAndSecondsString(buf, (uint32_t)SecondsRemaining)); - jsonStatus[CN_TimeRemaining] = buf; + JsonWrite(jsonStatus, CN_TimeRemaining, buf); p_InputFPPRemotePlayEffect->EffectsEngine.GetStatus (jsonStatus); diff --git a/src/input/InputFPPRemotePlayFile.cpp b/src/input/InputFPPRemotePlayFile.cpp index f22f0bbec..30a55bb96 100644 --- a/src/input/InputFPPRemotePlayFile.cpp +++ b/src/input/InputFPPRemotePlayFile.cpp @@ -143,29 +143,28 @@ void c_InputFPPRemotePlayFile::GetStatus (JsonObject& JsonStatus) secsRem = 0; // set to zero remaining seconds when overflow occurs } - JsonStatus[F ("SyncCount")] = SyncControl.SyncCount; - JsonStatus[F ("SyncAdjustmentCount")] = SyncControl.SyncAdjustmentCount; + JsonWrite(JsonStatus, F ("SyncCount"), SyncControl.SyncCount); + JsonWrite(JsonStatus, F ("SyncAdjustmentCount"), SyncControl.SyncAdjustmentCount); String temp = GetFileName (); - JsonStatus[CN_current_sequence] = temp; - JsonStatus[CN_playlist] = temp; - JsonStatus[CN_seconds_elapsed] = String (secs); - JsonStatus[CN_seconds_played] = String (secs); - JsonStatus[CN_seconds_remaining] = String (secsRem); - JsonStatus[CN_sequence_filename] = temp; - JsonStatus[F("PlayedFileCount")] = PlayedFileCount; + JsonWrite(JsonStatus, CN_current_sequence, temp); + JsonWrite(JsonStatus, CN_playlist, temp); + JsonWrite(JsonStatus, CN_seconds_elapsed, String (secs)); + JsonWrite(JsonStatus, CN_seconds_played, String (secs)); + JsonWrite(JsonStatus, CN_seconds_remaining, String (secsRem)); + JsonWrite(JsonStatus, CN_sequence_filename, temp); + JsonWrite(JsonStatus, F("PlayedFileCount"), PlayedFileCount); // After inserting the total seconds and total seconds remaining, // JsonStatus also includes formatted "minutes + seconds" for both // time Elapsed and time Remaining char buf[12]; ESP_ERROR_CHECK(saferSecondsToFormattedMinutesAndSecondsString(buf, secs)); - JsonStatus[CN_time_elapsed] = buf; + JsonWrite(JsonStatus, CN_time_elapsed, buf); ESP_ERROR_CHECK(saferSecondsToFormattedMinutesAndSecondsString(buf, secsRem)); - JsonStatus[CN_time_remaining] = buf; - - JsonStatus[CN_errors] = LastFailedPlayStatusMsg; + JsonWrite(JsonStatus, CN_time_remaining, buf); + JsonWrite(JsonStatus, CN_errors, LastFailedPlayStatusMsg); // xDEBUG_END; diff --git a/src/input/InputFPPRemotePlayList.cpp b/src/input/InputFPPRemotePlayList.cpp index cb8af6264..c5f94ef3f 100644 --- a/src/input/InputFPPRemotePlayList.cpp +++ b/src/input/InputFPPRemotePlayList.cpp @@ -106,9 +106,9 @@ void c_InputFPPRemotePlayList::GetStatus (JsonObject & jsonStatus) { // DEBUG_START; - jsonStatus[CN_name] = GetFileName (); - jsonStatus[F ("entry")] = PlayListEntryId; - jsonStatus[CN_count] = PlayListRepeatCount; + JsonWrite(jsonStatus, CN_name, GetFileName ()); + JsonWrite(jsonStatus, CN_entry, PlayListEntryId); + JsonWrite(jsonStatus, CN_count, PlayListRepeatCount); pCurrentFsmState->GetStatus (jsonStatus); @@ -206,7 +206,7 @@ bool c_InputFPPRemotePlayList::ProcessPlayListEntry () else if (String (CN_effect) == PlayListEntryType) { - JsonObject EffectConfig = JsonPlayListArrayEntry[CN_config]; + JsonObject EffectConfig = JsonPlayListArrayEntry[(char*)CN_config].to(); serializeJson (EffectConfig, PlayListEntryName); FrameId = 10; diff --git a/src/input/InputFPPRemotePlayListFsm.cpp b/src/input/InputFPPRemotePlayListFsm.cpp index c7fcd11ab..aeb4401d4 100644 --- a/src/input/InputFPPRemotePlayListFsm.cpp +++ b/src/input/InputFPPRemotePlayListFsm.cpp @@ -84,7 +84,7 @@ void fsm_PlayList_state_WaitForStart::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - // JsonObject FileStatus = jsonStatus[CN_Idle].to (); + // JsonObject FileStatus = jsonStatus[(char*)CN_Idle].to (); // DEBUG_END; @@ -144,7 +144,7 @@ void fsm_PlayList_state_Idle::GetStatus (JsonObject& jsonStatus) { // DEBUG_START; - // JsonObject FileStatus = jsonStatus[CN_Idle].to (); + // JsonObject FileStatus = jsonStatus[(char*)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[CN_File].to (); + JsonObject FileStatus = jsonStatus[(char*)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[CN_Effect].to (); + JsonObject EffectStatus = jsonStatus[(char*)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[CN_Paused].to (); + JsonObject PauseStatus = jsonStatus[(char*)CN_Paused].to (); time_t SecondsRemaining = pInputFPPRemotePlayList->PauseDelayTimer.GetTimeRemaining() / 1000u; diff --git a/src/input/InputMQTT.cpp b/src/input/InputMQTT.cpp index d2c3b469c..f960d7049 100644 --- a/src/input/InputMQTT.cpp +++ b/src/input/InputMQTT.cpp @@ -123,19 +123,19 @@ void c_InputMQTT::GetConfig (JsonObject & jsonConfig) // DEBUG_START; // Serialize Config - jsonConfig[CN_ip] = ip; - jsonConfig[CN_port] = port; - jsonConfig[CN_user] = user; - jsonConfig[CN_password] = password; - jsonConfig[CN_topic] = topic; + JsonWrite(jsonConfig, CN_ip, ip); + JsonWrite(jsonConfig, CN_port, port); + JsonWrite(jsonConfig, CN_user, user); + JsonWrite(jsonConfig, CN_password, password); + JsonWrite(jsonConfig, CN_topic, topic); #ifdef SUPPORT_SENSOR_DS18B20 - jsonConfig[CN_tsensortopic] = TemperatureSensorTopic; + JsonWrite(jsonConfig, CN_tsensortopic, TemperatureSensorTopic); #endif // def SUPPORT_SENSOR_DS18B20 - jsonConfig[CN_clean] = CleanSessionRequired; - jsonConfig[CN_hadisco] = hadisco; - jsonConfig[CN_haprefix] = haprefix; - jsonConfig[CN_effects] = true; - jsonConfig[CN_play] = true; + JsonWrite(jsonConfig, CN_clean, CleanSessionRequired); + JsonWrite(jsonConfig, CN_hadisco, hadisco); + JsonWrite(jsonConfig, CN_haprefix, haprefix); + JsonWrite(jsonConfig, CN_effects, true); + JsonWrite(jsonConfig, CN_play, true); // DEBUG_END; @@ -147,7 +147,7 @@ void c_InputMQTT::GetStatus (JsonObject & jsonStatus) // DEBUG_START; JsonObject Status = jsonStatus[F ("mqtt")].to (); - Status[CN_id] = InputChannelId; + JsonWrite(Status, CN_id, InputChannelId); // DEBUG_END; @@ -614,29 +614,31 @@ void c_InputMQTT::GetEngineConfig (JsonObject & JsonConfig) { // DEBUG_V ("Effects engine running"); ((c_InputEffectEngine*)(pEffectsEngine))->GetMqttConfig (effectConfig); - } else { + } + else + { // DEBUG_V ("Effects engine not running"); } - JsonConfig[CN_effect] = effectConfig.effect; - JsonConfig[CN_mirror] = effectConfig.mirror; - JsonConfig[CN_allleds] = effectConfig.allLeds; - JsonConfig[CN_brightness] = effectConfig.brightness; - JsonConfig[CN_EffectWhiteChannel] = effectConfig.whiteChannel; + JsonWrite(JsonConfig, CN_effect, effectConfig.effect); + JsonWrite(JsonConfig, CN_mirror, effectConfig.mirror); + JsonWrite(JsonConfig, CN_allleds, effectConfig.allLeds); + JsonWrite(JsonConfig, CN_brightness, effectConfig.brightness); + JsonWrite(JsonConfig, CN_EffectWhiteChannel, effectConfig.whiteChannel); - JsonObject color = JsonConfig[CN_color].to (); - color[CN_r] = effectConfig.color.r; - color[CN_g] = effectConfig.color.g; - color[CN_b] = effectConfig.color.b; + JsonObject color = JsonConfig[(char*)CN_color].to (); + JsonWrite(color, CN_r, effectConfig.color.r); + JsonWrite(color, CN_g, effectConfig.color.g); + JsonWrite(color, CN_b, effectConfig.color.b); if (nullptr != pPlayFileEngine) { - JsonConfig[CN_effect] = CN_playFseq; - JsonConfig[CN_filename] = pPlayFileEngine->GetFileName (); + JsonWrite(JsonConfig, CN_effect, String(CN_playFseq)); + JsonWrite(JsonConfig, CN_filename, pPlayFileEngine->GetFileName ()); } else { - JsonConfig[CN_filename] = String (""); + JsonWrite(JsonConfig, CN_filename, emptyString); } // DEBUG_END; @@ -658,9 +660,9 @@ void c_InputMQTT::GetEffectList (JsonObject & JsonConfig) } // DEBUG_V (""); - JsonConfig[CN_brightness] = CN_true; + JsonWrite(JsonConfig, CN_brightness, String(CN_true)); ((c_InputEffectEngine*)(pEffectsEngine))->GetMqttEffectList (JsonConfig); - JsonConfig[CN_effect] = CN_true; + JsonWrite(JsonConfig, CN_effect, String(CN_true)); if (!EffectEngineIsRunning) { @@ -668,7 +670,7 @@ void c_InputMQTT::GetEffectList (JsonObject & JsonConfig) pEffectsEngine = nullptr; } - JsonConfig[CN_effect_list].add (CN_playFseq); + JsonConfig[(char*)CN_effect_list].add ((char*)CN_playFseq); // add the file play fields. // DEBUG_END; @@ -697,29 +699,29 @@ void c_InputMQTT::publishHA() JsonDocument root; JsonObject JsonConfig = root.to (); - JsonConfig[F ("platform")] = F ("MQTT"); - JsonConfig[CN_name] = config.id; - JsonConfig[F ("schema")] = F ("json"); - JsonConfig[F ("state_topic")] = topic; - JsonConfig[F ("command_topic")] = lwtTopic; - JsonConfig[F ("availability_topic")] = lwtTopic; - JsonConfig[F ("rgb")] = CN_true; + JsonWrite(JsonConfig, F ("platform"), F ("MQTT")); + JsonWrite(JsonConfig, CN_name, config.id); + JsonWrite(JsonConfig, F ("schema"), F ("json")); + JsonWrite(JsonConfig, F ("state_topic"), topic); + JsonWrite(JsonConfig, F ("command_topic"), lwtTopic); + JsonWrite(JsonConfig, F ("availability_topic"), lwtTopic); + JsonWrite(JsonConfig, F ("rgb"), String(CN_true)); GetEffectList (JsonConfig); // Register the attributes topic - JsonConfig[F ("json_attributes_topic")] = topic + F ("/attributes"); + JsonWrite(JsonConfig, F ("json_attributes_topic"), topic + F ("/attributes")); // Create a unique id using the chip id, and fill in the device properties // to enable integration support in HomeAssistant. - JsonConfig[F ("unique_id")] = CN_ESPixelStick + chipId; + JsonWrite(JsonConfig, F ("unique_id"), CN_ESPixelStick + chipId); - JsonObject device = JsonConfig[CN_device].to (); - device[F ("identifiers")] = WiFi.macAddress (); - device[F ("manufacturer")] = F ("Forkineye"); - device[F ("model")] = CN_ESPixelStick; - device[CN_name] = config.id; - device[F ("sw_version")] = String (CN_ESPixelStick) + " v" + VERSION; + JsonObject device = JsonConfig[(char*)CN_device].to (); + JsonWrite(device, F ("identifiers"), WiFi.macAddress ()); + JsonWrite(device, F ("manufacturer"), F ("Forkineye")); + JsonWrite(device, F ("model"), String(CN_ESPixelStick)); + JsonWrite(device, CN_name, config.id); + JsonWrite(device, F ("sw_version"), String (CN_ESPixelStick) + " v" + VERSION); String HaJsonConfig; serializeJson(JsonConfig, HaJsonConfig); @@ -745,7 +747,7 @@ void c_InputMQTT::publishState() JsonDocument root; JsonObject JsonConfig = root[F ("MQTT")].to(); - JsonConfig[CN_state] = (true == stateOn) ? String(ON) : String(OFF); + JsonWrite(JsonConfig, CN_state, String((true == stateOn) ? ON : OFF)); // populate the effect information GetEngineConfig (JsonConfig); @@ -803,7 +805,7 @@ void c_InputMQTT::UpdateEffectConfiguration (JsonObject & JsonConfig) setFromJSON (effectConfig.brightness, JsonConfig, CN_brightness); setFromJSON (effectConfig.whiteChannel, JsonConfig, CN_EffectWhiteChannel); - JsonObject JsonColor = JsonConfig[CN_color]; + JsonObject JsonColor = JsonConfig[(char*)CN_color].to(); if (JsonColor) { setFromJSON (effectConfig.color.r, JsonColor, CN_r); diff --git a/src/input/InputMgr.cpp b/src/input/InputMgr.cpp index eb73ced5d..4972e8feb 100644 --- a/src/input/InputMgr.cpp +++ b/src/input/InputMgr.cpp @@ -224,12 +224,12 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) // DEBUG_V (""); // add the channels header - JsonObject InputMgrChannelsData = jsonConfig[CN_channels]; + JsonObject InputMgrChannelsData = jsonConfig[(char*)CN_channels]; if (!InputMgrChannelsData) { // add our section header // DEBUG_V (""); - InputMgrChannelsData = jsonConfig[CN_channels].to (); + InputMgrChannelsData = jsonConfig[(char*)CN_channels].to (); } // add the channel configurations @@ -254,7 +254,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) } // save the name as the selected channel type - ChannelConfigData[CN_type] = int (CurrentChannel.pInputChannelDriver->GetInputType ()); + JsonWrite(ChannelConfigData, CN_type, int (CurrentChannel.pInputChannelDriver->GetInputType ())); String DriverTypeId = String (int (CurrentChannel.pInputChannelDriver->GetInputType ())); JsonObject ChannelConfigByTypeData = ChannelConfigData[(String (DriverTypeId))]; @@ -270,7 +270,7 @@ void c_InputMgr::CreateJsonConfig (JsonObject & jsonConfig) // Populate the driver name String DriverName = ""; CurrentChannel.pInputChannelDriver->GetDriverName (DriverName); - ChannelConfigByTypeData[CN_type] = DriverName; + JsonWrite(ChannelConfigByTypeData, CN_type, DriverName); CurrentChannel.pInputChannelDriver->GetConfig (ChannelConfigByTypeData); // DEBUG_V (""); @@ -300,10 +300,10 @@ void c_InputMgr::CreateNewConfig () JsonDocument JsonConfigDoc; // DEBUG_V(""); - JsonObject JsonConfig = JsonConfigDoc[CN_input_config].to(); + JsonObject JsonConfig = JsonConfigDoc[(char*)CN_input_config].to(); // DEBUG_V(""); - JsonConfig[CN_cfgver] = CurrentConfigVersion; + JsonWrite(JsonConfig, CN_cfgver, CurrentConfigVersion); // DEBUG_V ("for each Input type"); for (int InputTypeId = int (InputType_Start); @@ -784,7 +784,7 @@ bool c_InputMgr::FindJsonChannelConfig (JsonObject& jsonConfig, do // once { - JsonObject InputChannelMgrData = jsonConfig[CN_input_config]; + JsonObject InputChannelMgrData = jsonConfig[(char*)CN_input_config]; if (!InputChannelMgrData) { logcon (String (F ("No Input Interface Settings Found. Using Defaults"))); @@ -819,7 +819,7 @@ bool c_InputMgr::FindJsonChannelConfig (JsonObject& jsonConfig, } // do we have a channel configuration array? - JsonObject InputChannelArray = InputChannelMgrData[CN_channels]; + JsonObject InputChannelArray = InputChannelMgrData[(char*)CN_channels]; if (!InputChannelArray) { // if not, flag an error and stop processing diff --git a/src/input/externalInput.cpp b/src/input/externalInput.cpp index d04375a52..b9c018b08 100644 --- a/src/input/externalInput.cpp +++ b/src/input/externalInput.cpp @@ -68,12 +68,12 @@ void c_ExternalInput::GetConfig (JsonObject JsonData) { // DEBUG_START; - JsonData[CN_enabled] = Enabled; - JsonData[CN_name] = name; - JsonData[CN_id] = GpioId; - JsonData[CN_polarity] = (ActiveHigh == polarity) ? CN_ActiveHigh : CN_ActiveLow; - JsonData[CN_channels] = TriggerChannel; - JsonData[CN_long] = LongPushDelayMS; + JsonWrite(JsonData, CN_enabled, Enabled); + JsonWrite(JsonData, CN_name, name); + JsonWrite(JsonData, CN_id, GpioId); + JsonWrite(JsonData, CN_polarity, String((ActiveHigh == polarity) ? CN_ActiveHigh : CN_ActiveLow)); + JsonWrite(JsonData, CN_channels, TriggerChannel); + JsonWrite(JsonData, CN_long, LongPushDelayMS); // DEBUG_V (String ("m_iPinId: ") + String (m_iPinId)); @@ -86,8 +86,8 @@ void c_ExternalInput::GetStatistics (JsonObject JsonData) { // DEBUG_START; - JsonData[CN_id] = GpioId; - JsonData[CN_state] = (ReadInput()) ? CN_on : CN_off; + JsonWrite(JsonData, CN_id, GpioId); + JsonWrite(JsonData, CN_state, String((ReadInput()) ? CN_on : CN_off)); // DEBUG_END; diff --git a/src/main.cpp b/src/main.cpp index a7f4bbe9d..f18fb0282 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -261,7 +261,7 @@ bool dsDevice(JsonObject & json) // PrettyPrint (json, "dsDevice"); bool ConfigChanged = false; - JsonObject JsonDeviceConfig = json[CN_device]; + JsonObject JsonDeviceConfig = json[(char*)CN_device]; if (JsonDeviceConfig) { // PrettyPrint(JsonDeviceConfig, "device"); @@ -304,9 +304,9 @@ bool deserializeCore (JsonObject & json) bool DataHasBeenAccepted = false; // PrettyPrint (json, "Main Config"); - JsonObject SystemConfig = json[CN_system]; - JsonObject InitConfig = json[CN_init]; - JsonObject NetworkConfig = json[CN_network]; + JsonObject SystemConfig = json[(char*)CN_system]; + JsonObject InitConfig = json[(char*)CN_init]; + JsonObject NetworkConfig = json[(char*)CN_network]; JsonObject DeviceConfig; do // once @@ -315,7 +315,7 @@ bool deserializeCore (JsonObject & json) if (SystemConfig) { // DEBUG_V("Detected a System Config"); - DeviceConfig = json[CN_system]; + DeviceConfig = json[(char*)CN_system]; // PrettyPrint (DeviceConfig, "System based DeviceConfig"); } // is this an initial config from the flash tool? @@ -399,7 +399,7 @@ void SaveConfig() // Create buffer and root object JsonDocument jsonConfigDoc; - JsonObject JsonConfig = jsonConfigDoc[CN_system].to(); + JsonObject JsonConfig = jsonConfigDoc[(char*)CN_system].to(); GetConfig(JsonConfig); @@ -441,12 +441,12 @@ void GetConfig (JsonObject & json) // DEBUG_START; // Config Version - json[CN_cfgver] = CurrentConfigVersion; + json[(char*)CN_cfgver] = CurrentConfigVersion; // Device - JsonObject device = json[CN_device].to(); - device[CN_id] = config.id; - device[CN_blanktime] = config.BlankDelay; + JsonObject device = json[(char*)CN_device].to(); + JsonWrite(device, CN_id, config.id); + JsonWrite(device, CN_blanktime, config.BlankDelay); // PrettyPrint(device, "device"); diff --git a/src/network/EthernetDriver.cpp b/src/network/EthernetDriver.cpp index d8910ab3c..e11f31437 100644 --- a/src/network/EthernetDriver.cpp +++ b/src/network/EthernetDriver.cpp @@ -128,21 +128,21 @@ void c_EthernetDriver::GetConfig (JsonObject& json) { // DEBUG_START; - 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; - json[CN_addr] = phy_addr; - json[CN_power_pin] = power_pin; - json[CN_mode] = clk_mode; - json[CN_mdc_pin] = mdc_pin; - json[CN_mdio_pin] = mdio_pin; - json[CN_activevalue] = powerPinActiveValue; - json[CN_activedelay] = powerPinActiveDelayMs; + JsonWrite(json, CN_ip, ip.toString ()); + JsonWrite(json, CN_netmask, netmask.toString ()); + JsonWrite(json, CN_gateway, gateway.toString ()); + JsonWrite(json, CN_dnsp, primaryDns.toString ()); + JsonWrite(json, CN_dnss, secondaryDns.toString ()); + JsonWrite(json, CN_dhcp, UseDhcp); + + JsonWrite(json, CN_type, phy_type); + JsonWrite(json, CN_addr, phy_addr); + JsonWrite(json, CN_power_pin, power_pin); + JsonWrite(json, CN_mode, clk_mode); + JsonWrite(json, CN_mdc_pin, mdc_pin); + JsonWrite(json, CN_mdio_pin, mdio_pin); + JsonWrite(json, CN_activevalue, powerPinActiveValue); + JsonWrite(json, CN_activedelay, powerPinActiveDelayMs); // DEBUG_END; @@ -185,14 +185,12 @@ void c_EthernetDriver::GetStatus (JsonObject& jsonStatus) String Hostname; GetHostname (Hostname); - jsonStatus[CN_hostname] = Hostname; - - jsonStatus[CN_ip] = GetIpAddress ().toString (); - jsonStatus[CN_subnet] = GetIpSubNetMask ().toString (); - jsonStatus[CN_mac] = GetMacAddress (); - jsonStatus[CN_gateway] = GetIpGateway (); - - jsonStatus[CN_connected] = IsConnected (); + JsonWrite(jsonStatus, CN_hostname, Hostname); + JsonWrite(jsonStatus, CN_ip, GetIpAddress ().toString ()); + JsonWrite(jsonStatus, CN_subnet, GetIpSubNetMask ().toString ()); + JsonWrite(jsonStatus, CN_mac, GetMacAddress ()); + JsonWrite(jsonStatus, CN_gateway, GetIpGateway ()); + JsonWrite(jsonStatus, CN_connected, IsConnected ()); // DEBUG_END; } // GetStatus diff --git a/src/network/NetworkMgr.cpp b/src/network/NetworkMgr.cpp index ddfcbb702..68804c42b 100644 --- a/src/network/NetworkMgr.cpp +++ b/src/network/NetworkMgr.cpp @@ -92,17 +92,17 @@ void c_NetworkMgr::GetConfig (JsonObject & json) { // DEBUG_START; - JsonObject NetworkConfig = json[CN_network].to (); + JsonObject NetworkConfig = json[(char*)CN_network].to (); - NetworkConfig[CN_hostname] = hostname; + JsonWrite(NetworkConfig, CN_hostname, hostname); - JsonObject NetworkWiFiConfig = NetworkConfig[CN_wifi].to (); + JsonObject NetworkWiFiConfig = NetworkConfig[(char*)CN_wifi].to (); WiFiDriver.GetConfig (NetworkWiFiConfig); #ifdef SUPPORT_ETHERNET - NetworkConfig[CN_weus] = AllowWiFiAndEthUpSimultaneously; + JsonWrite(NetworkConfig, CN_weus, AllowWiFiAndEthUpSimultaneously); - JsonObject NetworkEthConfig = NetworkConfig[CN_eth].to (); + JsonObject NetworkEthConfig = NetworkConfig[(char*)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[CN_network].to (); + JsonObject NetworkStatus = json[(char*)CN_network].to (); String name; GetHostname (name); - NetworkStatus[CN_hostname] = name; + JsonWrite(NetworkStatus, CN_hostname, name); - JsonObject NetworkWiFiStatus = NetworkStatus[CN_wifi].to (); + JsonObject NetworkWiFiStatus = NetworkStatus[(char*)CN_wifi].to (); WiFiDriver.GetStatus (NetworkWiFiStatus); #ifdef SUPPORT_ETHERNET - JsonObject NetworkEthStatus = NetworkStatus[CN_eth].to (); + JsonObject NetworkEthStatus = NetworkStatus[(char*)CN_eth].to (); EthernetDriver.GetStatus (NetworkEthStatus); #endif // def SUPPORT_ETHERNET @@ -165,7 +165,7 @@ bool c_NetworkMgr::SetConfig (JsonObject & json) do // once { - JsonObject network = json[CN_network]; + JsonObject network = json[(char*)CN_network]; if (!network) { logcon (String (F ("No network config found. Use default settings"))); @@ -178,7 +178,7 @@ bool c_NetworkMgr::SetConfig (JsonObject & json) HostnameChanged = setFromJSON (hostname, network, CN_hostname); // DEBUG_V(""); - JsonObject networkWiFi = network[CN_wifi]; + JsonObject networkWiFi = network[(char*)CN_wifi]; if (networkWiFi) { // DEBUG_V(""); @@ -187,7 +187,7 @@ bool c_NetworkMgr::SetConfig (JsonObject & json) else { // DEBUG_V(""); - JsonObject ssid = network[CN_ssid]; + JsonObject ssid = network[(char*)CN_ssid]; // this may be an old style config if (!ssid) { @@ -205,7 +205,7 @@ bool c_NetworkMgr::SetConfig (JsonObject & json) #ifdef SUPPORT_ETHERNET ConfigChanged = setFromJSON (AllowWiFiAndEthUpSimultaneously, network, CN_weus); - JsonObject networkEth = network[CN_eth]; + JsonObject networkEth = network[(char*)CN_eth]; if (networkEth) { ConfigChanged |= EthernetDriver.SetConfig (networkEth); diff --git a/src/network/WiFiDriver.cpp b/src/network/WiFiDriver.cpp index a1a10ce8d..57dc3dba0 100644 --- a/src/network/WiFiDriver.cpp +++ b/src/network/WiFiDriver.cpp @@ -312,37 +312,37 @@ void c_WiFiDriver::GetConfig (JsonObject& json) { // DEBUG_START; - json[CN_ssid] = ssid; - json[CN_passphrase] = passphrase; - json[CN_ap_ssid] = ap_ssid; - json[CN_ap_passphrase] = ap_passphrase; + JsonWrite(json, CN_ssid, ssid); + JsonWrite(json, CN_passphrase, passphrase); + JsonWrite(json, CN_ap_ssid, ap_ssid); + JsonWrite(json, CN_ap_passphrase, ap_passphrase); #ifdef ARDUINO_ARCH_ESP8266 IPAddress Temp = ip; - json[CN_ip] = Temp.toString (); + JsonWrite(json, CN_ip, Temp.toString ()); Temp = netmask; - json[CN_netmask] = Temp.toString (); + JsonWrite(json, CN_netmask, Temp.toString ()); Temp = gateway; - json[CN_gateway] = Temp.toString (); + JsonWrite(json, CN_gateway, Temp.toString ()); Temp = primaryDns; - json[CN_dnsp] = Temp.toString (); + JsonWrite(json, CN_dnsp, Temp.toString ()); Temp = secondaryDns; - json[CN_dnss] = Temp.toString (); + JsonWrite(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 (); + JsonWrite(json, CN_ip, ip.toString ()); + JsonWrite(json, CN_netmask, netmask.toString ()); + JsonWrite(json, CN_gateway, gateway.toString ()); + JsonWrite(json, CN_dnsp, primaryDns.toString ()); + JsonWrite(json, CN_dnss, secondaryDns.toString ()); #endif // !def ARDUINO_ARCH_ESP8266 - json[CN_StayInApMode] = StayInApMode; - json[CN_dhcp] = UseDhcp; - json[CN_sta_timeout] = sta_timeout; - json[CN_ap_channel] = ap_channelNumber; - json[CN_ap_fallback] = ap_fallbackIsEnabled; - json[CN_ap_timeout] = ap_timeout; - json[CN_ap_reboot] = RebootOnWiFiFailureToConnect; + JsonWrite(json, CN_StayInApMode, StayInApMode); + JsonWrite(json, CN_dhcp, UseDhcp); + JsonWrite(json, CN_sta_timeout, sta_timeout); + JsonWrite(json, CN_ap_channel, ap_channelNumber); + JsonWrite(json, CN_ap_fallback, ap_fallbackIsEnabled); + JsonWrite(json, CN_ap_timeout, ap_timeout); + JsonWrite(json, CN_ap_reboot, RebootOnWiFiFailureToConnect); // DEBUG_END; @@ -365,14 +365,13 @@ void c_WiFiDriver::GetStatus (JsonObject& jsonStatus) // DEBUG_START; String Hostname; GetHostname (Hostname); - jsonStatus[CN_hostname] = Hostname; - - jsonStatus[CN_rssi] = WiFi.RSSI (); - jsonStatus[CN_ip] = getIpAddress ().toString (); - jsonStatus[CN_subnet] = getIpSubNetMask ().toString (); - jsonStatus[CN_mac] = WiFi.macAddress (); - jsonStatus[CN_ssid] = WiFi.SSID (); - jsonStatus[CN_connected] = IsWiFiConnected (); + JsonWrite(jsonStatus, CN_hostname, Hostname); + JsonWrite(jsonStatus, CN_rssi, WiFi.RSSI ()); + JsonWrite(jsonStatus, CN_ip, getIpAddress ().toString ()); + JsonWrite(jsonStatus, CN_subnet, getIpSubNetMask ().toString ()); + JsonWrite(jsonStatus, CN_mac, WiFi.macAddress ()); + JsonWrite(jsonStatus, CN_ssid, WiFi.SSID ()); + JsonWrite(jsonStatus, CN_connected, IsWiFiConnected ()); // DEBUG_END; } // GetStatus diff --git a/src/output/OutputCommon.cpp b/src/output/OutputCommon.cpp index 1c8c5d2c2..8870a75f7 100644 --- a/src/output/OutputCommon.cpp +++ b/src/output/OutputCommon.cpp @@ -69,17 +69,9 @@ void c_OutputCommon::BaseGetStatus (JsonObject & jsonStatus) { // DEBUG_START; - jsonStatus[CN_id] = OutputChannelId; - jsonStatus["framerefreshrate"] = int(MicroSecondsInASecond / FrameDurationInMicroSec); - jsonStatus["FrameCount"] = FrameCount; - - // jsonStatus["ActualFrameDurationMicroSec"] = ActualFrameDurationMicroSec; - // jsonStatus["FrameDurationInMicroSec"] = FrameDurationInMicroSec; - // jsonStatus["FrameRefreshTimeInMicroSec"] = FrameRefreshTimeInMicroSec; - // jsonStatus["FrameStartTimeInMicroSec"] = FrameStartTimeInMicroSec; - // jsonStatus["FrameEndTimeInMicroSec"] = FrameEndTimeInMicroSec; - // jsonStatus["FrameTimeDeltaUs"] = FrameTimeDeltaInMicroSec; - // jsonStatus["micros"] = micros(); + JsonWrite(jsonStatus, CN_id, OutputChannelId); + JsonWrite(jsonStatus, F("framerefreshrate"), int(MicroSecondsInASecond / FrameDurationInMicroSec)); + JsonWrite(jsonStatus, F("FrameCount"), FrameCount); // DEBUG_END; } // GetStatus @@ -121,7 +113,7 @@ void c_OutputCommon::GetConfig (JsonObject & jsonConfig) // DEBUG_START; // enums need to be converted to uints for json - jsonConfig[CN_data_pin] = uint8_t (DataPin); + JsonWrite(jsonConfig, CN_data_pin, uint8_t (DataPin)); // DEBUG_V(String(" DataPin: ") + String(DataPin)); diff --git a/src/output/OutputGrinch.cpp b/src/output/OutputGrinch.cpp index 562f954b0..bb648e145 100644 --- a/src/output/OutputGrinch.cpp +++ b/src/output/OutputGrinch.cpp @@ -51,7 +51,7 @@ void c_OutputGrinch::GetConfig (ArduinoJson::JsonObject& jsonConfig) // DEBUG_START; c_OutputCommon::GetConfig (jsonConfig); - jsonConfig[CN_count] = NumberOfGrinchControllers; + JsonWrite(jsonConfig, CN_count, NumberOfGrinchControllers); // DEBUG_END; } // GetConfig diff --git a/src/output/OutputMgr.cpp b/src/output/OutputMgr.cpp index cde5cc506..290306b9d 100644 --- a/src/output/OutputMgr.cpp +++ b/src/output/OutputMgr.cpp @@ -287,11 +287,11 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) // DEBUG_V (); // add the channels header - JsonObject OutputMgrChannelsData = jsonConfig[CN_channels]; + JsonObject OutputMgrChannelsData = jsonConfig[(char*)CN_channels]; if (!OutputMgrChannelsData) { // DEBUG_V (); - OutputMgrChannelsData = jsonConfig[CN_channels].to (); + OutputMgrChannelsData = jsonConfig[(char*)CN_channels].to (); } // add the channel configurations @@ -309,7 +309,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) } // save the name as the selected channel type - ChannelConfigData[CN_type] = int(CurrentChannel.pOutputChannelDriver->GetOutputType()); + JsonWrite(ChannelConfigData, CN_type, int(CurrentChannel.pOutputChannelDriver->GetOutputType())); String DriverTypeId = String(int(CurrentChannel.pOutputChannelDriver->GetOutputType())); JsonObject ChannelConfigByTypeData = ChannelConfigData[String (DriverTypeId)]; @@ -330,7 +330,7 @@ void c_OutputMgr::CreateJsonConfig (JsonObject& jsonConfig) CurrentChannel.pOutputChannelDriver->GetDriverName(DriverName); // DEBUG_V (String ("DriverName: ") + DriverName); - ChannelConfigByTypeData[CN_type] = DriverName; + JsonWrite(ChannelConfigByTypeData, CN_type, DriverName); // DEBUG_V (); // PrettyPrint (ChannelConfigByTypeData, String ("jsonConfig")); @@ -370,11 +370,11 @@ void c_OutputMgr::CreateNewConfig () // DEBUG_V (); // DEBUG_V("Create a new output config structure."); - JsonObject JsonConfig = JsonConfigDoc[CN_output_config].to (); + JsonObject JsonConfig = JsonConfigDoc[(char*)CN_output_config].to (); // DEBUG_V (); - JsonConfig[CN_cfgver] = CurrentConfigVersion; - JsonConfig[CN_MaxChannels] = sizeof(OutputBuffer); + JsonWrite(JsonConfig, CN_cfgver, CurrentConfigVersion); + JsonWrite(JsonConfig, CN_MaxChannels, sizeof(OutputBuffer)); // DEBUG_V("Collect the all ports disabled config first"); CreateJsonConfig (JsonConfig); @@ -467,7 +467,7 @@ void c_OutputMgr::GetStatus (JsonObject & jsonStatus) // jsonStatus["PollCount"] = PollCount; #endif // defined(ARDUINO_ARCH_ESP32) - JsonArray OutputStatus = jsonStatus[CN_output].to (); + JsonArray OutputStatus = jsonStatus[(char*)CN_output].to (); for (auto & CurrentOutput : OutputChannelDrivers) { // DEBUG_V (); @@ -1045,7 +1045,7 @@ bool c_OutputMgr::FindJsonChannelConfig (JsonDocument& jsonConfig, do // once { - JsonObject OutputChannelMgrData = jsonConfig[CN_output_config]; + JsonObject OutputChannelMgrData = jsonConfig[(char*)CN_output_config]; if (!OutputChannelMgrData) { logcon(String(MN_16) + MN_18); @@ -1066,7 +1066,7 @@ bool c_OutputMgr::FindJsonChannelConfig (JsonDocument& jsonConfig, } // do we have a channel configuration array? - JsonObject OutputChannelArray = OutputChannelMgrData[CN_channels]; + JsonObject OutputChannelArray = OutputChannelMgrData[(char*)CN_channels]; if (!OutputChannelArray) { // if not, flag an error and stop processing diff --git a/src/output/OutputPixel.cpp b/src/output/OutputPixel.cpp index 8889f4d40..481901ce0 100644 --- a/src/output/OutputPixel.cpp +++ b/src/output/OutputPixel.cpp @@ -51,15 +51,15 @@ void c_OutputPixel::GetConfig (ArduinoJson::JsonObject& jsonConfig) { // DEBUG_START; - jsonConfig[CN_color_order] = color_order; - jsonConfig[CN_pixel_count] = pixel_count; - jsonConfig[CN_group_size] = PixelGroupSize; - jsonConfig[CN_zig_size] = zig_size; - jsonConfig[CN_gamma] = gamma; - jsonConfig[CN_brightness] = brightness; // save as a 0 - 100 percentage - jsonConfig[CN_interframetime] = InterFrameGapInMicroSec; - jsonConfig[CN_prependnullcount] = PrependNullPixelCount; - jsonConfig[CN_appendnullcount] = AppendNullPixelCount; + JsonWrite(jsonConfig, CN_color_order, color_order); + JsonWrite(jsonConfig, CN_pixel_count, pixel_count); + JsonWrite(jsonConfig, CN_group_size, PixelGroupSize); + JsonWrite(jsonConfig, CN_zig_size, zig_size); + JsonWrite(jsonConfig, CN_gamma, gamma); + JsonWrite(jsonConfig, CN_brightness, brightness); // save as a 0 - 100 percentage + JsonWrite(jsonConfig, CN_interframetime, InterFrameGapInMicroSec); + JsonWrite(jsonConfig, CN_prependnullcount, PrependNullPixelCount); + JsonWrite(jsonConfig, CN_appendnullcount, AppendNullPixelCount); c_OutputCommon::GetConfig (jsonConfig); diff --git a/src/output/OutputRelay.cpp b/src/output/OutputRelay.cpp index 7cb94813f..13c458492 100644 --- a/src/output/OutputRelay.cpp +++ b/src/output/OutputRelay.cpp @@ -223,7 +223,7 @@ bool c_OutputRelay::SetConfig (ArduinoJson::JsonObject & jsonConfig) setFromJSON (UpdateInterval, jsonConfig, OM_RELAY_UPDATE_INTERVAL_NAME); // do we have a channel configuration array? - JsonArray JsonChannelList = jsonConfig[CN_channels]; + JsonArray JsonChannelList = jsonConfig[(char*)CN_channels]; if (!JsonChannelList) { // if not, flag an error and stop processing @@ -301,24 +301,24 @@ void c_OutputRelay::GetConfig (ArduinoJson::JsonObject & jsonConfig) { // DEBUG_START; - jsonConfig[OM_RELAY_UPDATE_INTERVAL_NAME] = UpdateInterval; + JsonWrite(jsonConfig, OM_RELAY_UPDATE_INTERVAL_NAME, UpdateInterval); - JsonArray JsonChannelList = jsonConfig[CN_channels].to (); + JsonArray JsonChannelList = jsonConfig[(char*)CN_channels].to (); uint8_t ChannelId = 0; for (RelayChannel_t & currentRelay : OutputList) { JsonObject JsonChannelData = JsonChannelList.add (); - JsonChannelData[CN_id] = ChannelId; - JsonChannelData[OM_RELAY_CHANNEL_ENABLED_NAME] = currentRelay.Enabled; - JsonChannelData[OM_RELAY_CHANNEL_INVERT_NAME] = currentRelay.InvertOutput; - JsonChannelData[OM_RELAY_CHANNEL_PWM_NAME] = currentRelay.Pwm; - JsonChannelData[CN_trig] = currentRelay.OnOffTriggerLevel; - JsonChannelData[CN_gid] = int(currentRelay.GpioId); + JsonWrite(JsonChannelData, CN_id, ChannelId); + JsonWrite(JsonChannelData, OM_RELAY_CHANNEL_ENABLED_NAME, currentRelay.Enabled); + JsonWrite(JsonChannelData, OM_RELAY_CHANNEL_INVERT_NAME, currentRelay.InvertOutput); + JsonWrite(JsonChannelData, OM_RELAY_CHANNEL_PWM_NAME, currentRelay.Pwm); + JsonWrite(JsonChannelData, CN_trig, currentRelay.OnOffTriggerLevel); + JsonWrite(JsonChannelData, CN_gid, int(currentRelay.GpioId)); #if defined(ARDUINO_ARCH_ESP32) - JsonChannelData[CN_Frequency] = currentRelay.PwmFrequency; + JsonWrite(JsonChannelData, CN_Frequency, currentRelay.PwmFrequency); #endif // defined(ARDUINO_ARCH_ESP32) // DEBUGV (String ("CurrentRelayChanIndex: ") + String (ChannelId)); @@ -340,15 +340,15 @@ void c_OutputRelay::GetStatus(ArduinoJson::JsonObject &jsonStatus) // DEBUG_START; c_OutputCommon::BaseGetStatus(jsonStatus); - JsonArray JsonChannelList = jsonStatus[CN_Relay].to (); + JsonArray JsonChannelList = jsonStatus[(char*)CN_Relay].to (); uint8_t ChannelId = 0; for (RelayChannel_t & currentRelay : OutputList) { JsonObject JsonChannelData = JsonChannelList.add (); - JsonChannelData[CN_id] = ChannelId; - JsonChannelData[CN_activevalue] = currentRelay.previousValue; + JsonWrite(JsonChannelData, CN_id, ChannelId); + JsonWrite(JsonChannelData, CN_activevalue, currentRelay.previousValue); ++ChannelId; } diff --git a/src/output/OutputSerial.cpp b/src/output/OutputSerial.cpp index c3ad90469..a88a58cc1 100644 --- a/src/output/OutputSerial.cpp +++ b/src/output/OutputSerial.cpp @@ -66,10 +66,10 @@ void c_OutputSerial::GetConfig(ArduinoJson::JsonObject &jsonConfig) { // DEBUG_START; - jsonConfig[CN_gen_ser_hdr] = GenericSerialHeader; - jsonConfig[CN_gen_ser_ftr] = GenericSerialFooter; - jsonConfig[CN_num_chan] = Num_Channels; - jsonConfig[CN_baudrate] = CurrentBaudrate; + JsonWrite(jsonConfig, CN_gen_ser_hdr, GenericSerialHeader); + JsonWrite(jsonConfig, CN_gen_ser_ftr, GenericSerialFooter); + JsonWrite(jsonConfig, CN_num_chan, Num_Channels); + JsonWrite(jsonConfig, CN_baudrate, CurrentBaudrate); c_OutputCommon::GetConfig (jsonConfig); @@ -177,7 +177,7 @@ bool c_OutputSerial::SetConfig (ArduinoJson::JsonObject& jsonConfig) #if defined(SUPPORT_OutputType_DMX) if (OutputType == c_OutputMgr::e_OutputType::OutputType_DMX) { - jsonConfig[CN_baudrate] = uint32_t(BaudRate::BR_DMX); + JsonWrite(jsonConfig, CN_baudrate, uint32_t(BaudRate::BR_DMX)); } #endif // defined(SUPPORT_OutputType_DMX) diff --git a/src/output/OutputServoPCA9685.cpp b/src/output/OutputServoPCA9685.cpp index d04d605df..6f92165b9 100644 --- a/src/output/OutputServoPCA9685.cpp +++ b/src/output/OutputServoPCA9685.cpp @@ -161,7 +161,7 @@ bool c_OutputServoPCA9685::SetConfig (ArduinoJson::JsonObject & jsonConfig) pwm->setPWMFreq (UpdateFrequency); // do we have a channel configuration array? - JsonArray JsonChannelList = jsonConfig[OM_SERVO_PCA9685_CHANNELS_NAME]; + JsonArray JsonChannelList = jsonConfig[(char*)OM_SERVO_PCA9685_CHANNELS_NAME]; if (!JsonChannelList) { // if not, flag an error and stop processing @@ -216,23 +216,23 @@ void c_OutputServoPCA9685::GetConfig (ArduinoJson::JsonObject & jsonConfig) { // DEBUG_START; - jsonConfig[OM_SERVO_PCA9685_UPDATE_INTERVAL_NAME] = UpdateFrequency; + JsonWrite(jsonConfig, OM_SERVO_PCA9685_UPDATE_INTERVAL_NAME, UpdateFrequency); - JsonArray JsonChannelList = jsonConfig[OM_SERVO_PCA9685_CHANNELS_NAME].to (); + JsonArray JsonChannelList = jsonConfig[(char*)OM_SERVO_PCA9685_CHANNELS_NAME].to (); uint8_t ChannelId = 0; for (ServoPCA9685Channel_t & currentServoPCA9685 : OutputList) { JsonObject JsonChannelData = JsonChannelList.add (); - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_ID_NAME] = ChannelId; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_ENABLED_NAME] = currentServoPCA9685.Enabled; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_MINLEVEL_NAME] = currentServoPCA9685.MinLevel; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_MAXLEVEL_NAME] = currentServoPCA9685.MaxLevel; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_REVERSED] = currentServoPCA9685.IsReversed; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_16BITS] = currentServoPCA9685.Is16Bit; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_SCALED] = currentServoPCA9685.IsScaled; - JsonChannelData[OM_SERVO_PCA9685_CHANNEL_HOME] = currentServoPCA9685.HomeValue; + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_ID_NAME, ChannelId); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_ENABLED_NAME, currentServoPCA9685.Enabled); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_MINLEVEL_NAME, currentServoPCA9685.MinLevel); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_MAXLEVEL_NAME, currentServoPCA9685.MaxLevel); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_REVERSED, currentServoPCA9685.IsReversed); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_16BITS, currentServoPCA9685.Is16Bit); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_SCALED, currentServoPCA9685.IsScaled); + JsonWrite(JsonChannelData, OM_SERVO_PCA9685_CHANNEL_HOME, currentServoPCA9685.HomeValue); // DEBUG_V (String ("ChannelId: ") + String (ChannelId)); // DEBUG_V (String (" Enabled: ") + String (currentServoPCA9685.Enabled)); diff --git a/src/output/OutputSpi.cpp b/src/output/OutputSpi.cpp index 67f88c6a7..4bf44f788 100644 --- a/src/output/OutputSpi.cpp +++ b/src/output/OutputSpi.cpp @@ -181,9 +181,9 @@ void c_OutputSpi::GetConfig (ArduinoJson::JsonObject & jsonConfig) // DEBUG_START; JsonObject SpiConfig = jsonConfig["dataspi"].to(); - SpiConfig[CN_cs_pin] = CsPin; - SpiConfig[CN_data_pin] = DataPin; - SpiConfig[CN_clock_pin] = ClockPin; + JsonWrite(SpiConfig, CN_cs_pin, CsPin); + JsonWrite(SpiConfig, CN_data_pin, DataPin); + JsonWrite(SpiConfig, CN_clock_pin, ClockPin); // DEBUG_END; } // GetConfig diff --git a/src/output/OutputTM1814.cpp b/src/output/OutputTM1814.cpp index fb2fd8037..94473fd19 100644 --- a/src/output/OutputTM1814.cpp +++ b/src/output/OutputTM1814.cpp @@ -61,7 +61,7 @@ void c_OutputTM1814::GetConfig (ArduinoJson::JsonObject& jsonConfig) // DEBUG_START; c_OutputPixel::GetConfig (jsonConfig); - jsonConfig[CN_currentlimit] = CurrentLimit; + JsonWrite(jsonConfig, CN_currentlimit, CurrentLimit); // DEBUG_END; } // GetConfig diff --git a/src/output/OutputUart.cpp b/src/output/OutputUart.cpp index 711f243d6..b9544df9b 100644 --- a/src/output/OutputUart.cpp +++ b/src/output/OutputUart.cpp @@ -283,7 +283,7 @@ void c_OutputUart::GetConfig(JsonObject &jsonConfig) // enums need to be converted to uints for json // jsonConfig[CN_data_pin] = uint8_t(OutputUartConfig.DataPin); - jsonConfig[CN_baudrate] = OutputUartConfig.Baudrate; + JsonWrite(jsonConfig, CN_baudrate, OutputUartConfig.Baudrate); // DEBUG_V(String(" DataPin: ") + String(OutputUartConfig.DataPin)); // DEBUG_V(String("Baudrate: ") + String(OutputUartConfig.Baudrate)); diff --git a/src/service/FPPDiscovery.cpp b/src/service/FPPDiscovery.cpp index 878881722..fd46a00be 100644 --- a/src/service/FPPDiscovery.cpp +++ b/src/service/FPPDiscovery.cpp @@ -158,35 +158,35 @@ void c_FPPDiscovery::GetStatus (JsonObject & jsonStatus) if (IsEnabled) { #ifdef FPP_DEBUG_ENABLED - jsonStatus[F ("pktCommand")] = MultiSyncStats.pktCommand; - jsonStatus[F ("pktSyncSeqOpen")] = MultiSyncStats.pktSyncSeqOpen; - jsonStatus[F ("pktSyncSeqStart")] = MultiSyncStats.pktSyncSeqStart; - jsonStatus[F ("pktSyncSeqStop")] = MultiSyncStats.pktSyncSeqStop; - jsonStatus[F ("pktSyncSeqSync")] = MultiSyncStats.pktSyncSeqSync; - jsonStatus[F ("pktSyncMedOpen")] = MultiSyncStats.pktSyncMedOpen; - jsonStatus[F ("pktSyncMedStart")] = MultiSyncStats.pktSyncMedStart; - jsonStatus[F ("pktSyncMedStop")] = MultiSyncStats.pktSyncMedStop; - jsonStatus[F ("pktSyncMedSync")] = MultiSyncStats.pktSyncMedSync; - jsonStatus[F ("pktBlank")] = MultiSyncStats.pktBlank; - jsonStatus[F ("pktPing")] = MultiSyncStats.pktPing; - jsonStatus[F ("pktPlugin")] = MultiSyncStats.pktPlugin; - jsonStatus[F ("pktFPPCommand")] = MultiSyncStats.pktFPPCommand; - jsonStatus[F ("pktHdrError")] = MultiSyncStats.pktHdrError; - jsonStatus[F ("pktUnknown")] = MultiSyncStats.pktUnknown; - jsonStatus[F ("pktLastCommand")] = MultiSyncStats.pktLastCommand; - - jsonStatus[F ("ProcessFPPJson")] = SystemDebugStats.ProcessFPPJson; - jsonStatus[F ("ProcessFPPDJson")] = SystemDebugStats.ProcessFPPDJson; - jsonStatus[F ("CmdGetFPPstatus")] = SystemDebugStats.CmdGetFPPstatus; - jsonStatus[F ("CmdGetSysInfoJSON")] = SystemDebugStats.CmdGetSysInfoJSON; - jsonStatus[F ("CmdGetHostname")] = SystemDebugStats.CmdGetHostname; - jsonStatus[F ("CmdGetConfig")] = SystemDebugStats.CmdGetConfig; - jsonStatus[F ("CmdNotFound")] = SystemDebugStats.CmdNotFound; + JsonWrite(jsonStatus, F ("pktCommand"), MultiSyncStats.pktCommand); + JsonWrite(jsonStatus, F ("pktSyncSeqOpen"), MultiSyncStats.pktSyncSeqOpen); + JsonWrite(jsonStatus, F ("pktSyncSeqStart"), MultiSyncStats.pktSyncSeqStart); + JsonWrite(jsonStatus, F ("pktSyncSeqStop"), MultiSyncStats.pktSyncSeqStop); + JsonWrite(jsonStatus, F ("pktSyncSeqSync"), MultiSyncStats.pktSyncSeqSync); + JsonWrite(jsonStatus, F ("pktSyncMedOpen"), MultiSyncStats.pktSyncMedOpen); + JsonWrite(jsonStatus, F ("pktSyncMedStart"), MultiSyncStats.pktSyncMedStart); + JsonWrite(jsonStatus, F ("pktSyncMedStop"), MultiSyncStats.pktSyncMedStop); + JsonWrite(jsonStatus, F ("pktSyncMedSync"), MultiSyncStats.pktSyncMedSync); + JsonWrite(jsonStatus, F ("pktBlank"), MultiSyncStats.pktBlank); + JsonWrite(jsonStatus, F ("pktPing"), MultiSyncStats.pktPing); + JsonWrite(jsonStatus, F ("pktPlugin"), MultiSyncStats.pktPlugin); + JsonWrite(jsonStatus, F ("pktFPPCommand"), MultiSyncStats.pktFPPCommand); + JsonWrite(jsonStatus, F ("pktHdrError"), MultiSyncStats.pktHdrError); + JsonWrite(jsonStatus, F ("pktUnknown"), MultiSyncStats.pktUnknown); + JsonWrite(jsonStatus, F ("pktLastCommand"), MultiSyncStats.pktLastCommand); + + JsonWrite(jsonStatus, F ("ProcessFPPJson"), SystemDebugStats.ProcessFPPJson); + JsonWrite(jsonStatus, F ("ProcessFPPDJson"), SystemDebugStats.ProcessFPPDJson); + JsonWrite(jsonStatus, F ("CmdGetFPPstatus"), SystemDebugStats.CmdGetFPPstatus); + JsonWrite(jsonStatus, F ("CmdGetSysInfoJSON"), SystemDebugStats.CmdGetSysInfoJSON); + JsonWrite(jsonStatus, F ("CmdGetHostname"), SystemDebugStats.CmdGetHostname); + JsonWrite(jsonStatus, F ("CmdGetConfig"), SystemDebugStats.CmdGetConfig); + JsonWrite(jsonStatus, F ("CmdNotFound"), SystemDebugStats.CmdNotFound); #endif // def FPP_DEBUG_ENABLED // DEBUG_V ("Is Enabled"); JsonObject MyJsonStatus = jsonStatus[F ("FPPDiscovery")].to (); - MyJsonStatus[F ("FppRemoteIp")] = FppRemoteIp.toString (); + JsonWrite(MyJsonStatus, F ("FppRemoteIp"), FppRemoteIp.toString ()); if (InputFPPRemotePlayFile) { InputFPPRemotePlayFile->GetStatus (MyJsonStatus); @@ -547,12 +547,12 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St FSEQRawHeader fsqHeader; FileMgr.ReadSdFile (fseq, (byte*)&fsqHeader, sizeof (fsqHeader), size_t(0)); - JsonData[F ("Name")] = fname; - JsonData[CN_Version] = String (fsqHeader.majorVersion) + "." + String (fsqHeader.minorVersion); - JsonData[F ("ID")] = int64String (read64 (fsqHeader.id, 0)); - JsonData[F ("StepTime")] = String (fsqHeader.stepTime); - JsonData[F ("NumFrames")] = String (read32 (fsqHeader.TotalNumberOfFramesInSequence, 0)); - JsonData[F ("CompressionType")] = fsqHeader.compressionType; + JsonWrite(JsonData, F ("Name"), fname); + JsonWrite(JsonData, CN_Version, String (fsqHeader.majorVersion) + "." + String (fsqHeader.minorVersion)); + JsonWrite(JsonData, F ("ID"), int64String (read64 (fsqHeader.id, 0))); + JsonWrite(JsonData, F ("StepTime"), String (fsqHeader.stepTime)); + JsonWrite(JsonData, F ("NumFrames"), String (read32 (fsqHeader.TotalNumberOfFramesInSequence, 0))); + JsonWrite(JsonData, F ("CompressionType"), fsqHeader.compressionType); static const int TIME_STR_CHAR_COUNT = 32; char timeStr[TIME_STR_CHAR_COUNT]; @@ -565,23 +565,23 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St // TODO: assert ((actuallyWritten > 0) && (actuallyWritten < TIME_STR_CHAR_COUNT)) if ((actuallyWritten > 0) && (actuallyWritten < TIME_STR_CHAR_COUNT)) { - JsonData[F ("lastReceiveTime")] = timeStr; + JsonWrite(JsonData, F ("lastReceiveTime"), timeStr); } - JsonData[F ("pktCommand")] = MultiSyncStats.pktCommand; - JsonData[F ("pktSyncSeqOpen")] = MultiSyncStats.pktSyncSeqOpen; - JsonData[F ("pktSyncSeqStart")] = MultiSyncStats.pktSyncSeqStart; - JsonData[F ("pktSyncSeqStop")] = MultiSyncStats.pktSyncSeqStop; - JsonData[F ("pktSyncSeqSync")] = MultiSyncStats.pktSyncSeqSync; - JsonData[F ("pktSyncMedOpen")] = MultiSyncStats.pktSyncMedOpen; - JsonData[F ("pktSyncMedStart")] = MultiSyncStats.pktSyncMedStart; - JsonData[F ("pktSyncMedStop")] = MultiSyncStats.pktSyncMedStop; - JsonData[F ("pktSyncMedSync")] = MultiSyncStats.pktSyncMedSync; - JsonData[F ("pktBlank")] = MultiSyncStats.pktBlank; - JsonData[F ("pktPing")] = MultiSyncStats.pktPing; - JsonData[F ("pktPlugin")] = MultiSyncStats.pktPlugin; - JsonData[F ("pktFPPCommand")] = MultiSyncStats.pktFPPCommand; - JsonData[F ("pktError")] = MultiSyncStats.pktHdrError; + JsonWrite(JsonData, F ("pktCommand"), MultiSyncStats.pktCommand); + JsonWrite(JsonData, F ("pktSyncSeqOpen"), MultiSyncStats.pktSyncSeqOpen); + JsonWrite(JsonData, F ("pktSyncSeqStart"), MultiSyncStats.pktSyncSeqStart); + JsonWrite(JsonData, F ("pktSyncSeqStop"), MultiSyncStats.pktSyncSeqStop); + JsonWrite(JsonData, F ("pktSyncSeqSync"), MultiSyncStats.pktSyncSeqSync); + JsonWrite(JsonData, F ("pktSyncMedOpen"), MultiSyncStats.pktSyncMedOpen); + JsonWrite(JsonData, F ("pktSyncMedStart"), MultiSyncStats.pktSyncMedStart); + JsonWrite(JsonData, F ("pktSyncMedStop"), MultiSyncStats.pktSyncMedStop); + JsonWrite(JsonData, F ("pktSyncMedSync"), MultiSyncStats.pktSyncMedSync); + JsonWrite(JsonData, F ("pktBlank"), MultiSyncStats.pktBlank); + JsonWrite(JsonData, F ("pktPing"), MultiSyncStats.pktPing); + JsonWrite(JsonData, F ("pktPlugin"), MultiSyncStats.pktPlugin); + JsonWrite(JsonData, F ("pktFPPCommand"), MultiSyncStats.pktFPPCommand); + JsonWrite(JsonData, F ("pktError"), MultiSyncStats.pktHdrError); uint32_t maxChannel = read32 (fsqHeader.channelCount, 0); @@ -604,8 +604,8 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St uint32_t RangeLength = read24 (CurrentFSEQRangeEntry->Length); JsonObject JsonRange = JsonDataRanges.add (); - JsonRange[F ("Start")] = String (RangeStart); - JsonRange[F ("Length")] = String (RangeLength); + JsonWrite(JsonRange, F ("Start"), String (RangeStart)); + JsonWrite(JsonRange, F ("Length"), String (RangeLength)); if ((RangeStart + RangeLength - 1) > maxChannel) { @@ -616,8 +616,8 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St free (RangeDataBuffer); } - JsonData[F ("MaxChannel")] = String (maxChannel); - JsonData[F ("ChannelCount")] = String (read32 (fsqHeader.channelCount,0)); + JsonWrite(JsonData, F ("MaxChannel"), String (maxChannel)); + JsonWrite(JsonData, F ("ChannelCount"), String (read32 (fsqHeader.channelCount,0))); uint32_t FileOffsetToCurrentHeaderRecord = read16 (fsqHeader.VariableHdrOffset); uint32_t FileOffsetToStartOfSequenceData = read16 (fsqHeader.dataOffset); // DataOffset @@ -650,7 +650,7 @@ void c_FPPDiscovery::BuildFseqResponse (String fname, c_FileMgr::FileId fseq, St FileMgr.ReadSdFile (fseq, (byte*)VariableDataHeaderDataBuffer, VariableDataHeaderDataLength, FileOffsetToCurrentHeaderRecord); JsonObject JsonDataHeader = JsonDataHeaders.add (); - JsonDataHeader[HeaderTypeCode] = String (VariableDataHeaderDataBuffer); + JsonWrite(JsonDataHeader, HeaderTypeCode.c_str(), String (VariableDataHeaderDataBuffer)); free (VariableDataHeaderDataBuffer); } @@ -689,12 +689,12 @@ void c_FPPDiscovery::ProcessGET (AsyncWebServerRequest* request) if (path.startsWith (F ("/api/sequence/")) && AllowedToRemotePlayFiles()) { - // DEBUG_V (""); + // DEBUG_V (emptyString); String seq = path.substring (14); if (seq.endsWith (F ("/meta"))) { - // DEBUG_V (""); + // DEBUG_V (emptyString); seq = seq.substring (0, seq.length () - 5); StopPlaying (false); @@ -778,7 +778,7 @@ void c_FPPDiscovery::ProcessPOST (AsyncWebServerRequest* request) } // DEBUG_V ("BuildFseqResponse"); - String resp = ""; + String resp = emptyString; BuildFseqResponse (filename, FileHandle, resp); FileMgr.CloseSdFile (FileHandle); request->send (200, CN_applicationSLASHjson, resp); @@ -846,7 +846,7 @@ void c_FPPDiscovery::ProcessFile ( if (final) { inFileUpload = false; - UploadFileName = ""; + UploadFileName = emptyString; writeFailed = false; memset(OutputMgr.GetBufferAddress(), 0x00, OutputMgr.GetBufferSize()); InputMgr.SetOperationalState(true); @@ -903,7 +903,7 @@ void c_FPPDiscovery::ProcessBody ( break; } UploadFileName = String (request->getParam (CN_filename)->value ()); - // DEBUG_V (""); + // DEBUG_V (emptyString); } writeFailed = false; @@ -929,24 +929,24 @@ void c_FPPDiscovery::GetSysInfoJSON (JsonObject & jsonResponse) String Hostname; NetworkMgr.GetHostname (Hostname); - jsonResponse[CN_HostName] = Hostname; - jsonResponse[F ("HostDescription")] = config.id; - jsonResponse[CN_Platform] = CN_ESPixelStick; - jsonResponse[F ("Variant")] = FPP_VARIANT_NAME; - jsonResponse[F ("Mode")] = (true == AllowedToRemotePlayFiles()) ? CN_remote : CN_bridge; - jsonResponse[CN_Version] = VERSION; + JsonWrite(jsonResponse, CN_HostName, Hostname); + JsonWrite(jsonResponse, F ("HostDescription"), config.id); + JsonWrite(jsonResponse, CN_Platform, String(CN_ESPixelStick)); + JsonWrite(jsonResponse, F ("Variant"), FPP_VARIANT_NAME); + JsonWrite(jsonResponse, F ("Mode"), String((true == AllowedToRemotePlayFiles()) ? CN_remote : CN_bridge)); + JsonWrite(jsonResponse, CN_Version, VERSION); const char* version = VERSION.c_str (); - jsonResponse[F ("majorVersion")] = (uint16_t)atoi (version); - jsonResponse[F ("minorVersion")] = (uint16_t)atoi (&version[2]); - jsonResponse[F ("typeId")] = FPP_TYPE_ID; + JsonWrite(jsonResponse, F ("majorVersion"), (uint16_t)atoi (version)); + JsonWrite(jsonResponse, F ("minorVersion"), (uint16_t)atoi (&version[2])); + JsonWrite(jsonResponse, F ("typeId"), FPP_TYPE_ID); JsonObject jsonResponseUtilization = jsonResponse[F ("Utilization")].to (); - jsonResponseUtilization[F ("MemoryFree")] = ESP.getFreeHeap (); - jsonResponseUtilization[F ("Uptime")] = millis (); + JsonWrite(jsonResponseUtilization, F ("MemoryFree"), ESP.getFreeHeap ()); + JsonWrite(jsonResponseUtilization, F ("Uptime"), millis ()); - jsonResponse[CN_rssi] = WiFi.RSSI (); + JsonWrite(jsonResponse, CN_rssi, WiFi.RSSI ()); JsonArray jsonResponseIpAddresses = jsonResponse[F ("IPS")].to (); jsonResponseIpAddresses.add(WiFi.localIP ().toString ()); @@ -960,47 +960,46 @@ void c_FPPDiscovery::GetStatusJSON (JsonObject & JsonData, bool adv) // DEBUG_START; JsonObject JsonDataMqtt = JsonData[F ("MQTT")].to(); - JsonDataMqtt[F ("configured")] = false; - JsonDataMqtt[F ("connected")] = false; + JsonWrite(JsonDataMqtt, F ("configured"), false); + JsonWrite(JsonDataMqtt, F ("connected"), false); JsonObject JsonDataCurrentPlaylist = JsonData[F ("current_playlist")].to (); - JsonDataCurrentPlaylist[CN_count] = "0"; - JsonDataCurrentPlaylist[F ("description")] = ""; - JsonDataCurrentPlaylist[F ("index")] = "0"; - JsonDataCurrentPlaylist[CN_playlist] = ""; - JsonDataCurrentPlaylist[CN_type] = ""; + JsonWrite(JsonDataCurrentPlaylist, CN_count, "0"); + JsonWrite(JsonDataCurrentPlaylist, F ("description"), emptyString); + JsonWrite(JsonDataCurrentPlaylist, F ("index"), "0"); + JsonWrite(JsonDataCurrentPlaylist, CN_playlist, emptyString); + JsonWrite(JsonDataCurrentPlaylist, CN_type, emptyString); // DEBUG_V(); - JsonData[F ("volume")] = 70; - JsonData[F ("media_filename")] = ""; - JsonData[F ("fppd")] = F ("running"); - JsonData[F ("current_song")] = ""; + JsonWrite(JsonData, F ("volume"), 70); + JsonWrite(JsonData, F ("media_filename"), emptyString); + JsonWrite(JsonData, F ("fppd"), F ("running")); + JsonWrite(JsonData, F ("current_song"), emptyString); if (false == PlayingFile()) { - JsonData[CN_current_sequence] = ""; - JsonData[CN_playlist] = ""; - JsonData[CN_seconds_elapsed] = String (0); - JsonData[CN_seconds_played] = String (0); - JsonData[CN_seconds_remaining] = String (0); - JsonData[CN_sequence_filename] = ""; - JsonData[CN_time_elapsed] = String("00:00"); - JsonData[CN_time_remaining] = String ("00:00"); - - JsonData[CN_status] = 0; - JsonData[CN_status_name] = F ("idle"); + JsonWrite(JsonData, CN_current_sequence, emptyString); + JsonWrite(JsonData, CN_playlist, emptyString); + JsonWrite(JsonData, CN_seconds_elapsed, String (0)); + JsonWrite(JsonData, CN_seconds_played, String (0)); + JsonWrite(JsonData, CN_seconds_remaining, String (0)); + JsonWrite(JsonData, CN_sequence_filename, emptyString); + JsonWrite(JsonData, CN_time_elapsed, String("00:00")); + JsonWrite(JsonData, CN_time_remaining, String ("00:00")); + JsonWrite(JsonData, CN_status, 0); + JsonWrite(JsonData, CN_status_name, F ("idle")); if (IsEnabled) { - JsonData[CN_mode] = 8; - JsonData[CN_mode_name] = CN_remote; + JsonWrite(JsonData, CN_mode, 8); + JsonWrite(JsonData, CN_mode_name, String(CN_remote)); } else { - JsonData[CN_mode] = 1; - JsonData[CN_mode_name] = CN_bridge; + JsonWrite(JsonData, CN_mode, 1); + JsonWrite(JsonData, CN_mode_name, String(CN_bridge)); } } else @@ -1011,11 +1010,11 @@ void c_FPPDiscovery::GetStatusJSON (JsonObject & JsonData, bool adv) // DEBUG_V(); InputFPPRemotePlayFile->GetStatus (JsonData); } - JsonData[CN_status] = 1; - JsonData[CN_status_name] = F ("playing"); + JsonWrite(JsonData, CN_status, 1); + JsonWrite(JsonData, CN_status_name, F ("playing")); - JsonData[CN_mode] = 8; - JsonData[CN_mode_name] = CN_remote; + JsonWrite(JsonData, CN_mode, 8); + JsonWrite(JsonData, CN_mode_name, String(CN_remote)); } // DEBUG_V(); @@ -1077,7 +1076,7 @@ void c_FPPDiscovery::ProcessFPPJson (AsyncWebServerRequest* request) SystemDebugStats.CmdGetSysInfoJSON++; GetSysInfoJSON (JsonData); - String resp = ""; + String resp = emptyString; serializeJson (JsonData, resp); // DEBUG_V (String ("JsonDoc: ") + resp); request->send (200, CN_applicationSLASHjson, resp); @@ -1091,8 +1090,8 @@ void c_FPPDiscovery::ProcessFPPJson (AsyncWebServerRequest* request) String Hostname; NetworkMgr.GetHostname (Hostname); - JsonData[CN_HostName] = Hostname; - JsonData[F ("HostDescription")] = config.id; + JsonWrite(JsonData, CN_HostName, Hostname); + JsonWrite(JsonData, F ("HostDescription"), config.id); String resp; serializeJson (JsonData, resp); @@ -1173,14 +1172,14 @@ void c_FPPDiscovery::StartPlaying (String & FileName, float SecondsElapsed) // DEBUG_V ("Not Enabled"); break; } - // DEBUG_V (""); + // DEBUG_V (emptyString); if (inFileUpload) { // DEBUG_V ("Uploading"); break; } - // DEBUG_V (""); + // DEBUG_V (emptyString); if (FileName.isEmpty()) {