light off mechanics

This commit is contained in:
hg
2016-07-11 21:51:33 +02:00
parent cb9483e6ff
commit 99e4edf762
8 changed files with 396 additions and 11 deletions

View File

@ -20,6 +20,8 @@ extern Hmi hmi;
static const char MESSAGE_TOPIC[] = "IoT/Monitor/Message";
static const char ALARM_TOPIC[] = "IoT/Monitor/Alarm";
static const char SECONDS_TOPIC[] = "IoT/SecondsSinceMidnight";
void callback(char* topic, byte* payload, unsigned int length);
@ -77,6 +79,9 @@ void callback(char* topic, byte* payload, unsigned int length) {
hmi.updateMessage(slot, headerStr, bodyStr);
}
}
} else if (!strcmp(topic, SECONDS_TOPIC)) {
uint32_t seconds = atol(buffer);
hmi.setSeconds(seconds);
} else {
Serial << "Strange, unknown topic received" << endl;
}
@ -170,6 +175,7 @@ void MqttClientNS::exec() {
if (mqttClient.connect("Monitor")) {
mqttClient.subscribe(MESSAGE_TOPIC);
mqttClient.subscribe(ALARM_TOPIC);
mqttClient.subscribe(SECONDS_TOPIC);
disconnectTime = millis();
mqttClient.publish("IoT/Monitor/Started", "monitor started");
disconnectState = 0;