forked from wirenboard/wb-mqtt-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_observer.h
33 lines (26 loc) · 879 Bytes
/
serial_observer.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
#pragma once
#include <vector>
#include <memory>
#include <wbmqtt/mqtt_wrapper.h>
#include "serial_config.h"
#include "serial_port_driver.h"
class TMQTTSerialObserver : public IMQTTObserver,
public std::enable_shared_from_this<TMQTTSerialObserver>
{
public:
TMQTTSerialObserver(PMQTTClientBase mqtt_client,
PHandlerConfig handler_config,
PPort port_override = 0);
void SetUp();
void OnConnect(int rc);
void OnMessage(const struct mosquitto_message *message);
void OnSubscribe(int mid, int qos_count, const int *granted_qos);
void LoopOnce();
void Loop();
bool WriteInitValues();
private:
PMQTTClientBase MQTTClient;
PHandlerConfig Config;
std::vector<PSerialPortDriver> PortDrivers;
};
typedef std::shared_ptr<TMQTTSerialObserver> PMQTTSerialObserver;