[SYS] Implement a central queue (#1767)
to avoid concurrency issues when modules or/and gateways want to publish data
This commit is contained in:
1 parent
ca9ef664ab
commit
029409c0c3
39 files changed
+491
-407
No files matched your search
@@ -144,11 +144,10 @@ void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
|
||||
if (ONOFFConfig.useLastStateOnStart) {
|
||||
ONOFFdata["save"] = true;
|
||||
ONOFFConfig_fromJson(ONOFFdata);
|
||||
ONOFFdata.remove("save");
|
||||
}
|
||||
# endif
|
||||
// we acknowledge the sending by publishing the value to an acknowledgement topic
|
||||
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
|
||||
stateONOFFMeasures();
|
||||
} else {
|
||||
if (ONOFFdata["cmd"] == "high_pulse") {
|
||||
Log.notice(F("MQTTtoONOFF high_pulse ok" CR));
|
||||
@@ -290,10 +289,9 @@ void ActuatorTrigger() {
|
||||
if (ONOFFConfig.useLastStateOnStart) {
|
||||
ONOFFdata["save"] = true;
|
||||
ONOFFConfig_fromJson(ONOFFdata);
|
||||
ONOFFdata.remove("save");
|
||||
}
|
||||
# endif
|
||||
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
|
||||
stateONOFFMeasures();
|
||||
}
|
||||
|
||||
void stateONOFFMeasures() {
|
||||
@@ -301,6 +299,7 @@ void stateONOFFMeasures() {
|
||||
StaticJsonDocument<64> jsonBuffer;
|
||||
JsonObject ONOFFdata = jsonBuffer.to<JsonObject>();
|
||||
ONOFFdata["cmd"] = (int)digitalRead(ACTUATOR_ONOFF_GPIO);
|
||||
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
|
||||
ONOFFdata["origin"] = subjectGTWONOFFtoMQTT;
|
||||
enqueueJsonObject(ONOFFdata);
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user