Добавляем системную функцию отправки в MQTT

This commit is contained in:
2022-08-22 21:03:20 +03:00
parent 2bf63798e5
commit 5aef309154

View File

@@ -292,12 +292,12 @@ enum SysOp {
sysop_getSeconds, // sysop_getSeconds, //
sysop_getMonth, // sysop_getMonth, //
sysop_getDay, sysop_getDay,
sysop_getIP sysop_getIP,
sysop_mqttPub
}; };
IoTValue sysExecute(SysOp command, std::vector<IoTValue>& param) { IoTValue sysExecute(SysOp command, std::vector<IoTValue>& param) {
IoTValue value; IoTValue value;
Serial.printf("Call from sysExecute %d\n", command);
switch (command) { switch (command) {
case sysop_reboot: case sysop_reboot:
ESP.restart(); ESP.restart();
@@ -374,6 +374,13 @@ IoTValue sysExecute(SysOp command, std::vector<IoTValue>& param) {
value.isDecimal = false; value.isDecimal = false;
return value; return value;
break; 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 {}; return {};
@@ -403,6 +410,7 @@ public:
if (Callee == "getMonth") operation = sysop_getMonth; else if (Callee == "getMonth") operation = sysop_getMonth; else
if (Callee == "getDay") operation = sysop_getDay; else if (Callee == "getDay") operation = sysop_getDay; else
if (Callee == "getIP") operation = sysop_getIP; else if (Callee == "getIP") operation = sysop_getIP; else
if (Callee == "mqttPub") operation = sysop_mqttPub; else
operation = sysop_notfound; operation = sysop_notfound;
} }