From ff8997fb0287f056d1875741470a6e39ee028841 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 23 Aug 2024 00:12:12 +0300 Subject: [PATCH] post-refactoring fixes: $command, Items-Parse --- lighthub/item.cpp | 19 +++++++++---------- lighthub/main.cpp | 4 ++-- lighthub/utils.cpp | 5 +++-- lighthub/utils.h | 2 ++ platformio.ini | 8 +++++--- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 3640f9a..1d082bc 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -156,24 +156,23 @@ void Item::Parse() { if (isValid()) { // Todo - avoid static enlarge for every types for (int i = aJson.getArraySize(itemArr); i < 4; i++) - aJson.addItemToArray(itemArr, aJson.createNull());//( (long int) 0)); - // int(defval[i]) )); //Enlarge item to 4 elements. VAL=int if no other definition in conf - //itemType = aJson.getArrayItem(itemArr, I_TYPE)->valueint; - /* + aJson.addItemToArray(itemArr, aJson.createNull()); + + /* itemType = replaceTypeToInt (aJson.getArrayItem(itemArr, I_TYPE)); itemArg = aJson.getArrayItem(itemArr, I_ARG); itemVal = aJson.getArrayItem(itemArr, I_VAL); - itemExt = aJson.getArrayItem(itemArr, I_EXT); - */ - + itemExt = aJson.getArrayItem(itemArr, I_EXT); */ + + aJsonObject * cmdObj = NULL; aJsonObject * itemTypeObj = itemArr->child; if (itemTypeObj) itemArg = itemTypeObj->next; - if (itemArg) itemVal = itemArg->next; - if (itemVal) itemExt = itemVal->next; + if (itemArg) itemVal = itemArg->next; + if (itemVal) cmdObj = itemVal->next; + if (cmdObj) itemExt = cmdObj->next; itemType = replaceTypeToInt (itemTypeObj); - switch (itemType) { #ifndef PWM_DISABLE diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 0152715..c76fa00 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -486,7 +486,7 @@ else // debugSerial<1)) { mqttClient.deleteTopic(topic); - if (forLocal || forBcast)((char *)payload); + if (forLocal || forBcast) cmd_parse ((char *)payload); //TODO implement for remote return;// -4; } @@ -1645,7 +1645,7 @@ int loadConfigFromEEPROM() if (sysConfStream.peek() == '{') { debugSerial<