From 5673cb5b8c9993ab143278ec33b4459819e01574 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 21 Aug 2019 21:01:13 +0700 Subject: [PATCH] Preparing ESPCommander Intergration --- .../WaterishOS-core3.0.ino | 2 ++ .../config.h | 0 WaterishOS-core3.0/espcommander.cpp | 14 ++++++++++++++ .../lcdcontrol.h | 0 4 files changed, 16 insertions(+) rename WaterishOS-core2.0/WaterishOS-core2.0.ino => WaterishOS-core3.0/WaterishOS-core3.0.ino (97%) rename {WaterishOS-core2.0 => WaterishOS-core3.0}/config.h (100%) create mode 100644 WaterishOS-core3.0/espcommander.cpp rename {WaterishOS-core2.0 => WaterishOS-core3.0}/lcdcontrol.h (100%) 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