forked from MTJoker/HomeStatusDisplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeStatusDisplay.hpp
48 lines (33 loc) · 1002 Bytes
/
HomeStatusDisplay.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "HSDConfig.hpp"
#include "HSDWifi.hpp"
#include "HSDWebserver.hpp"
#include "HSDLeds.hpp"
#include "HSDMqtt.hpp"
class HomeStatusDisplay
{
public:
HomeStatusDisplay();
void begin(const char* version, const char* identifier);
void work();
private:
unsigned long calcUptime();
static const int MQTT_MSG_MAX_LEN = 50;
void mqttCallback(char* topic, byte* payload, unsigned int length);
bool isStatusTopic(String& topic);
HSDConfig::deviceType getDeviceType(String& statusTopic);
String getDevice(String& statusTopic);
void handleStatus(String device, HSDConfig::deviceType type, String msg);
void handleTest(String msg);
void checkConnections();
char mqttMsgBuffer[MQTT_MSG_MAX_LEN + 1];
HSDConfig m_config;
HSDWifi m_wifi;
HSDWebserver m_webServer;
HSDMqtt m_mqttHandler;
HSDLeds m_leds;
bool m_lastWifiConnectionState;
bool m_lastMqttConnectionState;
unsigned long m_oneMinuteTimerLast;
unsigned long m_uptime;
};