From 5aef3091543994f9bed757e5f9b8ffc04d682e30 Mon Sep 17 00:00:00 2001 From: biver Date: Mon, 22 Aug 2022 21:03:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD=D1=83?= =?UTF-8?q?=D1=8E=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=20MQTT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/IoTScenario.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/classes/IoTScenario.cpp b/src/classes/IoTScenario.cpp index a9b3cac8..d8a1d69f 100644 --- a/src/classes/IoTScenario.cpp +++ b/src/classes/IoTScenario.cpp @@ -292,12 +292,12 @@ enum SysOp { sysop_getSeconds, // sysop_getMonth, // sysop_getDay, - sysop_getIP + sysop_getIP, + sysop_mqttPub }; IoTValue sysExecute(SysOp command, std::vector& param) { IoTValue value; - Serial.printf("Call from sysExecute %d\n", command); switch (command) { case sysop_reboot: ESP.restart(); @@ -374,6 +374,13 @@ IoTValue sysExecute(SysOp command, std::vector& param) { value.isDecimal = false; return value; break; + case sysop_mqttPub: + if (param.size() == 2) { + //Serial.printf("Call from sysExecute %s %s\n", param[0].valS.c_str(), param[1].valS.c_str()); + value.valD = mqtt.publish(param[0].valS.c_str(), param[1].valS.c_str(), false); + return value; + } + break; } return {}; @@ -403,6 +410,7 @@ public: if (Callee == "getMonth") operation = sysop_getMonth; else if (Callee == "getDay") operation = sysop_getDay; else if (Callee == "getIP") operation = sysop_getIP; else + if (Callee == "mqttPub") operation = sysop_mqttPub; else operation = sysop_notfound; }