-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMQTTDataModule.h
74 lines (60 loc) · 1.73 KB
/
MQTTDataModule.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @file MQTTDataModule.h
* @Author BeeeOn team - Peter Tisovcik <[email protected]>
* @date September, 2016
*/
#ifndef MQTT_DATA_MODULE_H
#define MQTT_DATA_MODULE_H
#include <memory>
#include <string>
#include "MQTTDataParser.h"
#include "ModuleADT.h"
#include "device_table.h"
#include "utils.h"
#define MQTT_DATA_MODULE_TO_ADAAPP (std::string)"BeeeOn/MQTTDataModule/ToAdaApp"
#define MQTT_DATA_MODULE_FROM_ADAAPP (std::string)"BeeeOn/MQTTDataModule/FromAdaApp"
class Aggregator;
/*
* The class implements interface for module within the Adaapp. It uses mosquitto
* for communication in JSON format. MQTTDataModule provides support for listening,
* clearing and setting actuator messages from server and sending data to server
* from sensor.
*/
class MQTTDataModule : public ModuleADT
{
void threadFunction() override;
public:
MQTTDataModule(IOTMessage msg, std::shared_ptr<Aggregator> agg);
void parseCmdFromServer(const Command & cmd) override;
/*
* Send message from modul to MQTT
* @param msg message
*/
void sendConfigCmd(std::string msg);
/*
* Receive message from MQTT
* @param received message
*/
void msgToMQTTDataModule(std::string msg);
/*
* Create pairing message
* {"state": "listen"}
* @return Pairing message
*/
std::string createPairingMessage() const;
/*
* Create delete message
* {"device": { "euid": "" }, "state": "clean" }
* @return Delete message
*/
std::string createDeleteMessage(const euid_t& euid) const;
/*
* Create message which set actuator
* {"state": "set", "euid": "", "data": [{"module_id": "", "value:": ""}]}
* @return Set Message
*/
std::string createSetActuatorsMessage(const Command& cmd) const;
private:
IOTMessage m_msg;
};
#endif