-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontroller.h
More file actions
65 lines (45 loc) · 1.18 KB
/
Copy pathcontroller.h
File metadata and controls
65 lines (45 loc) · 1.18 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
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
#ifndef CONTROLLER_H
#define CONTROLLER_H
#define SERVICE_VERSION "1.0.11"
#define RECONNECT_TIMEOUT 10000
#include <QTcpSocket>
#include <QTimer>
#include "crypto.h"
#include "homed.h"
struct handshakeRequest
{
quint32 prime;
quint32 generator;
quint32 sharedKey;
};
class Controller : public HOMEd
{
Q_OBJECT
public:
Controller(const QString &configFile);
private:
QTcpSocket *m_socket;
QTimer *m_timer;
AES128 *m_aes;
DH *m_dh;
QString m_uniqueId, m_token, m_host;
quint16 m_port;
bool m_handshake;
QByteArray m_buffer;
QList <QString> m_retained, m_topics;
QMap <QString, QByteArray> m_messages;
void parseData(QByteArray &buffer);
void sendData(const QByteArray &data);
void sendMessage(const QString &topic, const QJsonObject &message);
public slots:
void quit(void) override;
private slots:
void mqttConnected(void) override;
void mqttReceived(const QByteArray &message, const QMqttTopicName &topic) override;
void connected(void);
void disconnected(void);
void errorOccurred(QAbstractSocket::SocketError error);
void readyRead(void);
void connectToHost(void);
};
#endif