From a9bcba3d7cc869de3020348a5e3242afe1d613e0 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Wed, 22 Sep 2021 01:03:57 +0300 Subject: [PATCH] restart on MQTT err fix, Float storage & RAW fix --- build-flags/build_flags_mega2560slim2 | 2 +- lighthub/item.cpp | 8 +++++ lighthub/item.h | 1 + lighthub/itemCmd.cpp | 42 +++++++++++++++++++++++---- lighthub/main.cpp | 27 +++++++++-------- lighthub/modules/out_ac.h | 2 +- 6 files changed, 63 insertions(+), 19 deletions(-) diff --git a/build-flags/build_flags_mega2560slim2 b/build-flags/build_flags_mega2560slim2 index a9d219e..ef80113 100644 --- a/build-flags/build_flags_mega2560slim2 +++ b/build-flags/build_flags_mega2560slim2 @@ -10,7 +10,7 @@ -DNO_HOMIE -DCSSHDC_DISABLE -DSPILED_DISABLE --DAC_DISABLE +#-DAC_DISABLE -DSYSLOG_ENABLE -DPID_DISABLE -DOTA diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 775a0f5..8e2e9f5 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -388,6 +388,14 @@ void Item::setVal(long int par) // Only store if VAL is int (autogenerated or c itemVal->type = aJson_Int; } +void Item::setFloatVal(float par) // Only store if VAL is int (autogenerated or config-defined) +{ + if (!itemVal || (itemVal->type != aJson_Int && itemVal->type != aJson_Float && itemVal->type != aJson_NULL)) return; + //debugSerial<")<itemVal->valueint); //debugSerial<itemVal->valueint); //debugSerial<setCmd(cmd.cmdCode); if (optionsFlag & SEND_PARAMETERS) + switch (cmd.itemArgType) { + case ST_FLOAT: + item->setFloatVal(param.asfloat); + //case ST_FLOAT_CELSIUS: + break; + + case ST_INT32: + case ST_UINT32: + item->setVal(param.asInt32); + break; + + default: item->setSubtype(cmd.itemArgType); item->setVal(param.asInt32); } diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 1296bb3..4cdbd08 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -1468,16 +1468,15 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args) } else { errorSerial<