|
|
@ -16,6 +16,19 @@ |
|
|
|
#include "settings.h"
|
|
|
|
#include "qmqtt.h"
|
|
|
|
|
|
|
|
MQTTClient *MQTTClient::_singleton = NULL; |
|
|
|
|
|
|
|
MQTTClient *MQTTClient::getInstance(void) |
|
|
|
{ |
|
|
|
if (!_singleton) { |
|
|
|
Settings *s = Settings::getInstance(); |
|
|
|
|
|
|
|
_singleton = new MQTTClient(QHostAddress(s->m_broker.address), s->m_broker.port); |
|
|
|
} |
|
|
|
|
|
|
|
return _singleton; |
|
|
|
} |
|
|
|
|
|
|
|
MQTTClient::MQTTClient(const QHostAddress& host, const quint16 port, |
|
|
|
QObject* parent) : QMQTT::Client(host, port, parent) |
|
|
|
{ |
|
|
@ -24,7 +37,8 @@ MQTTClient::MQTTClient(const QHostAddress& host, const quint16 port, |
|
|
|
connect(this, &MQTTClient::received, this, &MQTTClient::onReceived); |
|
|
|
connect(this, &MQTTClient::published, this, &MQTTClient::onPublished); |
|
|
|
connect(this, &MQTTClient::error, this, &MQTTClient::onError); |
|
|
|
qDebug() << "created" << endl; |
|
|
|
|
|
|
|
connectToHost(); |
|
|
|
} |
|
|
|
|
|
|
|
MQTTClient::~MQTTClient() { |
|
|
|