[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
+8
-8
@@ -624,8 +624,8 @@ void handleWI() {
|
||||
return;
|
||||
|
||||
} else if (server.hasArg("save")) {
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject WEBtoSYS = jsonBuffer.to<JsonObject>();
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> WEBtoSYSBuffer;
|
||||
JsonObject WEBtoSYS = WEBtoSYSBuffer.to<JsonObject>();
|
||||
bool update = false;
|
||||
if (server.hasArg("s1")) {
|
||||
WEBtoSYS["wifi_ssid"] = server.arg("s1");
|
||||
@@ -705,8 +705,8 @@ void handleMQ() {
|
||||
WEBUI_TRACE_LOG(F("handleMQ Arg: %d, %s=%s" CR), i, server.argName(i).c_str(), server.arg(i).c_str());
|
||||
}
|
||||
if (server.hasArg("save")) {
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject WEBtoSYS = jsonBuffer.to<JsonObject>();
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> WEBtoSYSBuffer;
|
||||
JsonObject WEBtoSYS = WEBtoSYSBuffer.to<JsonObject>();
|
||||
bool update = false;
|
||||
|
||||
if (server.hasArg("mh")) {
|
||||
@@ -1567,7 +1567,6 @@ void MQTTtoWebUI(char* topicOri, JsonObject& WebUIdata) { // json object decodin
|
||||
if (success) {
|
||||
stateWebUIStatus();
|
||||
} else {
|
||||
// pub(subjectWebUItoMQTT, "{\"Status\": \"Error\"}"); // Fail feedback
|
||||
Log.error(F("[ WebUI ] MQTTtoWebUI Fail json" CR), WebUIdata);
|
||||
}
|
||||
}
|
||||
@@ -1575,8 +1574,8 @@ void MQTTtoWebUI(char* topicOri, JsonObject& WebUIdata) { // json object decodin
|
||||
|
||||
String stateWebUIStatus() {
|
||||
//Publish display state
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject WebUIdata = jsonBuffer.to<JsonObject>();
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> WebUIdataBuffer;
|
||||
JsonObject WebUIdata = WebUIdataBuffer.to<JsonObject>();
|
||||
WebUIdata["displayMetric"] = (bool)displayMetric;
|
||||
WebUIdata["webUISecure"] = (bool)webUISecure;
|
||||
WebUIdata["displayQueue"] = uxQueueMessagesWaiting(webUIQueue);
|
||||
@@ -1585,7 +1584,8 @@ String stateWebUIStatus() {
|
||||
serializeJson(WebUIdata, output);
|
||||
|
||||
// WebUIdata["currentMessage"] = currentWebUIMessage;
|
||||
pub(subjectWebUItoMQTT, WebUIdata);
|
||||
WebUIdata["origin"] = subjectWebUItoMQTT;
|
||||
enqueueJsonObject(WebUIdata);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user