ready so far

This commit is contained in:
hg
2016-07-10 18:38:53 +02:00
parent 627656e7b6
commit cb9483e6ff
5 changed files with 35 additions and 48 deletions

View File

@ -18,8 +18,8 @@
extern Hmi hmi;
static const char MESSAGE_TOPIC[] = "IoT/Message/Monitor";
static const char ALARM_TOPIC[] = "IoT/Alarm/Monitor";
static const char MESSAGE_TOPIC[] = "IoT/Monitor/Message";
static const char ALARM_TOPIC[] = "IoT/Monitor/Alarm";
void callback(char* topic, byte* payload, unsigned int length);
@ -137,12 +137,12 @@ void MqttClientNS::begin() {
}
void MqttClientNS::exec() {
// if (minute.check() == 1) {
// byte r = Ethernet.maintain();
// Serial << "Ethernet.maintain: " << r << endl;
// if ((r == DHCP_CHECK_REBIND_FAIL) || (r == DHCP_CHECK_RENEW_FAIL)) {
// }
// }
// if (minute.check() == 1) {
// byte r = Ethernet.maintain();
// Serial << "Ethernet.maintain: " << r << endl;
// if ((r == DHCP_CHECK_REBIND_FAIL) || (r == DHCP_CHECK_RENEW_FAIL)) {
// }
// }
if ((disconnectState == 0) && (! mqttClient.loop())) {
disconnectState = 1;
@ -171,6 +171,7 @@ void MqttClientNS::exec() {
mqttClient.subscribe(MESSAGE_TOPIC);
mqttClient.subscribe(ALARM_TOPIC);
disconnectTime = millis();
mqttClient.publish("IoT/Monitor/Started", "monitor started");
disconnectState = 0;
} else {
disconnectState = 1;
@ -188,7 +189,7 @@ void MqttClientNS::exec() {
if (disconnectState == 0) {
String msg = String("{ \"metadata\": { \"device\": \"Monitor\" }, \"data\": { \"uptime\": ") + uptime + String("}}");
mqttClient.publish("IoT/Heartbeat/Monitor", (char*)msg.c_str());
mqttClient.publish("IoT/Monitor/Heartbeat", (char*)msg.c_str());
}
}