diff --git a/WaterishOS-core2.0/WaterishOS-core2.0.ino b/WaterishOS-core3.0/WaterishOS-core3.0.ino similarity index 97% rename from WaterishOS-core2.0/WaterishOS-core2.0.ino rename to WaterishOS-core3.0/WaterishOS-core3.0.ino index fb0c0ca..6ea9a87 100644 --- a/WaterishOS-core2.0/WaterishOS-core2.0.ino +++ b/WaterishOS-core3.0/WaterishOS-core3.0.ino @@ -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"); diff --git a/WaterishOS-core2.0/config.h b/WaterishOS-core3.0/config.h similarity index 100% rename from WaterishOS-core2.0/config.h rename to WaterishOS-core3.0/config.h diff --git a/WaterishOS-core3.0/espcommander.cpp b/WaterishOS-core3.0/espcommander.cpp new file mode 100644 index 0000000..3dfc5b2 --- /dev/null +++ b/WaterishOS-core3.0/espcommander.cpp @@ -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"]; +} diff --git a/WaterishOS-core2.0/lcdcontrol.h b/WaterishOS-core3.0/lcdcontrol.h similarity index 100% rename from WaterishOS-core2.0/lcdcontrol.h rename to WaterishOS-core3.0/lcdcontrol.h