-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmqttController.h
50 lines (43 loc) · 919 Bytes
/
mqttController.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
/*
* usage:
*
* #include "mqttController.h"
*
* PubSubClient mqttClient(wifi_client);
* MqttController MqttCon(&mqttClient);
* StaticJsonBuffer<300> JSONbuffer;
* JsonObject& publishData = JSONbuffer.createObject();
* char JSONmessageBuffer[300];
*
* MqttCon.mqttConnect();
*
* MqttCon.mqttLoop();
*
*
*
*
*
*
*/
#ifndef _MQTTCONTROLLER_H
#define _MQTTCONTROLLER_H
#include "Arduino.h"
#include "wifiController.h"
#include "eepromController.h"
#include "ledController.h"
#include <PubSubClient.h>
#include <ArduinoJson.h>
class MqttController
{
public:
MqttController(PubSubClient *mqttClient);
void mqttConnect();
int mqttIsConnected();
void mqttPublish(char* JSONmessageBuffer);
void mqttLoop();
void mqttReconnect();
static void callback(char* topic, byte* payload, unsigned int length);
private:
PubSubClient *_mqtt_client;
};
#endif