Preparing ESPCommander Intergration

This commit is contained in:
Siwat Sirichai 2019-08-21 21:01:13 +07:00
parent b2f627bda3
commit 5673cb5b8c
4 changed files with 16 additions and 0 deletions

View File

@ -69,6 +69,7 @@ void updatemqtt() {
mqtt.publish("/waterishos/node" + nodename + "/flowrate2", String(sensor2.getCurrentFlowrate()));
mqtt.publish("/waterishos/node" + nodename + "/volume2", String(sensor2.getTotalVolume()));
}
#include "espcommander.cpp"
void setup() {
lcd.begin();
writelcd(" Siwat INC (tm) "," Waterish OS");
@ -117,6 +118,7 @@ void setup() {
writelcd(" Telemetry Node","siwatsystem.com");
if (client.connect("waterishos",telemetryuser,telemetrykey)) {
writelcd(" Telemetry Node","Connected");
mqtt.subscribe("/waterishos/node" + nodename + "command", espcommander);
delay(1000);
} else {
writelcd(" Telemetry Node"," Failed Offline");

View File

@ -0,0 +1,14 @@
// Copyright Siwat INC(tm) 2019
// Created by Siwat Sirichai
// ESPCommander EXTENDED v1.2
void espcommander(String topic, String command) { //the command is in json format!
StaticJsonDocument<200> doc;
DeserializationError error = deserializeJson(doc, json);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
return;
}
String command = doc["command"];
String value = doc["value"];
}