light off mechanics
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user