-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMOSQUITTOWrapper.h
More file actions
39 lines (32 loc) · 1.12 KB
/
MOSQUITTOWrapper.h
File metadata and controls
39 lines (32 loc) · 1.12 KB
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
#if !defined(MOSQUITTOWRAPPER_H)
#define MOSQUITTOWRAPPER_H
#include <mosquitto.h>
class MOSQUITTOWrapper
{
private:
const char *host = "localhost";
int port = 1883;
int keepalive = 60;
bool clean_session = true;
const char *client_id = nullptr;
const char *topic = "test";
public:
struct mosquitto *mosq = nullptr;
void mosquittoCallbackSet();
static void on_log(struct mosquitto *mosq, void *userdata, int level, const char *str);
static void on_connect(struct mosquitto *mosq, void *userdata, int result);
static void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *message);
static void on_subscribe(struct mosquitto *mosq, void *userdata, int mid, int qos_count, const int *granted_qos);
static void on_disconnect(struct mosquitto *mosq, void *userdata, int result);
void mosquittoLoop();
MOSQUITTOWrapper();
MOSQUITTOWrapper(
const char *host,
int port,
const char *client_id,
int keepalive,
bool clean_session,
const char *topic);
~MOSQUITTOWrapper();
};
#endif // MOSQUITTOWRAPPER_H