Preparing ESPCommander Intergration
This commit is contained in:
parent
b2f627bda3
commit
5673cb5b8c
|
@ -69,6 +69,7 @@ void updatemqtt() {
|
||||||
mqtt.publish("/waterishos/node" + nodename + "/flowrate2", String(sensor2.getCurrentFlowrate()));
|
mqtt.publish("/waterishos/node" + nodename + "/flowrate2", String(sensor2.getCurrentFlowrate()));
|
||||||
mqtt.publish("/waterishos/node" + nodename + "/volume2", String(sensor2.getTotalVolume()));
|
mqtt.publish("/waterishos/node" + nodename + "/volume2", String(sensor2.getTotalVolume()));
|
||||||
}
|
}
|
||||||
|
#include "espcommander.cpp"
|
||||||
void setup() {
|
void setup() {
|
||||||
lcd.begin();
|
lcd.begin();
|
||||||
writelcd(" Siwat INC (tm) "," Waterish OS");
|
writelcd(" Siwat INC (tm) "," Waterish OS");
|
||||||
|
@ -117,6 +118,7 @@ void setup() {
|
||||||
writelcd(" Telemetry Node","siwatsystem.com");
|
writelcd(" Telemetry Node","siwatsystem.com");
|
||||||
if (client.connect("waterishos",telemetryuser,telemetrykey)) {
|
if (client.connect("waterishos",telemetryuser,telemetrykey)) {
|
||||||
writelcd(" Telemetry Node","Connected");
|
writelcd(" Telemetry Node","Connected");
|
||||||
|
mqtt.subscribe("/waterishos/node" + nodename + "command", espcommander);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
} else {
|
} else {
|
||||||
writelcd(" Telemetry Node"," Failed Offline");
|
writelcd(" Telemetry Node"," Failed Offline");
|
|
@ -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"];
|
||||||
|
}
|
Loading…
Reference in New Issue