-
Notifications
You must be signed in to change notification settings - Fork 1
/
MQTToverSerial.h
40 lines (31 loc) · 1.06 KB
/
MQTToverSerial.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
#ifndef MQTTOVERSERIAL
#define MQTTOVERSERIAL
#include <WiFi.h>
#include "PubSubClient.h"
class MQTToverSerial
{
public:
MQTToverSerial(WiFiClient& _wifiClient, HardwareSerial &_serial, const char* _serverIp, int _serverPort, const char* _MQTTlogin, const char* _MQTTpass, const char* _MQTTid, HardwareSerial* _debugSerial = NULL);
~MQTToverSerial();
bool SubscribeTopic(const char* topic);
bool UnsubscribeTopic(const char* topic);
bool Publish(const char* topic, const char* message);
bool Loop();
void SetSpecialCharacter(char _specialCharacter) { specialCharacter = _specialCharacter; };
char GetSpecialCharacter() { return specialCharacter; };
void ReadSerial();
private:
PubSubClient* pubSubClient = NULL;
HardwareSerial &serial;
HardwareSerial* debugSerial;
WiFiClient &wifiClient;
const char* &serverIp;
int &serverPort;
const char* &MQTTlogin;
const char* &MQTTpass;
const char* &MQTTid;
char specialCharacter = '$';
void Reconnect();
void Error(const char* buff);
};
#endif