Merge pull request #3 in WAT/waterishos-revision3.0x from develop to master

* commit '9c557b1f8e66fa35a7483279f0b0f920ba07c0ad':
  Fix bugs
  add espcommander
  Preparing ESPCommander Intergration
This commit is contained in:
Siwat Sirichai 2019-08-23 03:47:01 +00:00
commit 763b934796
3 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#include <ArduinoJson.h>
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
#include <PubSubClient.h> #include <PubSubClient.h>
#include <MqttWildcard.h> #include <MqttWildcard.h>
@ -69,6 +70,22 @@ 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()));
} }
// Copyright Siwat INC(tm) 2019
// Created by Siwat Sirichai
// ESPCommander EXTENDED v1.2
// For Legal Distribution of this code, the comment must not be removed!
void espcommander(String topic, String rawcommand) {
StaticJsonDocument<200> doc;
DeserializationError error = deserializeJson(doc, rawcommand);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
return;
}
const char* command = doc["command"];
const char* value = doc["value"];
}
//END OF ESPCOMMANDER CODE
void setup() { void setup() {
lcd.begin(); lcd.begin();
writelcd(" Siwat INC (tm) "," Waterish OS"); writelcd(" Siwat INC (tm) "," Waterish OS");
@ -117,6 +134,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");