diff --git a/makeosxbundle.sh b/makeosxbundle.sh old mode 100755 new mode 100644 diff --git a/qt-openzwave.pri b/qt-openzwave.pri index f9b6f29..83fa39a 100644 --- a/qt-openzwave.pri +++ b/qt-openzwave.pri @@ -55,7 +55,7 @@ win32 { } else { equals(BUILDTYPE, "debug") { exists ( $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/DebugDLL/OpenZWaved.dll )) { - LIBS += -L$$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/DebugDLL) -lopenzwaved + LIBS += -L$$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/DebugDLL) -lOpenZWaved OZW_LIB_PATH = $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/ReleaseDLL) } else { error("Can't find a copy of OpenZWaved.dll in the DebugDLL Directory"); diff --git a/qt-ozwdaemon/qt-ozwdaemon.pro b/qt-ozwdaemon/qt-ozwdaemon.pro index 893dba0..846739f 100644 --- a/qt-ozwdaemon/qt-ozwdaemon.pro +++ b/qt-ozwdaemon/qt-ozwdaemon.pro @@ -1,6 +1,6 @@ QT -= gui -QT += remoteobjects +QT += remoteobjects mqtt TARGET = ../ozwdaemon diff --git a/qt-ozwdaemon/qtozwdaemon.cpp b/qt-ozwdaemon/qtozwdaemon.cpp index 49f3fbb..8319759 100644 --- a/qt-ozwdaemon/qtozwdaemon.cpp +++ b/qt-ozwdaemon/qtozwdaemon.cpp @@ -1,12 +1,29 @@ #include #include "qtozwdaemon.h" + qtozwdaemon::qtozwdaemon(QObject *parent) : QObject(parent) { this->m_openzwave = new QTOpenZwave(this); this->m_qtozwmanager = this->m_openzwave->GetManager(); QObject::connect(this->m_qtozwmanager, &QTOZWManager::ready, this, &qtozwdaemon::QTOZW_Ready); this->m_qtozwmanager->initilizeSource(true); + + this->m_client = new QMqttClient(this); + this->m_client->setHostname("10.51.107.19"); + this->m_client->setPort(1883); + + connect(this->m_client, &QMqttClient::stateChanged, this, &qtozwdaemon::updateLogStateChange); + connect(this->m_client, &QMqttClient::disconnected, this, &qtozwdaemon::brokerDisconnected); + + connect(this->m_client, &QMqttClient::messageReceived, this, &qtozwdaemon::handleMessage); + connect(m_client, &QMqttClient::pingResponseReceived, this, [this]() { + const QString content = QDateTime::currentDateTime().toString() + + QLatin1String(" PingResponse") + + QLatin1Char('\n'); + qDebug() << content; + }); + this->m_client->connectToHost(); } void qtozwdaemon::QTOZW_Ready() { @@ -19,3 +36,25 @@ void qtozwdaemon::startOZW() { } //this->m_qtozwmanager->open(this->getSerialPort()); } + +void qtozwdaemon::updateLogStateChange() +{ + const QString content = QDateTime::currentDateTime().toString() + + QLatin1String(": State Change: " ) + + QString::number(m_client->state()); + qDebug() << content; + if (this->m_client->state() == QMqttClient::ClientState::Connected) { + this->m_client->subscribe(QMqttTopicFilter("/OpenZWave/commands")); + this->m_client->publish(QMqttTopicName("/OpenZWave/commands"), QString("testhaha").toLocal8Bit()); + } + +} + +void qtozwdaemon::brokerDisconnected() +{ + qDebug() << "Disconnnected"; +} + +void qtozwdaemon::handleMessage(const QByteArray &message, const QMqttTopicName &topic) { + qDebug() << "Received: " << topic.name() << ":" << message; +} diff --git a/qt-ozwdaemon/qtozwdaemon.h b/qt-ozwdaemon/qtozwdaemon.h index 4e6b27d..c18b0fa 100644 --- a/qt-ozwdaemon/qtozwdaemon.h +++ b/qt-ozwdaemon/qtozwdaemon.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -22,12 +23,15 @@ signals: public slots: void QTOZW_Ready(); - + void updateLogStateChange(); + void brokerDisconnected(); + void handleMessage(const QByteArray &message, const QMqttTopicName &topic = QMqttTopicName()); private: QTOpenZwave *m_openzwave; QTOZWManager *m_qtozwmanager; QString m_serialPort; + QMqttClient *m_client; }; #endif // QTOZWDAEMON_H diff --git a/updaterpath.sh b/updaterpath.sh old mode 100755 new mode 100644