mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
post-refactoring fixes: $command, Items-Parse
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -977,7 +977,7 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef CANDRV
|
||||
uint16_t getCRC(aJsonObject * in)
|
||||
{
|
||||
if (!in) return 0;
|
||||
@@ -987,8 +987,9 @@ aJsonStream aJsonCrcStream = aJsonStream(&crcStream);
|
||||
//debugSerial.print(aJson.print(in));
|
||||
aJson.print(in,&aJsonCrcStream,false);
|
||||
//debugSerial<<"\nCRC:"<<crcStream.getCRC16();
|
||||
return crcStream.getCRC16();
|
||||
return crcStream.getCRC16();
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma message(VAR_NAME_VALUE(debugSerial))
|
||||
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user