add watchdog handling
This commit is contained in:
parent
99e4edf762
commit
444ace95e0
@ -28,8 +28,6 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
wdt_reset();
|
|
||||||
|
|
||||||
if (tick.check()) {
|
if (tick.check()) {
|
||||||
Serial << "tick" << endl;
|
Serial << "tick" << endl;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "mqttclient.h"
|
#include "mqttclient.h"
|
||||||
|
|
||||||
|
#include <avr/wdt.h>
|
||||||
#include <Streaming.h>
|
#include <Streaming.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiUDP.h>
|
#include <WiFiUDP.h>
|
||||||
@ -21,6 +22,7 @@ extern Hmi hmi;
|
|||||||
static const char MESSAGE_TOPIC[] = "IoT/Monitor/Message";
|
static const char MESSAGE_TOPIC[] = "IoT/Monitor/Message";
|
||||||
static const char ALARM_TOPIC[] = "IoT/Monitor/Alarm";
|
static const char ALARM_TOPIC[] = "IoT/Monitor/Alarm";
|
||||||
static const char SECONDS_TOPIC[] = "IoT/SecondsSinceMidnight";
|
static const char SECONDS_TOPIC[] = "IoT/SecondsSinceMidnight";
|
||||||
|
static const char WATCHDOG_TOPIC[] = "IoT/Watchdog";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +84,8 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
} else if (!strcmp(topic, SECONDS_TOPIC)) {
|
} else if (!strcmp(topic, SECONDS_TOPIC)) {
|
||||||
uint32_t seconds = atol(buffer);
|
uint32_t seconds = atol(buffer);
|
||||||
hmi.setSeconds(seconds);
|
hmi.setSeconds(seconds);
|
||||||
|
} else if (!strcmp(topic, WATCHDOG_TOPIC)) {
|
||||||
|
wdt_reset();
|
||||||
} else {
|
} else {
|
||||||
Serial << "Strange, unknown topic received" << endl;
|
Serial << "Strange, unknown topic received" << endl;
|
||||||
}
|
}
|
||||||
@ -176,6 +180,7 @@ void MqttClientNS::exec() {
|
|||||||
mqttClient.subscribe(MESSAGE_TOPIC);
|
mqttClient.subscribe(MESSAGE_TOPIC);
|
||||||
mqttClient.subscribe(ALARM_TOPIC);
|
mqttClient.subscribe(ALARM_TOPIC);
|
||||||
mqttClient.subscribe(SECONDS_TOPIC);
|
mqttClient.subscribe(SECONDS_TOPIC);
|
||||||
|
mqttClient.subscribe(WATCHDOG_TOPIC);
|
||||||
disconnectTime = millis();
|
disconnectTime = millis();
|
||||||
mqttClient.publish("IoT/Monitor/Started", "monitor started");
|
mqttClient.publish("IoT/Monitor/Started", "monitor started");
|
||||||
disconnectState = 0;
|
disconnectState = 0;
|
||||||
@ -195,7 +200,7 @@ void MqttClientNS::exec() {
|
|||||||
|
|
||||||
if (disconnectState == 0) {
|
if (disconnectState == 0) {
|
||||||
String msg = String("{ \"metadata\": { \"device\": \"Monitor\" }, \"data\": { \"uptime\": ") + uptime + String("}}");
|
String msg = String("{ \"metadata\": { \"device\": \"Monitor\" }, \"data\": { \"uptime\": ") + uptime + String("}}");
|
||||||
mqttClient.publish("IoT/Monitor/Heartbeat", (char*)msg.c_str());
|
mqttClient.publish("IoT/Heartbeat/Monitor", (char*)msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user