Skip to content

Commit

Permalink
Changes to support ArduinoJson 7.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMueller2003 committed Jan 7, 2025
1 parent d048d9b commit 8888777
Show file tree
Hide file tree
Showing 35 changed files with 452 additions and 459 deletions.
1 change: 1 addition & 0 deletions include/ConstNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
10 changes: 6 additions & 4 deletions include/ESPixelStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ bool setFromJSON (T& OutValue, JsonObject & Json, N Name)
{
bool HasBeenModified = false;

if (Json[Name].template is<T>())
if (Json[(char*)Name].template is<T>())
{
T temp = Json[Name];
T temp = Json[(char*)Name];
if (temp != OutValue)
{
OutValue = temp;
Expand All @@ -115,9 +115,9 @@ bool setFromJSON (T& OutValue, JsonVariant & Json, N Name)
{
bool HasBeenModified = false;

if (Json[Name].template is<T>())
if (Json[(char*)Name].template is<T>())
{
T temp = Json[Name];
T temp = Json[(char*)Name];
if (temp != OutValue)
{
OutValue = temp;
Expand All @@ -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; \
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/ConstNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 9 additions & 9 deletions src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonObject>();
if (JsonDeviceConfig)
{
// PrettyPrint (JsonDeviceConfig, "c_FileMgr");
Expand Down Expand Up @@ -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;

Expand Down
32 changes: 16 additions & 16 deletions src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,16 @@ void c_WebMgr::CreateAdminInfoFile ()
JsonDocument AdminJsonDoc;
JsonObject jsonAdmin = AdminJsonDoc[F ("admin")].to<JsonObject> ();

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
Expand Down Expand Up @@ -765,14 +765,14 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client)

JsonDocument WebJsonDoc;
WebJsonDoc.clear ();
JsonObject status = WebJsonDoc[CN_status].to<JsonObject> ();
JsonObject system = status[CN_system].to<JsonObject> ();

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> ();
JsonObject system = status[(char*)CN_system].to<JsonObject> ();

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");
Expand Down
18 changes: 9 additions & 9 deletions src/input/InputAlexa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonObject> ();

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<JsonObject> ();

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 ()));

Expand Down
28 changes: 14 additions & 14 deletions src/input/InputArtnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -87,25 +87,25 @@ void c_InputArtnet::GetStatus (JsonObject & jsonStatus)
// DEBUG_START;

JsonObject ArtnetStatus = jsonStatus[F ("Artnet")].to<JsonObject> ();
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> ();
JsonArray ArtnetUniverseStatus = ArtnetStatus[(char*)CN_channels].to<JsonArray> ();

for (auto & CurrentUniverse : UniverseArray)
{
JsonObject ArtnetCurrentUniverseStatus = ArtnetUniverseStatus.add<JsonObject> ();

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;
Expand Down
30 changes: 15 additions & 15 deletions src/input/InputDDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ void c_InputDDP::GetStatus (JsonObject& jsonStatus)
JsonObject ddpStatus = jsonStatus[F ("ddp")].to<JsonObject> ();
// 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;

Expand Down Expand Up @@ -323,21 +323,21 @@ void c_InputDDP::ProcessReceivedQuery ()
// DEBUG_V ("DDP_ID_CONFIG query");

JsonDocument JsonConfigDoc;
JsonObject JsonConfig = JsonConfigDoc[CN_config].to<JsonObject> ();
JsonObject JsonConfig = JsonConfigDoc[(char*)CN_config].to<JsonObject> ();
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);
Expand Down
2 changes: 1 addition & 1 deletion src/input/InputDisabled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void c_InputDisabled::GetStatus (JsonObject & jsonStatus)
// DEBUG_START;

JsonObject Status = jsonStatus[F ("disabled")].to<JsonObject> ();
Status[CN_id] = InputChannelId;
JsonWrite(Status, CN_id, InputChannelId);

// DEBUG_END;

Expand Down
28 changes: 14 additions & 14 deletions src/input/InputE131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -92,27 +92,27 @@ void c_InputE131::GetStatus (JsonObject & jsonStatus)
{
// DEBUG_START;

JsonObject e131Status = jsonStatus[F ("e131")].to<JsonObject> ();
e131Status[CN_id] = InputChannelId;
e131Status[CN_unifirst] = startUniverse;
e131Status[CN_unilast ] = LastUniverse;
e131Status[CN_unichanlim] = ChannelsPerUniverse;
JsonObject e131Status = jsonStatus[(char*)F ("e131")].to<JsonObject> ();
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> ();
JsonArray e131UniverseStatus = e131Status[(char*)CN_channels].to<JsonArray> ();
uint32_t TotalErrors = 0; // e131->stats.packet_errors;
for (auto & CurrentUniverse : UniverseArray)
{
JsonObject e131CurrentUniverseStatus = e131UniverseStatus.add<JsonObject> ();

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;

Expand Down
Loading

0 comments on commit 8888777

Please sign in to comment.