diff --git a/qt-ozwdaemon/main.cpp b/qt-ozwdaemon/main.cpp index 2cb887b..422d975 100644 --- a/qt-ozwdaemon/main.cpp +++ b/qt-ozwdaemon/main.cpp @@ -6,9 +6,12 @@ #include #include #include -#include "qtozwdaemon.h" -#include "mqttpublisher.h" #include +#include "qtozwdaemon.h" +#ifdef HAVE_MQTT +#include "mqttpublisher.h" +#warning "MQTT Enabled" +#endif void handler(int sig) { void *array[10]; @@ -59,6 +62,7 @@ int main(int argc, char *argv[]) parser.addOption(userDir); +#ifdef HAVE_MQTT QCommandLineOption MQTTServer(QStringList() << "mqtt-server", "MQTT Server Hostname/IP Address", "IP/Hostname" @@ -71,9 +75,8 @@ int main(int argc, char *argv[]) "Port" ); - parser.addOption(MQTTPort); - +#endif parser.process(a); if (!parser.isSet(serialPort)) { @@ -83,12 +86,14 @@ int main(int argc, char *argv[]) exit(-1); } QSettings settings; +#ifdef HAVE_MQTT if (parser.isSet(MQTTServer)) { settings.setValue("MQTTServer", parser.value(MQTTServer)); } if (parser.isSet(MQTTPort)) { settings.setValue("MQTTPort", parser.value(MQTTPort).toInt()); } +#endif #if 0 QLoggingCategory::setFilterRules("qt.remoteobjects.debug=true\n" @@ -161,8 +166,10 @@ int main(int argc, char *argv[]) qtozwdaemon daemon; +#ifdef HAVE_MQTT mqttpublisher mqttpublisher; mqttpublisher.setOZWDaemon(&daemon); +#endif daemon.setSerialPort(parser.value(serialPort)); daemon.startOZW(); return a.exec(); diff --git a/qt-ozwdaemon/qt-ozwdaemon.pro b/qt-ozwdaemon/qt-ozwdaemon.pro index 93fb01f..3e18029 100644 --- a/qt-ozwdaemon/qt-ozwdaemon.pro +++ b/qt-ozwdaemon/qt-ozwdaemon.pro @@ -1,6 +1,6 @@ QT -= gui -QT += remoteobjects mqtt +QT += remoteobjects 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. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -SOURCES += \ - main.cpp \ - mqttpublisher.cpp \ - qtozwdaemon.cpp \ - mqttcommands/mqttcommands.cpp \ - mqttcommands/ping.cpp \ - mqttcommands/open.cpp \ - mqttcommands/refreshnodeinfo.cpp \ - mqttcommands/requestNodeState.cpp \ - mqttcommands/requestNodeDynamic.cpp \ - mqttcommands/requestConfigParam.cpp \ - mqttcommands/requestAllConfigParam.cpp \ - mqttcommands/softResetController.cpp \ - mqttcommands/hardResetController.cpp \ - mqttcommands/cancelControllerCommand.cpp \ - mqttcommands/testNetworkNode.cpp \ - mqttcommands/testNetwork.cpp \ - mqttcommands/healNetworkNode.cpp \ - mqttcommands/healNetwork.cpp \ - mqttcommands/addNode.cpp \ - mqttcommands/addNodeSecure.cpp \ - mqttcommands/removeNode.cpp \ - mqttcommands/removeFailedNode.cpp \ - mqttcommands/hasNodeFailed.cpp \ - mqttcommands/requestNodeNeighborUpdate.cpp \ - mqttcommands/assignReturnRoute.cpp \ - mqttcommands/deleteAllReturnRoute.cpp \ - mqttcommands/sendNodeInformation.cpp \ - mqttcommands/replaceFailedNode.cpp \ - mqttcommands/requestNetworkUpdate.cpp \ - mqttcommands/IsNodeFailed.cpp \ - mqttcommands/checkLatestConfigFileRevision.cpp \ - mqttcommands/checkLatestMFSRevision.cpp \ - mqttcommands/downloadLatestConfigFileRevision.cpp \ - mqttcommands/downloadLatestMFSRevision.cpp +qtHaveModule(mqtt) { + QT += mqtt + DEFINES += HAVE_MQTT + SOURCES += mqttpublisher.cpp \ + mqttcommands/mqttcommands.cpp \ + mqttcommands/ping.cpp \ + mqttcommands/open.cpp \ + mqttcommands/refreshnodeinfo.cpp \ + mqttcommands/requestNodeState.cpp \ + mqttcommands/requestNodeDynamic.cpp \ + mqttcommands/requestConfigParam.cpp \ + mqttcommands/requestAllConfigParam.cpp \ + mqttcommands/softResetController.cpp \ + mqttcommands/hardResetController.cpp \ + mqttcommands/cancelControllerCommand.cpp \ + mqttcommands/testNetworkNode.cpp \ + mqttcommands/testNetwork.cpp \ + mqttcommands/healNetworkNode.cpp \ + mqttcommands/healNetwork.cpp \ + mqttcommands/addNode.cpp \ + mqttcommands/addNodeSecure.cpp \ + mqttcommands/removeNode.cpp \ + mqttcommands/removeFailedNode.cpp \ + mqttcommands/hasNodeFailed.cpp \ + mqttcommands/requestNodeNeighborUpdate.cpp \ + mqttcommands/assignReturnRoute.cpp \ + mqttcommands/deleteAllReturnRoute.cpp \ + mqttcommands/sendNodeInformation.cpp \ + mqttcommands/replaceFailedNode.cpp \ + mqttcommands/requestNetworkUpdate.cpp \ + mqttcommands/IsNodeFailed.cpp \ + mqttcommands/checkLatestConfigFileRevision.cpp \ + mqttcommands/checkLatestMFSRevision.cpp \ + mqttcommands/downloadLatestConfigFileRevision.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. @@ -61,39 +101,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ - mqttpublisher.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