From ea49576b206582d2a8bab9fab3fcb22239c33e6a Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 20 May 2024 00:44:18 +0700 Subject: [PATCH] global state request --- .gitignore | 1 + ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 9bea433..a965236 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store +/ESPMegaPRO-OS-SDK diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp index 80fd0d3..2b9c877 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaIoT.cpp @@ -56,6 +56,16 @@ void ESPMegaIoT::mqttCallback(char *topic, byte *payload, unsigned int length) { callback.second(topic_without_base, payload_buffer); } + // Check for global state request + if (!strcmp(topic_without_base,"requeststate")) { + for (int i = 0; i < 255; i++) + { + if (components[i] != NULL) + { + components[i]->publishReport(); + } + } + } // Call the respective card's mqtt callback // Note that after the base topic, there should be the card id // /base_topic/card_id/...