-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcustommqtt.h
58 lines (42 loc) · 1.12 KB
/
custommqtt.h
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
48
49
50
51
52
53
54
55
56
57
58
#ifndef CUSTOM_MQTT_H
#define CUSTOM_MQTT_H
#include <AdvancedLogger.h>
#include <Arduino.h>
#include <HTTPClient.h>
#include <PubSubClient.h>
#include <Ticker.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "ade7953.h"
#include "constants.h"
#include "customtime.h"
#include "global.h"
#include "structs.h"
#include "utils.h"
class CustomMqtt
{
public:
CustomMqtt(
Ade7953 &ade7953,
AdvancedLogger &logger);
void setup();
void loop();
bool setConfiguration(JsonDocument &jsonDocument);
private:
void _setDefaultConfiguration();
void _setConfigurationFromSpiffs();
void _saveConfigurationToSpiffs();
void _disable();
bool _connectMqtt();
void _publishMeter();
bool _publishMessage(const char *topic, const char *message);
bool _validateJsonConfiguration(JsonDocument &jsonDocument);
Ade7953 &_ade7953;
AdvancedLogger &_logger;
bool _isSetupDone = false;
unsigned long _lastMillisMqttLoop = 0;
unsigned long _lastMillisMqttFailed = 0;
unsigned long _mqttConnectionAttempt = 0;
unsigned long _lastMillisMeterPublish = 0;
};
#endif