diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 92dfa8c..c8c497d 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -176,12 +176,10 @@ Item::Item(char *name) //Constructor } -uint8_t Item::getCmd(bool ext) { +uint8_t Item::getCmd() { aJsonObject *t = aJson.getArrayItem(itemArr, I_CMD); if (t) - if (ext) - return t->valueint; - else return t->valueint & CMD_MASK; + return t->valueint & CMD_MASK; else return -1; } @@ -190,11 +188,42 @@ void Item::setCmd(uint8_t cmdValue) { aJsonObject *itemCmd = aJson.getArrayItem(itemArr, I_CMD); if (itemCmd) { - itemCmd->valueint = cmdValue; + itemCmd->valueint = cmdValue & CMD_MASK | itemCmd->valueint & FLAG_MASK; // Preserve special bits debugSerial<valueint & flag & FLAG_MASK; + } +} + +void Item::setFlag (short flag) +{ + aJsonObject *itemCmd = aJson.getArrayItem(itemArr, I_CMD); + if (itemCmd) + { + itemCmd->valueint |= flag & FLAG_MASK; // Preserve CMD bits + debugSerial<valueint &= CMD_MASK | ~(flag & FLAG_MASK); // Preserve CMD bits + debugSerial<name, sizeof(addrstr)); if (mqttClient.connected() && !ethernetIdleCount) - if (!isParam) //remake + if (!(sendFlags & SEND_PARAMETERS)) { mqttClient.publish(addrstr, cmdstr, true); debugSerial<")<name, sizeof(addrstr)); @@ -1444,7 +1451,7 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) { } - if (isCommand) + if (sendFlags & SEND_COMMAND) { setTopic(addrstr,sizeof(addrstr),T_OUT); strncat(addrstr, itemArr->name, sizeof(addrstr)); @@ -1454,7 +1461,7 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) { debugSerial<")<