post-refactoring fixes: $command, Items-Parse

This commit is contained in:
2024-08-23 00:12:12 +03:00
parent 96a9c59add
commit ff8997fb02
5 changed files with 21 additions and 17 deletions

View File

@@ -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 (itemVal) cmdObj = itemVal->next;
if (cmdObj) itemExt = cmdObj->next;
itemType = replaceTypeToInt (itemTypeObj);
switch (itemType)
{
#ifndef PWM_DISABLE

View File

@@ -486,7 +486,7 @@ else
// debugSerial<<itemName<<endl;
if(!strcmp_P(itemName,CMDTOPIC_P) && payload && (strlen((char*) payload)>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<<F("JSON detected")<<endl;
cleanConf(1);
if (root) cleanConf(1);
aJsonStream as = aJsonStream(&sysConfStream);
root = aJson.parse(&as);

View File

@@ -977,7 +977,7 @@ return true;
}
#ifdef CANDRV
uint16_t getCRC(aJsonObject * in)
{
if (!in) return 0;
@@ -989,6 +989,7 @@ aJson.print(in,&aJsonCrcStream,false);
//debugSerial<<"\nCRC:"<<crcStream.getCRC16();
return crcStream.getCRC16();
}
#endif
#pragma message(VAR_NAME_VALUE(debugSerial))
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))

View File

@@ -83,6 +83,7 @@ bool checkToken(char * token, char * data);
bool i2cReset();
uint16_t getCRC(aJsonObject * in);
#ifdef CANDRV
#include "util/crc16_.h"
class CRCStream : public Stream
{
@@ -102,3 +103,4 @@ public:
virtual int availableForWrite(){return 1;};
};
#endif

View File

@@ -356,9 +356,11 @@ lib_ignore =
DMXSerial
Adafruit NeoPixel
DmxSimple
ModbusMaster
ClosedCube HDC1080
SparkFun CCS811 Arduino Library
;ArduinoOTA
ArduinoMDNS
;Adafruit BusIO
;Adafruit MCP23017 Arduino Library
;Adafruit Unified Sensor
@@ -369,7 +371,7 @@ lib_deps =
https://github.com/anklimov/httpClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
;https://github.com/anklimov/ModbusMaster
;https://github.com/anklimov/DMXSerial
;https://github.com/anklimov/Ethernet5100
;5100 lib have ~90 bytes less footprint of RAM
@@ -388,7 +390,7 @@ lib_deps =
Adafruit MCP23017 Arduino Library
Adafruit BusIO
br3ttb/PID@^1.2.1
ArduinoMDNS
;ArduinoMDNS
;https://github.com/khoih-prog/TimerInterrupt_Generic.git
monitor_speed = 115200