mirror of
https://github.com/Fishwaldo/qt-openzwave.git
synced 2025-07-21 12:38:20 +00:00
make mqtt optional if QT module not present
This commit is contained in:
parent
5078f38acc
commit
ce0022e4d2
2 changed files with 87 additions and 72 deletions
|
@ -6,9 +6,12 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include "qtozwdaemon.h"
|
|
||||||
#include "mqttpublisher.h"
|
|
||||||
#include <qt-openzwave/qt-openzwavedatabase.h>
|
#include <qt-openzwave/qt-openzwavedatabase.h>
|
||||||
|
#include "qtozwdaemon.h"
|
||||||
|
#ifdef HAVE_MQTT
|
||||||
|
#include "mqttpublisher.h"
|
||||||
|
#warning "MQTT Enabled"
|
||||||
|
#endif
|
||||||
|
|
||||||
void handler(int sig) {
|
void handler(int sig) {
|
||||||
void *array[10];
|
void *array[10];
|
||||||
|
@ -59,6 +62,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
parser.addOption(userDir);
|
parser.addOption(userDir);
|
||||||
|
|
||||||
|
#ifdef HAVE_MQTT
|
||||||
QCommandLineOption MQTTServer(QStringList() << "mqtt-server",
|
QCommandLineOption MQTTServer(QStringList() << "mqtt-server",
|
||||||
"MQTT Server Hostname/IP Address",
|
"MQTT Server Hostname/IP Address",
|
||||||
"IP/Hostname"
|
"IP/Hostname"
|
||||||
|
@ -71,9 +75,8 @@ int main(int argc, char *argv[])
|
||||||
"Port"
|
"Port"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
parser.addOption(MQTTPort);
|
parser.addOption(MQTTPort);
|
||||||
|
#endif
|
||||||
|
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
if (!parser.isSet(serialPort)) {
|
if (!parser.isSet(serialPort)) {
|
||||||
|
@ -83,12 +86,14 @@ int main(int argc, char *argv[])
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
#ifdef HAVE_MQTT
|
||||||
if (parser.isSet(MQTTServer)) {
|
if (parser.isSet(MQTTServer)) {
|
||||||
settings.setValue("MQTTServer", parser.value(MQTTServer));
|
settings.setValue("MQTTServer", parser.value(MQTTServer));
|
||||||
}
|
}
|
||||||
if (parser.isSet(MQTTPort)) {
|
if (parser.isSet(MQTTPort)) {
|
||||||
settings.setValue("MQTTPort", parser.value(MQTTPort).toInt());
|
settings.setValue("MQTTPort", parser.value(MQTTPort).toInt());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
QLoggingCategory::setFilterRules("qt.remoteobjects.debug=true\n"
|
QLoggingCategory::setFilterRules("qt.remoteobjects.debug=true\n"
|
||||||
|
@ -161,8 +166,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
qtozwdaemon daemon;
|
qtozwdaemon daemon;
|
||||||
|
#ifdef HAVE_MQTT
|
||||||
mqttpublisher mqttpublisher;
|
mqttpublisher mqttpublisher;
|
||||||
mqttpublisher.setOZWDaemon(&daemon);
|
mqttpublisher.setOZWDaemon(&daemon);
|
||||||
|
#endif
|
||||||
daemon.setSerialPort(parser.value(serialPort));
|
daemon.setSerialPort(parser.value(serialPort));
|
||||||
daemon.startOZW();
|
daemon.startOZW();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
QT -= gui
|
QT -= gui
|
||||||
|
|
||||||
QT += remoteobjects mqtt
|
QT += remoteobjects
|
||||||
|
|
||||||
TARGET = ../ozwdaemon
|
TARGET = ../ozwdaemon
|
||||||
|
|
||||||
|
@ -18,41 +18,81 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
qtHaveModule(mqtt) {
|
||||||
main.cpp \
|
QT += mqtt
|
||||||
mqttpublisher.cpp \
|
DEFINES += HAVE_MQTT
|
||||||
qtozwdaemon.cpp \
|
SOURCES += mqttpublisher.cpp \
|
||||||
mqttcommands/mqttcommands.cpp \
|
mqttcommands/mqttcommands.cpp \
|
||||||
mqttcommands/ping.cpp \
|
mqttcommands/ping.cpp \
|
||||||
mqttcommands/open.cpp \
|
mqttcommands/open.cpp \
|
||||||
mqttcommands/refreshnodeinfo.cpp \
|
mqttcommands/refreshnodeinfo.cpp \
|
||||||
mqttcommands/requestNodeState.cpp \
|
mqttcommands/requestNodeState.cpp \
|
||||||
mqttcommands/requestNodeDynamic.cpp \
|
mqttcommands/requestNodeDynamic.cpp \
|
||||||
mqttcommands/requestConfigParam.cpp \
|
mqttcommands/requestConfigParam.cpp \
|
||||||
mqttcommands/requestAllConfigParam.cpp \
|
mqttcommands/requestAllConfigParam.cpp \
|
||||||
mqttcommands/softResetController.cpp \
|
mqttcommands/softResetController.cpp \
|
||||||
mqttcommands/hardResetController.cpp \
|
mqttcommands/hardResetController.cpp \
|
||||||
mqttcommands/cancelControllerCommand.cpp \
|
mqttcommands/cancelControllerCommand.cpp \
|
||||||
mqttcommands/testNetworkNode.cpp \
|
mqttcommands/testNetworkNode.cpp \
|
||||||
mqttcommands/testNetwork.cpp \
|
mqttcommands/testNetwork.cpp \
|
||||||
mqttcommands/healNetworkNode.cpp \
|
mqttcommands/healNetworkNode.cpp \
|
||||||
mqttcommands/healNetwork.cpp \
|
mqttcommands/healNetwork.cpp \
|
||||||
mqttcommands/addNode.cpp \
|
mqttcommands/addNode.cpp \
|
||||||
mqttcommands/addNodeSecure.cpp \
|
mqttcommands/addNodeSecure.cpp \
|
||||||
mqttcommands/removeNode.cpp \
|
mqttcommands/removeNode.cpp \
|
||||||
mqttcommands/removeFailedNode.cpp \
|
mqttcommands/removeFailedNode.cpp \
|
||||||
mqttcommands/hasNodeFailed.cpp \
|
mqttcommands/hasNodeFailed.cpp \
|
||||||
mqttcommands/requestNodeNeighborUpdate.cpp \
|
mqttcommands/requestNodeNeighborUpdate.cpp \
|
||||||
mqttcommands/assignReturnRoute.cpp \
|
mqttcommands/assignReturnRoute.cpp \
|
||||||
mqttcommands/deleteAllReturnRoute.cpp \
|
mqttcommands/deleteAllReturnRoute.cpp \
|
||||||
mqttcommands/sendNodeInformation.cpp \
|
mqttcommands/sendNodeInformation.cpp \
|
||||||
mqttcommands/replaceFailedNode.cpp \
|
mqttcommands/replaceFailedNode.cpp \
|
||||||
mqttcommands/requestNetworkUpdate.cpp \
|
mqttcommands/requestNetworkUpdate.cpp \
|
||||||
mqttcommands/IsNodeFailed.cpp \
|
mqttcommands/IsNodeFailed.cpp \
|
||||||
mqttcommands/checkLatestConfigFileRevision.cpp \
|
mqttcommands/checkLatestConfigFileRevision.cpp \
|
||||||
mqttcommands/checkLatestMFSRevision.cpp \
|
mqttcommands/checkLatestMFSRevision.cpp \
|
||||||
mqttcommands/downloadLatestConfigFileRevision.cpp \
|
mqttcommands/downloadLatestConfigFileRevision.cpp \
|
||||||
mqttcommands/downloadLatestMFSRevision.cpp
|
mqttcommands/downloadLatestMFSRevision.cpp
|
||||||
|
|
||||||
|
HEADERS += mqttpublisher.h \
|
||||||
|
mqttcommands/mqttcommands.h \
|
||||||
|
mqttcommands/ping.h \
|
||||||
|
mqttcommands/open.h \
|
||||||
|
mqttcommands/refreshnodeinfo.h \
|
||||||
|
mqttcommands/requestNodeState.h \
|
||||||
|
mqttcommands/requestNodeDynamic.h \
|
||||||
|
mqttcommands/requestConfigParam.h \
|
||||||
|
mqttcommands/requestAllConfigParam.h \
|
||||||
|
mqttcommands/softResetController.h \
|
||||||
|
mqttcommands/hardResetController.h \
|
||||||
|
mqttcommands/cancelControllerCommand.h \
|
||||||
|
mqttcommands/testNetworkNode.h \
|
||||||
|
mqttcommands/testNetwork.h \
|
||||||
|
mqttcommands/healNetworkNode.h \
|
||||||
|
mqttcommands/healNetwork.h \
|
||||||
|
mqttcommands/addNode.h \
|
||||||
|
mqttcommands/addNodeSecure.h \
|
||||||
|
mqttcommands/removeNode.h \
|
||||||
|
mqttcommands/removeFailedNode.h \
|
||||||
|
mqttcommands/hasNodeFailed.h \
|
||||||
|
mqttcommands/requestNodeNeighborUpdate.h \
|
||||||
|
mqttcommands/assignReturnRoute.h \
|
||||||
|
mqttcommands/deleteAllReturnRoute.h \
|
||||||
|
mqttcommands/sendNodeInformation.h \
|
||||||
|
mqttcommands/replaceFailedNode.h \
|
||||||
|
mqttcommands/requestNetworkUpdate.h \
|
||||||
|
mqttcommands/IsNodeFailed.h \
|
||||||
|
mqttcommands/checkLatestConfigFileRevision.h \
|
||||||
|
mqttcommands/CheckLatestMFSRevision.h \
|
||||||
|
mqttcommands/downloadLatestConfigFileRevision.h \
|
||||||
|
mqttcommands/downloadLatestMFSRevision.h
|
||||||
|
} else {
|
||||||
|
warning("MQTT Qt Module Not Found. Not Building MQTT Client Capabilities")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
qtozwdaemon.cpp
|
||||||
|
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
|
@ -61,39 +101,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mqttpublisher.h \
|
|
||||||
qtozwdaemon.h \
|
qtozwdaemon.h \
|
||||||
mqttcommands/mqttcommands.h \
|
|
||||||
mqttcommands/ping.h \
|
|
||||||
mqttcommands/open.h \
|
|
||||||
mqttcommands/refreshnodeinfo.h \
|
|
||||||
mqttcommands/requestNodeState.h \
|
|
||||||
mqttcommands/requestNodeDynamic.h \
|
|
||||||
mqttcommands/requestConfigParam.h \
|
|
||||||
mqttcommands/requestAllConfigParam.h \
|
|
||||||
mqttcommands/softResetController.h \
|
|
||||||
mqttcommands/hardResetController.h \
|
|
||||||
mqttcommands/cancelControllerCommand.h \
|
|
||||||
mqttcommands/testNetworkNode.h \
|
|
||||||
mqttcommands/testNetwork.h \
|
|
||||||
mqttcommands/healNetworkNode.h \
|
|
||||||
mqttcommands/healNetwork.h \
|
|
||||||
mqttcommands/addNode.h \
|
|
||||||
mqttcommands/addNodeSecure.h \
|
|
||||||
mqttcommands/removeNode.h \
|
|
||||||
mqttcommands/removeFailedNode.h \
|
|
||||||
mqttcommands/hasNodeFailed.h \
|
|
||||||
mqttcommands/requestNodeNeighborUpdate.h \
|
|
||||||
mqttcommands/assignReturnRoute.h \
|
|
||||||
mqttcommands/deleteAllReturnRoute.h \
|
|
||||||
mqttcommands/sendNodeInformation.h \
|
|
||||||
mqttcommands/replaceFailedNode.h \
|
|
||||||
mqttcommands/requestNetworkUpdate.h \
|
|
||||||
mqttcommands/IsNodeFailed.h \
|
|
||||||
mqttcommands/checkLatestConfigFileRevision.h \
|
|
||||||
mqttcommands/CheckLatestMFSRevision.h \
|
|
||||||
mqttcommands/downloadLatestConfigFileRevision.h \
|
|
||||||
mqttcommands/downloadLatestMFSRevision.h
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue