cleanUp persistance of command topics (update libs

This commit is contained in:
2022-02-13 18:47:40 +03:00
parent fc8b04ac9b
commit d30591d9f7
2 changed files with 38 additions and 32 deletions

View File

@@ -388,12 +388,30 @@ void mqttCallback(char *topic, byte *payload, unsigned int length)
char * subItem = NULL;
// in Retaining status - trying to restore previous state from retained output topic. Retained input topics are not relevant.
if (lanStatus == RETAINING_COLLECTING) pfxlen=inTopic(topic,T_OUT);
if (lanStatus == RETAINING_COLLECTING)
{
pfxlen=inTopic(topic,T_OUT);
if (!pfxlen) // There is not status topic
{
if (mqttClient.isRetained())
{
pfxlen=inTopic(topic,T_BCST);
if (!pfxlen) pfxlen = inTopic(topic,T_DEV);
if (!pfxlen) return; // Not command topic ever
itemName=topic+pfxlen;
if (itemName[0]=='$') return;// -6; //Skipping homie stuff
debugSerial<<F("CleanUp retained topic ")<<topic<<endl;
mqttClient.deleteTopic(topic);
}
return;
}
}
else
{
pfxlen=inTopic(topic,T_BCST);
if (!pfxlen) pfxlen = inTopic(topic,T_DEV);
}
if (!pfxlen) {
debugSerial<<F("Skipping..")<<endl;
return;// -3;
@@ -406,28 +424,16 @@ else
cmd_parse((char *)payload);
return;// -4;
}
/*
if (subItem = strchr(itemName, '/'))
{
*subItem = 0;
subItem++;
if (*subItem=='$') return;// -5; //Skipping homie stuff
}
if (itemName[0]=='$') return;// -6; //Skipping homie stuff
Item item(itemName);
if (item.isValid()) {
//return
item.Ctrl((char *)payload,subItem);
} //valid item
*/
if (itemName[0]=='$') return;// -6; //Skipping homie stuff
//debugSerial<<F("itemName ")<<itemName<<endl;
Item item(itemName);
if (item.isValid()) item.Ctrl((char *)payload);
// else debugSerial<<F("item invalid")<<endl;
if (lanStatus != RETAINING_COLLECTING && (mqttClient.isRetained()))
{
debugSerial<<F("CleanUp retained topic ")<<topic<<endl;
mqttClient.deleteTopic(topic);
}
return;// -7;
}

View File

@@ -102,7 +102,7 @@ lib_deps =
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
; https://github.com/anklimov/Artnet.git
; FastLED@3.3.2
Adafruit Unified Sensor
@@ -162,7 +162,7 @@ lib_deps =
https://github.com/tzapu/WiFiManager
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
Streaming
;ESP_EEPROM
;https://github.com/anklimov/NRFFlashStorage
@@ -234,7 +234,7 @@ lib_deps =
;https://github.com/zhouhan0126/WebServer-esp32.git
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
Streaming
;EEPROM
;https://github.com/anklimov/NRFFlashStorage
@@ -309,7 +309,7 @@ lib_deps =
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Ethernet.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED@3.3.2
SD
@@ -371,7 +371,7 @@ lib_deps =
;https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet5100
;5100 lib have ~90 bytes less footprint of RAM
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
;https://github.com/anklimov/Artnet.git
;FastLED@3.3.2
Adafruit Unified Sensor
@@ -445,7 +445,7 @@ lib_deps =
;https://github.com/anklimov/Ethernet5100
;5100 lib have ~90 bytes less footprint of RAM
https://github.com/anklimov/Ethernet.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
;https://github.com/anklimov/Artnet.git
FastLED@3.3.2
Adafruit Unified Sensor
@@ -496,7 +496,7 @@ lib_deps =
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet2
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED@3.3.2
Adafruit Unified Sensor
@@ -573,7 +573,7 @@ lib_deps =
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
https://github.com/FastLED/FastLED.git
Adafruit Unified Sensor
@@ -629,7 +629,7 @@ lib_deps =
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED@3.3.2
Adafruit Unified Sensor
@@ -692,7 +692,7 @@ lib_deps =
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Ethernet
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED@3.3.2
SD
@@ -745,7 +745,7 @@ lib_deps =
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet5100
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED@3.3.2
Adafruit Unified Sensor
@@ -808,7 +808,7 @@ lib_deps =
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
ArduinoHttpClient
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
Streaming
UIPEthernet
https://github.com/anklimov/NRFFlashStorage
@@ -869,7 +869,7 @@ lib_deps =
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
ArduinoHttpClient
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/pubsubclient.git
Streaming
Ethernet
https://github.com/anklimov/NRFFlashStorage