├── .dockerignore ├── .github ├── FUNDING.yml ├── no-response.yml └── workflows │ └── prbuildtest.yml ├── .gitignore ├── .qmake.conf ├── Docker ├── Dockerfile ├── allinone │ ├── etc │ │ └── services.d │ │ │ ├── novnc │ │ │ ├── log │ │ │ │ └── run │ │ │ └── run │ │ │ └── ozwadmin │ │ │ ├── log │ │ │ └── run │ │ │ └── run │ └── opt │ │ └── novnc │ │ └── index.html ├── base │ └── etc │ │ ├── cont-init.d │ │ └── ozw-logs │ │ ├── fix-attrs.d │ │ └── ozw-logs │ │ └── services.d │ │ └── ozwdaemon │ │ ├── finish │ │ ├── log │ │ └── run │ │ └── run └── startozwdaemon.sh ├── LICENSE ├── README.md ├── docs ├── MQTT.md └── qt-openzwave.doxygen ├── makeosxbundle.sh ├── qt-openzwave.pri ├── qt-openzwave.pro ├── qt-openzwave ├── include │ ├── qt-openzwave │ │ ├── qtopenzwave.h │ │ ├── qtozw_pods.h │ │ ├── qtozwassociationmodel.h │ │ ├── qtozwlog.h │ │ ├── qtozwlog.rep │ │ ├── qtozwmanager.h │ │ ├── qtozwmanager.rep │ │ ├── qtozwnodemodel.h │ │ ├── qtozwoptions.h │ │ ├── qtozwoptions.rep │ │ ├── qtozwproxymodels.h │ │ ├── qtozwreplica.h │ │ ├── qtozwvalueidmodel.h │ │ └── websocketiodevice.h │ ├── qtozw_logging.h │ ├── qtozwassociationmodel_p.h │ ├── qtozwlog_p.h │ ├── qtozwmanager_p.h │ ├── qtozwnodemodel_p.h │ ├── qtozwnotification.h │ ├── qtozwoptions_p.h │ └── qtozwvalueidmodel_p.h ├── qt-openzwave.pro └── source │ ├── qtopenzwave.cpp │ ├── qtozw_pods.cpp │ ├── qtozwassociationmodel.cpp │ ├── qtozwassociationmodel_p.cpp │ ├── qtozwlog.cpp │ ├── qtozwlog_p.cpp │ ├── qtozwmanager.cpp │ ├── qtozwmanager_p.cpp │ ├── qtozwnodemodel.cpp │ ├── qtozwnodemodel_p.cpp │ ├── qtozwnotification.cpp │ ├── qtozwoptions.cpp │ ├── qtozwoptions_p.cpp │ ├── qtozwproxymodels.cpp │ ├── qtozwreplica.cpp │ ├── qtozwvalueidmodel.cpp │ ├── qtozwvalueidmodel_p.cpp │ └── websocketiodevice.cpp ├── qt-openzwavedatabase ├── include │ └── qt-openzwave │ │ └── qt-openzwavedatabase.h ├── qt-openzwavedatabase.pro └── source │ └── qt-openzwavedatabase.cpp ├── qt-ozwdaemon ├── main.cpp ├── mqttAssociations.cpp ├── mqttAssociations.h ├── mqttNodes.cpp ├── mqttNodes.h ├── mqttValues.cpp ├── mqttValues.h ├── mqttcommands │ ├── IsNodeFailed.cpp │ ├── IsNodeFailed.h │ ├── addAssociation.cpp │ ├── addAssociation.h │ ├── addNode.cpp │ ├── addNode.h │ ├── assignReturnRoute.cpp │ ├── assignReturnRoute.h │ ├── cancelControllerCommand.cpp │ ├── cancelControllerCommand.h │ ├── checkLatestConfigFileRevision.cpp │ ├── checkLatestConfigFileRevision.h │ ├── checkLatestMFSRevision.cpp │ ├── checkLatestMFSRevision.h │ ├── close.cpp │ ├── close.h │ ├── deleteAllReturnRoute.cpp │ ├── deleteAllReturnRoute.h │ ├── disablePoll.cpp │ ├── disablePoll.h │ ├── downloadLatestConfigFileRevision.cpp │ ├── downloadLatestConfigFileRevision.h │ ├── downloadLatestMFSRevision.cpp │ ├── downloadLatestMFSRevision.h │ ├── enablePoll.cpp │ ├── enablePoll.h │ ├── getPollInterval.cpp │ ├── getPollInterval.h │ ├── hardResetController.cpp │ ├── hardResetController.h │ ├── hasNodeFailed.cpp │ ├── hasNodeFailed.h │ ├── healNetwork.cpp │ ├── healNetwork.h │ ├── healNetworkNode.cpp │ ├── healNetworkNode.h │ ├── mqttcommands.cpp │ ├── mqttcommands.h │ ├── open.cpp │ ├── open.h │ ├── ping.cpp │ ├── ping.h │ ├── refreshValue.cpp │ ├── refreshValue.h │ ├── refreshnodeinfo.cpp │ ├── refreshnodeinfo.h │ ├── removeAssociation.cpp │ ├── removeAssociation.h │ ├── removeFailedNode.cpp │ ├── removeFailedNode.h │ ├── removeNode.cpp │ ├── removeNode.h │ ├── replaceFailedNode.cpp │ ├── replaceFailedNode.h │ ├── requestAllConfigParam.cpp │ ├── requestAllConfigParam.h │ ├── requestConfigParam.cpp │ ├── requestConfigParam.h │ ├── requestNetworkUpdate.cpp │ ├── requestNetworkUpdate.h │ ├── requestNodeDynamic.cpp │ ├── requestNodeDynamic.h │ ├── requestNodeNeighborUpdate.cpp │ ├── requestNodeNeighborUpdate.h │ ├── requestNodeState.cpp │ ├── requestNodeState.h │ ├── sendNodeInformation.cpp │ ├── sendNodeInformation.h │ ├── setPollInterval.cpp │ ├── setPollInterval.h │ ├── setValue.cpp │ ├── setValue.h │ ├── softResetController.cpp │ ├── softResetController.h │ ├── syncroniseNodeNeighbors.cpp │ ├── syncroniseNodeNeighbors.h │ ├── testNetwork.cpp │ ├── testNetwork.h │ ├── testNetworkNode.cpp │ └── testNetworkNode.h ├── mqttpublisher.cpp ├── mqttpublisher.h ├── qt-ozwdaemon.pro ├── qtozwdaemon.cpp ├── qtozwdaemon.h ├── qtrj.cpp ├── qtrj.h └── res │ ├── ozw_SF2_notext.png │ ├── ozw_logo.icns │ └── ozw_logo.ico ├── qt-simpleclient ├── bitsetwidget.cpp ├── bitsetwidget.h ├── bitsetwidget.ui ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── qt-simpleclient.pro ├── qtozw_itemdelegate.cpp ├── qtozw_itemdelegate.h ├── res │ ├── ozw_SF2_notext.png │ ├── ozw_logo.icns │ └── ozw_logo.ico ├── simpleclient.qrc ├── startup.cpp ├── startup.h └── startup.ui ├── setenv.sh └── tools ├── sentry-upload-debug.sh └── updaterpath.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .cache 3 | Docker/Dockerfile 4 | **/*.o 5 | **/moc_*.cpp 6 | **/moc_*.o 7 | **/rep_*.cpp 8 | **/rep_*.o 9 | .qmake.stash 10 | qt-openzwavedatabase/config/** -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [Fishwaldo] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: ozw 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: # Replace with a single custom sponsorship URL 9 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 14 5 | # Label requiring a response 6 | responseRequiredLabel: PendingFeedback 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because there has been no response 10 | to our request for more information from the original author. With only the 11 | information that is currently in the issue, we don't have enough information 12 | to take action. Please reach out if you have or find the answers we need so 13 | that we can investigate further. 14 | -------------------------------------------------------------------------------- /.github/workflows/prbuildtest.yml: -------------------------------------------------------------------------------- 1 | name: ozwdaemon Docker Image Build Test 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, reopened, synchronize] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout Code 12 | uses: actions/checkout@v1 13 | with: 14 | fetch-depth: 1 # shallow clone 15 | - name: Build Docker Image 16 | run: DOCKER_BUILDKIT=1 docker build . --file Docker/Dockerfile -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.dll 10 | *.dylib 11 | 12 | # Qt-es 13 | object_script.*.Release 14 | object_script.*.Debug 15 | *_plugin_import.cpp 16 | /.qmake.cache 17 | /.qmake.stash 18 | *.pro.user 19 | *.pro.user.* 20 | *.qbs.user 21 | *.qbs.user.* 22 | *.moc 23 | moc_*.cpp 24 | moc_*.h 25 | qrc_*.cpp 26 | ui_*.h 27 | *.qmlc 28 | *.jsc 29 | Makefile* 30 | *build-* 31 | 32 | # Qt unit tests 33 | target_wrapper.* 34 | 35 | # QtCreator 36 | *.autosave 37 | 38 | # QtCreator Qml 39 | *.qmlproject.user 40 | *.qmlproject.user.* 41 | 42 | # QtCreator CMake 43 | CMakeLists.txt.user* 44 | 45 | .vscode -------------------------------------------------------------------------------- /.qmake.conf: -------------------------------------------------------------------------------- 1 | top_srcdir=$$PWD 2 | top_builddir=$$shadowed($$PWD) -------------------------------------------------------------------------------- /Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Dockerfile to build OpenZWave Library container images 3 | # Based on CentOS7 4 | ############################################################ 5 | 6 | ARG distcchosts='' 7 | ARG concurrency="12" 8 | ARG qtversion="5.12.9" 9 | 10 | 11 | # Set the base image to Alpine 12 | FROM fishwaldo/ozw-base:${qtversion} as builder 13 | 14 | # File Author / Maintainer 15 | LABEL maintainer="justin@dynam.ac" 16 | 17 | 18 | ENV LC_ALL C 19 | ENV DEBIAN_FRONTEND noninteractive 20 | 21 | WORKDIR /opt 22 | 23 | #RUN echo 'APT::Default-Release "stable";' > /etc/apt/apt.conf.d/99defaultrelease \ 24 | # && echo 'deb http://ftp.debian.org/debian/ unstable main contrib non-free' > /etc/apt/sources.list.d/unstable.list \ 25 | # && apt update 26 | RUN apt update && apt-get -y install rapidjson-dev cmake pkgconf python libunwind-dev libcurl4-openssl-dev libx11-dev libglu1-mesa-dev libexecline-dev 27 | 28 | ARG distcchosts='' 29 | ARG concurrency="12" 30 | ARG qtversion="5.12.9" 31 | 32 | ENV DISTCC_HOSTS="$distcchosts" 33 | 34 | RUN if [ -n "${DISTCC_HOSTS}" ]; then cd /usr/local/bin; ln /usr/bin/distcc gcc; ln /usr/bin/distcc g++; echo "Using DistCC hosts ${DISTCC_HOSTS}"; fi 35 | 36 | ENV PATH=$PATH:/opt/depot_tools/ 37 | ENV DEPOT_TOOLS_UPDATE=0 38 | RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git \ 39 | && cd depot_tools && git checkout 464e9ff && cd .. \ 40 | && mkdir breakpad \ 41 | && cd breakpad \ 42 | && fetch breakpad \ 43 | && cd src \ 44 | && ./configure --disable-processor --disable-tools \ 45 | && make -j${concurrency} \ 46 | && make install 47 | 48 | RUN git clone https://github.com/OpenZWave/open-zwave.git \ 49 | && cd open-zwave \ 50 | && make -j${concurrency} \ 51 | && make install instlibdir=/usr/local/lib/ 52 | 53 | COPY .qmake.conf /opt/qt-openzwave/ 54 | COPY qt-openzwave /opt/qt-openzwave/qt-openzwave 55 | COPY qt-openzwave.pri /opt/qt-openzwave/ 56 | COPY qt-openzwave.pro /opt/qt-openzwave/ 57 | COPY qt-openzwavedatabase /opt/qt-openzwave/qt-openzwavedatabase 58 | COPY qt-ozwdaemon /opt/qt-openzwave/qt-ozwdaemon 59 | COPY qt-openzwave.pro /opt/qt-openzwave/ 60 | 61 | ARG BP_CLIENTID 62 | ARG BP_CLIENTKEY 63 | ARG BUILDNUMBER=0 64 | RUN cd qt-openzwave \ 65 | && if [ -f Makefile ]; then qmake -r; make distclean; fi \ 66 | && qmake -r CONFIG+=release "BP_CLIENTID=$BP_CLIENTID" "BP_CLIENTKEY=$BP_CLIENTKEY" "BUILDNUMBER=$BUILDNUMBER" \ 67 | && make -j${concurrency} \ 68 | && make install 69 | 70 | RUN git clone https://github.com/OpenZWave/ozw-admin.git \ 71 | && cd ozw-admin \ 72 | && if [ -f Makefile ]; then qmake -r; make distclean; fi \ 73 | && qmake -r CONFIG+=release \ 74 | && make -j${concurrency} \ 75 | && make install 76 | 77 | 78 | ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" 79 | 80 | FROM debian:buster-slim as base 81 | 82 | ARG qtversion="5.12.9" 83 | 84 | ENV LC_ALL C 85 | ENV DEBIAN_FRONTEND noninteractive 86 | 87 | LABEL maintainer="justin@dynam.ac" 88 | 89 | WORKDIR /opt 90 | 91 | RUN apt update \ 92 | && apt-get -y install libunwind8 libcurl4 binutils libglib2.0-0 libicu63 wget \ 93 | && apt-get -y purge binutils \ 94 | && apt-get -y autoremove \ 95 | && apt-get clean \ 96 | && rm -rf /var/lib/apt/lists/* 97 | 98 | RUN case `uname -m` in x86_64) var="amd64";; armhf) var="armhf";; armv7l) var="armhf";; aarch64) var="aarch64";; esac && wget https://github.com/just-containers/s6-overlay/releases/download/v2.0.0.1/s6-overlay-$var.tar.gz -O /tmp/s6-overlay.tar.gz \ 99 | && tar xzf /tmp/s6-overlay.tar.gz -C / \ 100 | && rm /tmp/s6-overlay.tar.gz 101 | 102 | 103 | COPY --from=builder /usr/local/bin/ozwdaemon /usr/local/bin/s6* /usr/local/bin/ 104 | COPY --from=builder /usr/local/lib/libopenzwave.so.1.6 /usr/local/lib/ 105 | COPY --from=builder /opt/qt/${qtversion}/lib/libQt5Core* /opt/qt/${qtversion}/lib/libQt5Network* /opt/qt/${qtversion}/lib/libQt5Mqtt* /opt/qt/${qtversion}/lib/libQt5WebSockets* /opt/qt/${qtversion}/lib/libQt5RemoteObjects* /opt/qt/${qtversion}/lib/ 106 | COPY --from=builder /opt/qt/${qtversion}/lib/libqt-openzwave* /opt/qt/${qtversion}/lib/ 107 | COPY --from=builder /opt/qt/${qtversion}/qt-openzwavedatabase.rcc /opt/qt/${qtversion}/ 108 | 109 | COPY Docker/base/ / 110 | 111 | RUN ldconfig -v 112 | 113 | ENV BP_DB_PATH="/opt/ozw/config/crashes/" 114 | ENV S6_LOGGING_SCRIPT="n20 s10000000 T" 115 | WORKDIR /opt/ozw/ 116 | EXPOSE 1983 117 | VOLUME ["/opt/ozw/config/"] 118 | ENTRYPOINT ["/init"] 119 | 120 | FROM base as allinone 121 | 122 | ARG qtversion="5.12.9" 123 | 124 | ENV LC_ALL C 125 | ENV DEBIAN_FRONTEND noninteractive 126 | 127 | ADD https://github.com/novnc/websockify/archive/v0.9.0.tar.gz /opt/source/ 128 | ADD https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz /opt/source/ 129 | 130 | RUN apt update \ 131 | && apt-get -y install libgl1 libpng16-16 libharfbuzz0b libfontconfig1 libmtdev1 libinput10 libxkbcommon0 libdbus-1-3 python3-setuptools python3-numpy \ 132 | && apt-get -y autoremove \ 133 | && apt-get clean \ 134 | && rm -rf /var/lib/apt/lists/* \ 135 | && cd /opt/source/ \ 136 | && tar -xzvf v0.9.0.tar.gz \ 137 | && cd websockify-0.9.0 \ 138 | && python3 setup.py install \ 139 | && cd /opt/source/ \ 140 | && tar -xzvf v1.2.0.tar.gz \ 141 | && cp -R /opt/source/noVNC-1.2.0/ /opt/novnc/ \ 142 | && rm -rf /opt/source/* 143 | 144 | 145 | COPY --from=builder /usr/local/bin/ozwadmin /usr/local/bin/ 146 | COPY --from=builder /opt/qt/${qtversion}/lib/libQt5Svg* /opt/qt/${qtversion}/lib/libQt5Widgets* /opt/qt/${qtversion}/lib/libQt5Gui* /opt/qt/${qtversion}/lib/libQt5Xml* /opt/qt/${qtversion}/lib/libQt5SerialPort* /opt/qt/${qtversion}/lib/libQt5DBus* /opt/qt/${qtversion}/lib/ 147 | COPY --from=builder /opt/qt/${qtversion}/plugins /opt/qt/${qtversion}/plugins 148 | COPY --from=builder /opt/qt/${qtversion}/resources /opt/qt/${qtversion}/resources 149 | COPY --from=builder /opt/qt/${qtversion}/libexec /opt/qt/${qtversion}/libexec 150 | COPY Docker/allinone/ / 151 | 152 | ENV BP_DB_PATH="/opt/ozw/config/crashes/" 153 | ENV VNC_PORT=5901 154 | ENV WEB_PORT=7800 155 | ENV QT_ASSUME_STDERR_HAS_CONSOLE=1 156 | ENV S6_LOGGING_SCRIPT="n20 s10000000 T" 157 | WORKDIR /opt/ozw/ 158 | EXPOSE 1983 159 | EXPOSE 5901 160 | EXPOSE 7800 161 | VOLUME ["/opt/ozw/config/"] 162 | 163 | ENTRYPOINT ["/init"] 164 | -------------------------------------------------------------------------------- /Docker/allinone/etc/services.d/novnc/log/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec logutil-service /opt/ozw/config/logs/novnc/ -------------------------------------------------------------------------------- /Docker/allinone/etc/services.d/novnc/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | logConsole() { 4 | fdmove -c 1 2 s6-echo "[$(basename `pwd`)]: $1"; 5 | } 6 | 7 | logConsole "Executing: /usr/local/bin/websockify --web /opt/novnc/ $WEB_PORT 127.0.0.1:$VNC_PORT" 8 | exec /bin/fdmove -c 2 1 /usr/local/bin/websockify --web /opt/novnc/ $WEB_PORT 127.0.0.1:$VNC_PORT 9 | -------------------------------------------------------------------------------- /Docker/allinone/etc/services.d/ozwadmin/log/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec logutil-service /opt/ozw/config/logs/ozwadmin/ -------------------------------------------------------------------------------- /Docker/allinone/etc/services.d/ozwadmin/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | logConsole() { 4 | fdmove -c 1 2 s6-echo "[$(basename `pwd`)]: $1"; 5 | } 6 | 7 | logConsole "/usr/local/bin/ozwadmin -platform vnc:port=$VNC_PORT -c /opt/ozw/config/ -u /opt/ozw/config/" 8 | exec /bin/fdmove -c 2 1 /usr/local/bin/ozwadmin -platform vnc:size=1024x768:port=$VNC_PORT -c /opt/ozw/config/ -u /opt/ozw/config/ 9 | -------------------------------------------------------------------------------- /Docker/allinone/opt/novnc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Basic Web Based VNC Client

8 |

Standard Web Based VNC Client

9 |

You can also connect a VNC Client to the VNC Port 5901 - Assuming you 10 | have exposed the port

11 | 12 | -------------------------------------------------------------------------------- /Docker/base/etc/cont-init.d/ozw-logs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p /opt/ozw/config/logs 3 | chown nobody:nogroup /opt/ozw/config/logs/ 4 | mkdir -p /opt/ozw/config/crashes 5 | chown nobody:nogroup /opt/ozw/config/crashes -------------------------------------------------------------------------------- /Docker/base/etc/fix-attrs.d/ozw-logs: -------------------------------------------------------------------------------- 1 | /opt/ozw/config/logs true nobody 0644 0755 2 | /opt/ozw/config/crashes true nobody 0644 0755 3 | -------------------------------------------------------------------------------- /Docker/base/etc/services.d/ozwdaemon/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/execlineb -S1 2 | if { fdmove -c 1 2 s6-echo [ozwdaemon]: Exited with Status Code ${1} } 3 | 4 | if { s6-test ${1} -ne 0 } 5 | if { s6-test ${1} -ne 256 } 6 | 7 | if { fdmove -c 1 2 s6-echo [ozwdaemon]: Shutting Down Container } 8 | if { s6-svscanctl -t /var/run/s6/services } 9 | -------------------------------------------------------------------------------- /Docker/base/etc/services.d/ozwdaemon/log/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec logutil-service /opt/ozw/config/logs/ozwdaemon -------------------------------------------------------------------------------- /Docker/base/etc/services.d/ozwdaemon/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | logConsole() { 4 | fdmove -c 1 2 s6-echo "[$(basename `pwd`)]: $1"; 5 | } 6 | 7 | logConsole "Setting Up....." 8 | logConsole " " 9 | logConsole "========================================================================" 10 | logConsole "Detailed Logging is available in the logs directory of the mapped volume" 11 | logConsole "========================================================================" 12 | logConsole " " 13 | 14 | : "${MQTT_PORT:=1883}" 15 | : "${MQTT_SERVER:=localhost}" 16 | : "${USB_PATH:=/dev/ttyUSB0}" 17 | 18 | OZW_ARGS=() 19 | if [[ ! -c $USB_PATH ]]; then 20 | logConsole "USB Path \"$USB_PATH\" does not exist or is not a Character Device" 21 | exit -5 22 | fi 23 | OZW_ARGS+=(-s "$USB_PATH") 24 | OZW_ARGS+=(--config-dir "${OZW_CONFIG_DIR:-/opt/ozw/config}") 25 | OZW_ARGS+=(--user-dir "${OZW_USER_DIR:-/opt/ozw/config}") 26 | OZW_ARGS+=(--mqtt-server "$MQTT_SERVER") 27 | OZW_ARGS+=(--mqtt-port "$MQTT_PORT") 28 | if [[ ${STOP_ON_FAILURE:=true} == true ]]; then 29 | OZW_ARGS+=(--stop-on-failure) 30 | elif [[ $STOP_ON_FAILURE != false ]]; then 31 | logConsole "Invalid value for STOP_ON_FAILURE: \"$STOP_ON_FAILURE\", expected true or false." 32 | exit -5 33 | fi 34 | if [[ ${MQTT_TLS:=false} == true ]]; then 35 | OZW_ARGS+=(--mqtt-tls) 36 | elif [[ $MQTT_TLS != false ]]; then 37 | logConsole "Invalid value for MQTT_TLS: \"$MQTT_TLS\", expected true or false." 38 | exit -5 39 | fi 40 | OZW_ARGS+=(--mqtt-instance "${OZW_INSTANCE:-1}") 41 | if [[ -n $MQTT_USERNAME ]]; then 42 | OZW_ARGS+=(--mqtt-username "$MQTT_USERNAME") 43 | fi 44 | 45 | logConsole "Waiting until the MQTT broker at $MQTT_SERVER:$MQTT_PORT is available..." 46 | if ! timeout "${MQTT_CONNECT_TIMEOUT:=30}" \ 47 | bash -c "until echo > /dev/tcp/$MQTT_SERVER/$MQTT_PORT; do sleep 1; done" &>/dev/null 48 | then 49 | logConsole "Could not connect to the MQTT broker after $MQTT_CONNECT_TIMEOUT seconds" 50 | exit -3 51 | fi 52 | 53 | logConsole "Starting..." 54 | set -- /usr/local/bin/ozwdaemon "${OZW_ARGS[@]}" "$@" 55 | logConsole "Executing: $@" 56 | exec fdmove -c 2 1 "$@" 57 | -------------------------------------------------------------------------------- /Docker/startozwdaemon.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | : "${MQTT_PORT:=1883}" 4 | : "${MQTT_SERVER:=localhost}" 5 | : "${USB_PATH:=/dev/ttyUSB0}" 6 | 7 | OZW_ARGS=() 8 | if [[ ! -c $USB_PATH ]]; then 9 | echo "USB Path \"$USB_PATH\" does not exist or is not a Character Device" 10 | exit 128 11 | fi 12 | OZW_ARGS+=(-s "$USB_PATH") 13 | OZW_ARGS+=(--config-dir "${OZW_CONFIG_DIR:-/opt/ozw/config}") 14 | OZW_ARGS+=(--user-dir "${OZW_USER_DIR:-/opt/ozw/config}") 15 | OZW_ARGS+=(--mqtt-server "$MQTT_SERVER") 16 | OZW_ARGS+=(--mqtt-port "$MQTT_PORT") 17 | if [[ ${STOP_ON_FAILURE:=true} == true ]]; then 18 | OZW_ARGS+=(--stop-on-failure) 19 | elif [[ $STOP_ON_FAILURE != false ]]; then 20 | echo "Invalid value for STOP_ON_FAILURE: \"$STOP_ON_FAILURE\", expected true or false." 21 | exit 1 22 | fi 23 | if [[ ${MQTT_TLS:=false} == true ]]; then 24 | OZW_ARGS+=(--mqtt-tls) 25 | elif [[ $MQTT_TLS != false ]]; then 26 | echo "Invalid value for MQTT_TLS: \"$MQTT_TLS\", expected true or false." 27 | exit 1 28 | fi 29 | OZW_ARGS+=(--mqtt-instance "${OZW_INSTANCE:-1}") 30 | if [[ -n $MQTT_USERNAME ]]; then 31 | OZW_ARGS+=(--mqtt-username "$MQTT_USERNAME") 32 | fi 33 | 34 | echo "Waiting until the MQTT broker is available..." 35 | if ! timeout "${MQTT_CONNECT_TIMEOUT:=30}" \ 36 | bash -c "until echo > /dev/tcp/$MQTT_SERVER/$MQTT_PORT; do sleep 1; done" &>/dev/null 37 | then 38 | echo "Could not connect to the MQTT broker after $MQTT_CONNECT_TIMEOUT seconds" 39 | exit 124 40 | fi 41 | 42 | set -- ozwdaemon "${OZW_ARGS[@]}" "$@" 43 | 44 | echo "Executing:" "$@" 45 | exec "$@" 46 | -------------------------------------------------------------------------------- /makeosxbundle.sh: -------------------------------------------------------------------------------- 1 | cp ozwdaemon simpleclient.app/Contents/MacOS/ 2 | $1/bin/macdeployqt simpleclient.app -verbose=2 -always-overwrite -dmg 3 | -------------------------------------------------------------------------------- /qt-openzwave.pri: -------------------------------------------------------------------------------- 1 | top_srcdir=$$PWD 2 | top_builddir=$$shadowed($$PWD) 3 | unix { 4 | macx { 5 | ICON = res/ozw_logo.icns 6 | QMAKE_POST_LINK=$$top_srcdir/tools/updaterpath.sh $(TARGET) 7 | QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11 8 | } 9 | !macx: QMAKE_CXXFLAGS += -Wno-deprecated-copy 10 | } 11 | unix { 12 | CONFIG-= no-pkg-config 13 | CONFIG+= link_pkgconfig 14 | !isEmpty(OZW_LIB_PATH) { 15 | !exists($$OZW_LIB_PATH/libopenzwave.so): error("Can't find libopenzwave.so") 16 | !exists($$OZW_INCLUDE_PATH/Manager.h) { 17 | !exists($$OZW_LIB_PATH/cpp/src/Manager.h) { 18 | error("Can't find Manager.h") 19 | } else { 20 | OZW_INCLUDE_PATH=$$OZW_LIB_PATH/cpp/src/ 21 | } 22 | } 23 | !exists($$OZW_DATABASE_PATH/manufacturer_specific.xml) { 24 | !exists($$OZW_LIB_PATH/config/manufacturer_specific.xml) { 25 | error("Can't find manufacturer_specific.xml") 26 | } else { 27 | OZW_DATABASE_PATH=$$absolute_path($$OZW_LIB_PATH/config/) 28 | } 29 | } 30 | OZW_LIB_PATH=$$absolute_path($$OZW_LIB_PATH) 31 | OZW_INCLUDE_PATH=$$absolute_path($$OZW_INCLUDE_PATH) 32 | OZW_LIBS="-L$$OZW_LIB_PATH" 33 | OZW_LIBS+="-lopenzwave" 34 | OZW_DATABASE_PATH=$$absolute_path($$OZW_DATABASE_PATH) 35 | message(" ") 36 | message("OpenZWave Summary:") 37 | message(" OpenZWave Library Path: $$OZW_LIB_PATH") 38 | message(" OpenZWave Include Path: $$OZW_INCLUDE_PATH") 39 | message(" OpenZWave Libs Command: $$OZW_LIBS") 40 | message(" OpenZWave Database Path: $$OZW_DATABASE_PATH") 41 | message(" ") 42 | INCLUDEPATH+=$$OZW_INCLUDE_PATH 43 | !emscripten { 44 | LIBS+=$$OZW_LIBS 45 | } else { 46 | message(" Not Adding OpenZWave to Libs") 47 | } 48 | } else { 49 | exists( $$top_srcdir/../open-zwave/cpp/src/) { 50 | message("Found OZW in $$absolute_path($$top_srcdir/../open-zwave/)") 51 | OZW_LIB_PATH = "$$absolute_path($$top_srcdir/../open-zwave/)" 52 | OZW_INCLUDE_PATH = $$absolute_path($$top_srcdir/../open-zwave/cpp/src/) 53 | OZW_LIBS="-L$$OZW_LIB_PATH" 54 | OZW_LIBS+="-lopenzwave" 55 | OZW_DATABASE_PATH = $$absolute_path($$top_srcdir/../open-zwave/config/) 56 | message(" ") 57 | message("OpenZWave Summary:") 58 | message(" OpenZWave Library Path: $$OZW_LIB_PATH") 59 | message(" OpenZWave Include Path: $$OZW_INCLUDE_PATH") 60 | message(" OpenZWave Libs Command: $$OZW_LIBS") 61 | message(" OpenZWave Database Path: $$OZW_DATABASE_PATH") 62 | message(" ") 63 | INCLUDEPATH+=$$OZW_INCLUDE_PATH 64 | !emscripten { 65 | LIBS+=$$OZW_LIBS 66 | } else { 67 | message(" Not Adding OpenZWave to Libs") 68 | } 69 | } else { 70 | packagesExist("libopenzwave") { 71 | PKGCONFIG += libopenzwave 72 | OZW_DATABASE_PATH=$$system($$PKG_CONFIG --variable=sysconfdir libopenzwave) 73 | message(" ") 74 | message("OpenZWave Summary:") 75 | message(" Using OpenZWave from pkg-config:") 76 | message(" CXXFLAGS: $$system($$PKG_CONFIG --cflags libopenzwave)") 77 | message(" LDFLAGS: $$system($$PKG_CONFIG --libs libopenzwave)") 78 | message(" DATABASE: $$system($$PKG_CONFIG --variable=sysconfdir libopenzwave)") 79 | message(" ") 80 | } else { 81 | error("Can't find OpenZWave Library and Headers"); 82 | } 83 | } 84 | } 85 | } 86 | 87 | win32 { 88 | CONFIG(debug, debug|release) { 89 | BUILDTYPE = debug 90 | } else { 91 | BUILDTYPE = release 92 | } 93 | message(Checking for $$BUILDTYPE build of OZW) 94 | exists( $$top_srcdir/../open-zwave/cpp/src/) { 95 | message("Found OZW in $$absolute_path($$top_srcdir/../open-zwave/cpp/src)") 96 | INCLUDEPATH += $$absolute_path($$top_srcdir/../open-zwave/cpp/src/)/ 97 | OZW_DATABASE_PATH = $$absolute_path($$top_srcdir/../open-zwave/config/) 98 | equals(BUILDTYPE, "release") { 99 | exists( $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/ReleaseDLL/OpenZWave.dll ) ) { 100 | LIBS += -L$$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/ReleaseDLL) -lopenzwave 101 | OZW_LIB_PATH = $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/ReleaseDLL) 102 | } else { 103 | error("Can't find a copy of OpenZWave.dll in the ReleaseDLL Directory"); 104 | } 105 | } else { 106 | equals(BUILDTYPE, "debug") { 107 | exists ( $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/DebugDLL/OpenZWaved.dll )) { 108 | LIBS += -L$$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/DebugDLL) -lOpenZWaved 109 | OZW_LIB_PATH = $$absolute_path($$top_srcdir/../open-zwave/cpp/build/windows/vs2010/ReleaseDLL) 110 | } else { 111 | error("Can't find a copy of OpenZWaved.dll in the DebugDLL Directory"); 112 | } 113 | } 114 | } 115 | isEmpty(OZW_LIB_PATH) { 116 | error("Can't find a copy of OpenZWave with the right builds"); 117 | } 118 | } else { 119 | error("Can't Find a copy of OpenZwave") 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /qt-openzwave.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-04-27T16:10:29 4 | # 5 | #------------------------------------------------- 6 | 7 | TEMPLATE = subdirs 8 | 9 | CONFIG += ordered silent 10 | 11 | SUBDIRS += qt-openzwave \ 12 | qt-openzwavedatabase \ 13 | qt-ozwdaemon 14 | 15 | Examples { 16 | SUBDIRS += qt-simpleclient 17 | } 18 | #win32 { 19 | # SUBDIRS -= qt-openzwavedatabase 20 | #} 21 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtopenzwave.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtopenzwave.h 4 | // 5 | // Main Class For QT-OpenZWave 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | #ifndef QTOPENZWAVE_H 28 | #define QTOPENZWAVE_H 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #if defined(QTOPENZWAVE_LIBRARY) 35 | #define QTOPENZWAVESHARED_EXPORT Q_DECL_EXPORT 36 | #else 37 | #define QTOPENZWAVESHARED_EXPORT Q_DECL_IMPORT 38 | #define OPENZWAVE_USEDLL 1 39 | #endif 40 | 41 | #define PROTOCOL_VERSION 2 42 | 43 | /** 44 | * \mainpage QT-OpenZWave 45 | * \section Introduction Introduction to QT-OpenZWave 46 | * QT-OpenZWave is an open-source, cross-platform QT Wrapper around the OpenZWave 47 | * Library designed to allow developers to write QT Based Applications that can 48 | * interface with a Z-Wave Network. 49 | * Its Design Closely mimics the main OpenZWave Library in structure, while adopting 50 | * several QT Technologies such as Signals/Slots and Models to allow 51 | * quick development of QT based applications. 52 | * In Addition, it makes use of the QTRemoteObjects module that can expose QT 53 | * Classes to remote hosts. This allows a QT Application 54 | * to connect to a host and interact with the Z-Wave Network remotely. 55 | *

56 | * We recomend anyone wishing to develop a application using this library has a good 57 | * grasp of the Z-Wave Specificaitons and Technology and in particular has a good 58 | * understanding of Nodes, MultiChannel Devices, Association Groups and CommandClasses 59 | * We also recomend you consult the OpenZWave Library API (and associated documentation) 60 | * as many of the public methods this library exposes are simple wrappers around the OZW 61 | * Library 62 | *

63 | * Included in the library are two sample applications - 64 | * SimpleClient is, as the name implies a simple QT GUI Application to expose Nodes, 65 | * Values, and Association Groups. It also demostrates how to use the QTRemoteObjects 66 | * feature that allows QT-OpenZWave to connect to remote hosts that have a Z-Wave Dongle or 67 | * interface. 68 | * qt-ozwdaemon is console only application that allows remote clients (such as the simpleclient 69 | * or ozw-admin application) to connect remotely. 70 | *

71 | * @image html zwalliance_250x100.jpg 72 | *

OpenZWave is a affiliate member of the Z-Wave Alliance (http://zwavealliance.org/)
73 | */ 74 | 75 | 76 | 77 | /** \brief 78 | * Initilizes and Sets up QT-OpenZWave for use. 79 | * 80 | * \nosubgrouping 81 | * The QTOpenZWave class provides the necessary initilization steps to 82 | * setup QT-OpenZWave Ready for use. You should create a instance of this 83 | * class early in your application. 84 | * 85 | * The Class ensures that the enviroment is ready to start a Copy of OpenZWave 86 | * Your Application will then call GetManager() to get a copy of the QTOZW_Manager 87 | * class which is the main interface to QT-OpenZWave 88 | */ 89 | 90 | class QTOZWManager; 91 | 92 | class QTOPENZWAVESHARED_EXPORT QTOpenZwave : public QObject 93 | { 94 | Q_OBJECT 95 | public: 96 | /** \brief Main Constructor 97 | * \param parent The Parent Class of this instance 98 | * \param DBPath if this will be running a local instance (the machine has the attached ZWave Dongle) 99 | * of OZW, then the OpenZWave Device Database (config directory in the OpenZWave Source) must be present. 100 | * this is the path to that directory 101 | * \param UserPath Path where OpenZWave will store/retrive user Specific configuration, such as Options.xml 102 | * or store the network related files 103 | */ 104 | QTOpenZwave(QObject *parent = nullptr, QString ConfigPath = "./config/", QString UserPath = "./config/"); 105 | 106 | /** \brief Obtain a copy of the QTOZW_Manager Instance 107 | * 108 | * The QTOZW_Manager class is the main interface for your application. You must only obtain 109 | * the QTOZW_Manager instance via this call, and never create yourself, to ensure that the enviroment 110 | * is setup and ready for OpenZWave to start. 111 | * \returns QTOZWManager a copy of the instance you can use to interact with QT-OpenZWave 112 | */ 113 | QTOZWManager *GetManager(); 114 | 115 | QString getVersion(); 116 | private: 117 | QTOZWManager *m_manager; 118 | QString m_ozwconfigpath; 119 | QString m_ozwuserpath; 120 | }; 121 | 122 | #endif // QTOPENZWAVE_H 123 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwassociationmodel.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwassociationmodel.h 4 | // 5 | // Association Groups Exposed as a ABstractTableModel 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWASSOCIATIONS_H 29 | #define QTOZWASSOCIATIONS_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include 35 | 36 | 37 | class QTOPENZWAVESHARED_EXPORT QTOZW_Associations : public QAbstractTableModel { 38 | Q_OBJECT 39 | public: 40 | enum associationColumns { 41 | NodeID, 42 | GroupID, 43 | GroupName, 44 | GroupHelp, 45 | MaxAssocations, 46 | Members, 47 | Flags, 48 | Count 49 | }; 50 | Q_ENUM(associationColumns) 51 | 52 | enum associationFlags { 53 | isMultiInstance, 54 | FlagCount 55 | }; 56 | 57 | Q_ENUM(associationFlags) 58 | 59 | friend class QTOZWManager_Internal; 60 | 61 | QTOZW_Associations(QObject *parent=nullptr); 62 | int rowCount(const QModelIndex &parent) const override; 63 | int columnCount(const QModelIndex &parent) const override; 64 | QVariant data(const QModelIndex &index, int role) const override; 65 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 66 | #if 0 67 | Qt::ItemFlags flags(const QModelIndex &index) const override; 68 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; 69 | #endif 70 | 71 | protected: 72 | QVariant getassocationData(quint8 _node, quint8 _groupIDX, QTOZW_Associations::associationColumns _column); 73 | int32_t getassocationRow(quint8 _node, quint8 _groupIDX); 74 | 75 | QMap > m_associationData; 76 | }; 77 | #endif // QTOZWASSOCIATIONS_H 78 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwlog.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwlog.h 4 | // 5 | // OpenZWave Log Exposed as a AbstractTableModel 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWLOGGING_H 29 | #define QTOZWLOGGING_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "qt-openzwave/qtozwreplica.h" 36 | #include "qt-openzwave/rep_qtozwlog_replica.h" 37 | 38 | class QTOZWLog_Internal; 39 | class QTOZWLogModel; 40 | 41 | class QTOPENZWAVESHARED_EXPORT QTOZWLog : public QTOZWReplicaBase { 42 | friend class QTOZWLogModel; 43 | Q_OBJECT 44 | public: 45 | struct QTOZW_LogEntry { 46 | QString s_msg; 47 | QDateTime s_time; 48 | quint8 s_node; 49 | LogLevels::Level s_level; 50 | }; 51 | 52 | QTOZWLog(ConnectionType::Type connectionType, QObject *parent = nullptr); 53 | ~QTOZWLog(); 54 | 55 | Q_PROPERTY(quint32 logBufSize READ getLogBufSize WRITE setLogBufSize NOTIFY logBufSizeChanged) 56 | 57 | bool initilizeBase() override; 58 | bool initilizeSource(QRemoteObjectHost *m_sourceNode) override; 59 | bool initilizeReplica(QRemoteObjectNode *m_replicaNode) override; 60 | const QVector &getLogEntries(); 61 | 62 | public: 63 | quint32 getLogCount() const; 64 | bool syncroniseLogs(); 65 | quint32 getLogBufSize() const; 66 | 67 | Q_SIGNALS: 68 | void newLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 69 | void logLinesPopped(quint32 number); 70 | void syncronizedLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 71 | void logCleared(); 72 | void logBufSizeChanged(quint32 logBufSize); 73 | void syncStatus(quint32 size, bool finished); 74 | 75 | public Q_SLOTS: 76 | void setLogBufSize(quint32 size); 77 | 78 | protected: 79 | QVector m_logData; 80 | quint32 m_maxLogLength; 81 | 82 | private Q_SLOTS: 83 | void insertLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 84 | void syncLogMessages(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 85 | private: 86 | void connectSignals() override; 87 | 88 | QTOZWLog_Internal *d_ptr_internal; 89 | QTOZWLogReplica *d_ptr_replica; 90 | }; 91 | 92 | class QTOPENZWAVESHARED_EXPORT QTOZWLogModel : public QAbstractTableModel { 93 | Q_OBJECT 94 | public: 95 | enum LogColumns { 96 | TimeStamp, 97 | Node, 98 | Level, 99 | Message, 100 | Count 101 | }; 102 | Q_ENUM(LogColumns) 103 | 104 | QTOZWLogModel (QTOZWLog *qtozwlog, QObject *parent = nullptr); 105 | int rowCount(const QModelIndex &parent) const override; 106 | int columnCount(const QModelIndex &parent) const override; 107 | QVariant data(const QModelIndex &index, int role) const override; 108 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 109 | Qt::ItemFlags flags(const QModelIndex &index) const override; 110 | public Q_SLOTS: 111 | bool insertLogMessage(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 112 | bool syncLogMessage(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 113 | void resetModel(); 114 | void logsPoppped(quint32 size); 115 | private: 116 | const QTOZWLog::QTOZW_LogEntry getLogData(const int) const; 117 | QTOZWLog *m_qtozwlog; 118 | }; 119 | 120 | #endif // QTOZWLOGGING_H 121 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwlog.rep: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwlog.rep 4 | // 5 | // QT RemoteObjects Replica File - To Generate our Source and Replica Headers 6 | // so we can transport the QTOZWLog class over the network 7 | // 8 | // Copyright (c) 2020 Justin Hammond 9 | // 10 | // SOFTWARE NOTICE AND LICENSE 11 | // 12 | // This file is part of QT-OpenZWave. 13 | // 14 | // OpenZWave is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published 16 | // by the Free Software Foundation, either version 3 of the License, 17 | // or (at your option) any later version. 18 | // 19 | // OpenZWave is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with OpenZWave. If not, see . 26 | // 27 | //----------------------------------------------------------------------------- 28 | 29 | #include 30 | #include 31 | #include "qt-openzwave/qtozw_pods.h" 32 | 33 | class QTOZWLog { 34 | SIGNAL(newLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg)) 35 | SIGNAL(syncronizedLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg)) 36 | SIGNAL(syncStatus(quint32 size, bool finished)) 37 | 38 | SLOT(quint32 getLogCount()) 39 | SLOT(bool syncroniseLogs()) 40 | } -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwnodemodel.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwnodemodel.h 4 | // 5 | // Nodes Exposed as a QAbstractTableModel 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWNODEMODEL_H 29 | #define QTOZWNODEMODEL_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include 35 | 36 | class QTOPENZWAVESHARED_EXPORT QTOZW_Nodes : public QAbstractTableModel { 37 | Q_OBJECT 38 | public: 39 | enum NodeColumns { 40 | NodeID, 41 | NodeName, 42 | NodeLocation, 43 | NodeManufacturerName, 44 | NodeProductName, 45 | NodeBasicString, 46 | NodeBasic, 47 | NodeGenericString, 48 | NodeGeneric, 49 | NodeSpecificString, 50 | NodeSpecific, 51 | NodeDeviceTypeString, 52 | NodeDeviceType, 53 | NodeRole, 54 | NodeRoleString, 55 | NodePlusType, 56 | NodePlusTypeString, 57 | NodeQueryStage, 58 | NodeManufacturerID, 59 | NodeProductType, 60 | NodeProductID, 61 | NodeBaudRate, 62 | NodeVersion, 63 | NodeGroups, 64 | NodeFlags, 65 | NodeCount 66 | }; 67 | Q_ENUM(NodeColumns) 68 | 69 | enum nodeFlags { 70 | isListening, 71 | isFlirs, 72 | isBeaming, 73 | isRouting, 74 | isSecurityv1, 75 | isZWavePlus, 76 | isNIFRecieved, 77 | isAwake, 78 | isFailed, 79 | flagCount 80 | }; 81 | 82 | Q_ENUM(nodeFlags) 83 | 84 | QTOZW_Nodes(QObject *parent=nullptr); 85 | int rowCount(const QModelIndex &parent) const override; 86 | int columnCount(const QModelIndex &parent) const override; 87 | QVariant data(const QModelIndex &index, int role) const override; 88 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 89 | Qt::ItemFlags flags(const QModelIndex &index) const override; 90 | bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override; 91 | 92 | protected: 93 | QVariant getNodeData(quint8, NodeColumns); 94 | int32_t getNodeRow(quint8 _node); 95 | 96 | QVector< QMap > m_nodeData; 97 | }; 98 | #endif // QTOZWNODEMODEL_H 99 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwoptions.rep: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwoptions.rep 4 | // 5 | // QT RemoteObjects Replica File - To Generate our Source and Replica Headers 6 | // so we can transport the QTOZWOptions class over the network 7 | // 8 | // Copyright (c) 2019 Justin Hammond 9 | // 10 | // SOFTWARE NOTICE AND LICENSE 11 | // 12 | // This file is part of QT-OpenZWave. 13 | // 14 | // OpenZWave is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published 16 | // by the Free Software Foundation, either version 3 of the License, 17 | // or (at your option) any later version. 18 | // 19 | // OpenZWave is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with OpenZWave. If not, see . 26 | // 27 | //----------------------------------------------------------------------------- 28 | 29 | #include 30 | #include 31 | #include "qt-openzwave/qtozw_pods.h" 32 | 33 | class QTOZWOptions { 34 | ENUM QTOZWOptionsErrorCodes { 35 | InvalidOption, 36 | NoOptionClass, 37 | NoError 38 | }; 39 | 40 | PROP(QString ConfigPath READWRITE) 41 | PROP(QString UserPath READWRITE) 42 | PROP(bool Logging READWRITE) 43 | PROP(QString LogFileName READWRITE) 44 | PROP(bool AppendLogFile READWRITE) 45 | PROP(bool ConsoleOutput READWRITE) 46 | PROP(OptionList SaveLogLevel READWRITE) 47 | PROP(OptionList QueueLogLevel READWRITE) 48 | PROP(OptionList DumpTriggerLevel READWRITE) 49 | PROP(bool Associate READWRITE) 50 | PROP(QString Exclude READWRITE) 51 | PROP(QString Include READWRITE) 52 | PROP(bool NotifyTransactions READWRITE) 53 | PROP(QString Interface READWRITE) 54 | PROP(bool SaveConfiguration READWRITE) 55 | PROP(qint32 DriverMaxAttempts READWRITE) 56 | PROP(qint32 PollInterval READWRITE) 57 | PROP(bool IntervalBetweenPolls READWRITE) 58 | PROP(bool SuppressValueRefresh READWRITE) 59 | PROP(bool PerformReturnRoutes READWRITE) 60 | PROP(QString NetworkKey READWRITE) 61 | PROP(bool RefreshAllUserCodes READWRITE) 62 | PROP(qint32 RetryTimeout READWRITE) 63 | PROP(bool EnableSIS READWRITE) 64 | PROP(bool AssumeAwake READWRITE) 65 | PROP(bool NotifyOnDriverUnload READWRITE) 66 | PROP(OptionList SecurityStrategy READWRITE) 67 | PROP(QString CustomSecuredCC READWRITE) 68 | PROP(bool EnforceSecureReception READWRITE) 69 | PROP(bool AutoUpdateConfigFile READWRITE) 70 | PROP(OptionList ReloadAfterUpdate READWRITE) 71 | PROP(QString Language READWRITE) 72 | PROP(bool IncludeInstanceLabels READWRITE) 73 | 74 | SIGNAL(error(QTOZWOptionsErrorCodes errorcode)) 75 | 76 | SLOT(bool AddOptionBool(QString option, bool value)) 77 | SLOT(bool AddOptionInt(QString option, qint32 value)) 78 | SLOT(bool AddOptionString(QString option, QString value)) 79 | SLOT(bool GetOptionAsBool(QString option)) 80 | SLOT(qint32 GetOptionAsInt(QString option)) 81 | SLOT(QString GetOptionAsString(QString option)) 82 | SLOT(bool isLocked()); 83 | } 84 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwproxymodels.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwproxymodels.h 4 | // 5 | // Various useful Filtering Proxy Models for QT-OpenZWave 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWPROXYMODELS_H 29 | #define QTOZWPROXYMODELS_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "qtozwnodemodel.h" 38 | #include "qtozwvalueidmodel.h" 39 | 40 | class QTOPENZWAVESHARED_EXPORT QTOZW_proxyNodeModel : public QSortFilterProxyModel 41 | { 42 | Q_OBJECT 43 | public: 44 | explicit QTOZW_proxyNodeModel(QObject *parent = nullptr); 45 | 46 | signals: 47 | 48 | public slots: 49 | }; 50 | 51 | 52 | class QTOPENZWAVESHARED_EXPORT QTOZW_proxyValueModel : public QSortFilterProxyModel 53 | { 54 | Q_OBJECT 55 | public: 56 | explicit QTOZW_proxyValueModel(QObject *parent = nullptr); 57 | void setSelectionModel(QItemSelectionModel *); 58 | void setFilterGenre(QTOZW_ValueIds::ValueIdGenres genre); 59 | QTOZW_ValueIds::ValueIdGenres getFilterGenre(); 60 | QItemSelectionModel *getSelectionModel(); 61 | quint8 getCurrentFilteredNode(); 62 | public slots: 63 | void currentSelectedRowChanged(const QModelIndex ¤t, const QModelIndex &previous); 64 | 65 | protected: 66 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; 67 | 68 | private: 69 | QItemSelectionModel *m_selectionmodel; 70 | QTOZW_ValueIds::ValueIdGenres m_genreFilter; 71 | uint8_t m_nodeFilter; 72 | }; 73 | 74 | 75 | class QTOPENZWAVESHARED_EXPORT QTOZW_proxyAssociationModel : public QSortFilterProxyModel 76 | { 77 | Q_OBJECT 78 | public: 79 | explicit QTOZW_proxyAssociationModel(QObject *parent = nullptr); 80 | void setSelectionModel(QItemSelectionModel *); 81 | 82 | public slots: 83 | void currentSelectedRowChanged(const QModelIndex ¤t, const QModelIndex &previous); 84 | 85 | protected: 86 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; 87 | 88 | private: 89 | QItemSelectionModel *m_selectionmodel; 90 | uint8_t m_nodeFilter; 91 | }; 92 | 93 | 94 | 95 | 96 | #endif // QTOZWPROXYMODELS_H 97 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwreplica.h: -------------------------------------------------------------------------------- 1 | #ifndef QTOZWREPLICA_H 2 | #define QTOZWREPLICA_H 3 | 4 | #include 5 | #include "qt-openzwave/qtozw_pods.h" 6 | 7 | class QTOPENZWAVESHARED_EXPORT QTOZWReplicaBase : public QObject { 8 | Q_OBJECT 9 | public: 10 | QTOZWReplicaBase(ConnectionType::Type connectionType, QObject *parent); 11 | ~QTOZWReplicaBase(); 12 | 13 | Q_PROPERTY(ConnectionType::Type connectionType MEMBER m_connectionType READ getConnectionType WRITE setConnectionType NOTIFY connectionTypeChanged); 14 | Q_PROPERTY(bool ready MEMBER m_ready READ isReady WRITE setReady NOTIFY readyChanged); 15 | 16 | ConnectionType::Type getConnectionType() const; 17 | bool isReady() const; 18 | 19 | virtual bool initilizeBase() = 0; 20 | virtual bool initilizeSource(QRemoteObjectHost *m_sourceNode) = 0; 21 | virtual bool initilizeReplica(QRemoteObjectNode *m_replicaNode) = 0; 22 | 23 | 24 | public Q_SLOT: 25 | void setReady(bool ready); 26 | void setConnectionType(ConnectionType::Type type); 27 | 28 | signals: 29 | void readyChanged(const bool &ready); 30 | void connectionTypeChanged(const ConnectionType::Type &type); 31 | void onStateChange(QRemoteObjectReplica::State); 32 | 33 | private: 34 | virtual void connectSignals() = 0; 35 | 36 | ConnectionType::Type m_connectionType; 37 | bool m_ready; 38 | }; 39 | 40 | #ifndef Q_OS_WASM 41 | 42 | #define CONNECT_DPTR(x) if (this->getConnectionType() == ConnectionType::Type::Local) { \ 43 | QObject::connect(this->d_ptr_internal, &REP_INTERNAL_CLASS::x, this, &REP_PUBLIC_CLASS::x);\ 44 | } else { \ 45 | QObject::connect(this->d_ptr_replica, &REP_REPLICA_CLASS::x, this, &REP_PUBLIC_CLASS::x); \ 46 | }; 47 | 48 | #define CONNECT_DPTR1(x, y) if (this->getConnectionType() == ConnectionType::Type::Local) { \ 49 | QObject::connect(this->d_ptr_internal, &REP_INTERNAL_CLASS::x, this, &REP_PUBLIC_CLASS::y);\ 50 | } else { \ 51 | QObject::connect(this->d_ptr_replica, &REP_REPLICA_CLASS::x, this, &REP_PUBLIC_CLASS::y); \ 52 | }; 53 | 54 | #define CALL_DPTR(x) if (!this->isReady()) return; \ 55 | if (this->getConnectionType() == ConnectionType::Type::Local) { \ 56 | this->d_ptr_internal->x; \ 57 | } else { \ 58 | this->d_ptr_replica->x; \ 59 | } 60 | 61 | #define CALL_DPTR_RTN(x, y, ret) if (!this->isReady()) return ret; \ 62 | if (this->getConnectionType() == ConnectionType::Type::Local) \ 63 | return this->d_ptr_internal->x; \ 64 | else { \ 65 | QRemoteObjectPendingReply res = this->d_ptr_replica->x; \ 66 | res.waitForFinished(3000); \ 67 | return res.returnValue(); \ 68 | } 69 | 70 | #define CALL_DPTR_PROP(x, ret) if (!this->isReady()) return ret; \ 71 | if (this->getConnectionType() == ConnectionType::Type::Local) { \ 72 | return this->d_ptr_internal->x; \ 73 | } else { \ 74 | return this->d_ptr_replica->x; \ 75 | } 76 | 77 | #define CALL_DPTR_PROP_SET(x) if (!this->isReady()) return; \ 78 | if (this->getConnectionType() == ConnectionType::Type::Local) { \ 79 | this->d_ptr_internal->setProperty(#x, x); \ 80 | } else { \ 81 | this->d_ptr_replica->setProperty(#x, x); \ 82 | } 83 | 84 | #define CALL_DPTR_PROP_SET_TYPE(x, y) if (!this->isReady()) return; \ 85 | if (this->getConnectionType() == ConnectionType::Type::Local) { \ 86 | this->d_ptr_internal->setProperty(#x, QVariant::fromValue(x)); \ 87 | } else { \ 88 | this->d_ptr_replica->setProperty(#x, QVariant::fromValue(x)); \ 89 | } 90 | 91 | #define DISCONNECT_DPTR(x) if (this->getConnectionType() == ConnectionType::Type::Local) { \ 92 | if (this->d_ptr_replica) \ 93 | QObject::disconnect(this->d_ptr_replica, SIGNAL(x));\ 94 | } else { \ 95 | if (this->d_ptr_internal) \ 96 | QObject::disconnect(this->d_ptr_internal, SIGNAL(x)); \ 97 | }; 98 | 99 | #else 100 | 101 | #define CONNECT_DPTR(x) QObject::connect(this->d_ptr_replica, &REP_REPLICA_CLASS::x, this, &REP_PUBLIC_CLASS::x); 102 | 103 | #define CONNECT_DPTR1(x, y) QObject::connect(this->d_ptr_replica, &REP_REPLICA_CLASS::x, this, &REP_PUBLIC_CLASS::y); 104 | 105 | #define CALL_DPTR(x) this->d_ptr_replica->x 106 | 107 | #define CALL_DPTR_RTN(x, y) QRemoteObjectPendingReply res = this->d_ptr_replica->x; \ 108 | res.waitForFinished(); \ 109 | return res.returnValue(); \ 110 | 111 | #endif 112 | 113 | #endif -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/qtozwvalueidmodel.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwvalueidmodel.h 4 | // 5 | // Value's exposed as a QAstractTableModel 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWVALUEIDMODEL_H 29 | #define QTOZWVALUEIDMODEL_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | struct QTOZW_ValueIDList { 38 | QList< quint32 > values; 39 | QStringList labels; 40 | QString selectedItem; 41 | quint32 selectedItemId; 42 | }; 43 | QDataStream & operator<<( QDataStream & dataStream, const QTOZW_ValueIDList & list ); 44 | QDataStream & operator>>(QDataStream & dataStream, QTOZW_ValueIDList & list); 45 | 46 | Q_DECLARE_METATYPE(QTOZW_ValueIDList); 47 | 48 | struct QTOZW_ValueIDBitSet { 49 | QBitArray values; 50 | QBitArray mask; 51 | QMap label; 52 | QMap help; 53 | }; 54 | QDataStream & operator<<( QDataStream & dataStream, const QTOZW_ValueIDBitSet & list ); 55 | QDataStream & operator>>(QDataStream & dataStream, QTOZW_ValueIDBitSet & list); 56 | 57 | Q_DECLARE_METATYPE(QTOZW_ValueIDBitSet); 58 | 59 | 60 | class QTOPENZWAVESHARED_EXPORT QTOZW_ValueIds : public QAbstractTableModel { 61 | Q_OBJECT 62 | public: 63 | enum ValueIdColumns { 64 | Label, 65 | Value, 66 | Units, 67 | Min, 68 | Max, 69 | Type, 70 | Instance, 71 | CommandClass, 72 | Index, 73 | Node, 74 | Genre, 75 | Help, 76 | ValueIDKey, 77 | ValueFlags, 78 | ValueIdCount 79 | }; 80 | Q_ENUM(ValueIdColumns) 81 | enum ValueIdGenres { 82 | Basic, 83 | User, 84 | Config, 85 | System, 86 | GenreCount 87 | }; 88 | Q_ENUM(ValueIdGenres) 89 | enum ValueIdTypes { 90 | Bool, 91 | Byte, 92 | Decimal, 93 | Int, 94 | List, 95 | Schedule, 96 | Short, 97 | String, 98 | Button, 99 | Raw, 100 | BitSet, 101 | TypeCount 102 | }; 103 | Q_ENUM(ValueIdTypes) 104 | enum ValueIDFlags { 105 | ReadOnly, 106 | WriteOnly, 107 | ValueSet, 108 | ValuePolled, 109 | ChangeVerified, 110 | FlagCount 111 | }; 112 | Q_ENUM(ValueIDFlags) 113 | QTOZW_ValueIds(QObject *parent = nullptr); 114 | int rowCount(const QModelIndex &parent) const override; 115 | int columnCount(const QModelIndex &parent) const override; 116 | QVariant data(const QModelIndex &index, int role) const override; 117 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 118 | Qt::ItemFlags flags(const QModelIndex &index) const override; 119 | bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override; 120 | protected: 121 | QVariant getValueData(quint64, ValueIdColumns); 122 | int32_t getValueRow(quint64 _node); 123 | 124 | QVector< QMap > m_valueData; 125 | }; 126 | 127 | #endif // QTOZWVALUEIDMODEL_H 128 | -------------------------------------------------------------------------------- /qt-openzwave/include/qt-openzwave/websocketiodevice.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2019 Ford Motor Company 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the QtRemoteObjects module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** BSD License Usage 18 | ** Alternatively, you may use this file under the terms of the BSD license 19 | ** as follows: 20 | ** 21 | ** "Redistribution and use in source and binary forms, with or without 22 | ** modification, are permitted provided that the following conditions are 23 | ** met: 24 | ** * Redistributions of source code must retain the above copyright 25 | ** notice, this list of conditions and the following disclaimer. 26 | ** * Redistributions in binary form must reproduce the above copyright 27 | ** notice, this list of conditions and the following disclaimer in 28 | ** the documentation and/or other materials provided with the 29 | ** distribution. 30 | ** * Neither the name of The Qt Company Ltd nor the names of its 31 | ** contributors may be used to endorse or promote products derived 32 | ** from this software without specific prior written permission. 33 | ** 34 | ** 35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46 | ** 47 | ** $QT_END_LICENSE$ 48 | ** 49 | ****************************************************************************/ 50 | 51 | #ifndef WEBSOCKETIODEVICE_H 52 | #define WEBSOCKETIODEVICE_H 53 | 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #include "qt-openzwave/qtopenzwave.h" 60 | 61 | class QWebSocket; 62 | 63 | class WebSocketIoDevice : public QIODevice 64 | { 65 | Q_OBJECT 66 | public: 67 | enum connectionState { 68 | Stage_None, 69 | Stage_Protocol, 70 | Stage_Authenticate, 71 | Stage_Authenticated 72 | }; 73 | Q_ENUM(connectionState); 74 | 75 | WebSocketIoDevice(QWebSocket *webSocket, bool client, QString auth, QObject *parent = nullptr); 76 | 77 | signals: 78 | void disconnected(); 79 | void authenticated(); 80 | void authError(QString); 81 | 82 | // QIODevice interface 83 | public: 84 | qint64 bytesAvailable() const override; 85 | bool isSequential() const override; 86 | void close() override; 87 | 88 | protected: 89 | qint64 readData(char *data, qint64 maxlen) override; 90 | qint64 writeData(const char *data, qint64 len) override; 91 | void processTextMessage(const QString &message); 92 | 93 | private: 94 | QPointer m_socket; 95 | QByteArray m_buffer; 96 | bool m_client; 97 | connectionState m_state; 98 | QString m_auth; 99 | int m_version; 100 | int m_authattempts; 101 | }; 102 | 103 | #endif // WEBSOCKETIODEVICE_H 104 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozw_logging.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozw_logging.h 4 | // 5 | // Internal QT Logging Functions 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | 29 | #ifndef QTOZW_LOGGING_H 30 | #define QTOZW_LOGGING_H 31 | #include "qt-openzwave/qtopenzwave.h" 32 | #include 33 | 34 | Q_DECLARE_LOGGING_CATEGORY(manager); 35 | Q_DECLARE_LOGGING_CATEGORY(valueModel); 36 | Q_DECLARE_LOGGING_CATEGORY(nodeModel); 37 | Q_DECLARE_LOGGING_CATEGORY(logModel); 38 | Q_DECLARE_LOGGING_CATEGORY(associationModel); 39 | Q_DECLARE_LOGGING_CATEGORY(notifications); 40 | Q_DECLARE_LOGGING_CATEGORY(libopenzwave); 41 | Q_DECLARE_LOGGING_CATEGORY(qtrowebsocket); 42 | Q_DECLARE_LOGGING_CATEGORY(options); 43 | 44 | #endif // QTOZW_LOGGING_H 45 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwassociationmodel_p.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwassociationmodel_p.h 4 | // 5 | // Association Groups Model - Used Internally to Manage the Model 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWASSOCIATIONMODEL_P_H 29 | #define QTOZWASSOCIATIONMODEL_P_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | #include 33 | #include "qt-openzwave/qtozwassociationmodel.h" 34 | 35 | class QTOZW_Associations_internal : public QTOZW_Associations { 36 | Q_OBJECT 37 | public: 38 | QTOZW_Associations_internal(QObject *parent=nullptr); 39 | public Q_SLOTS: 40 | void addGroup(quint8 _nodeID, quint8 _groupIDX); 41 | void setGroupData(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationColumns column, QVariant data); 42 | void setGroupFlags(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationFlags _flags, bool _value); 43 | void delNode(quint8 _nodeID); 44 | void addAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance); 45 | void delAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance); 46 | bool findAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance); 47 | void resetModel(); 48 | }; 49 | 50 | 51 | #endif // QTOZWASSOCIATIONMODEL_P_H 52 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwlog_p.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwlog_p.h 4 | // 5 | // OpenZWave Log - Internal Class to manage the Model 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZW_LOG_P_H 29 | #define QTOZW_LOG_P_H 30 | #include "qt-openzwave/qtopenzwave.h" 31 | #include "qt-openzwave/qtozwlog.h" 32 | #include "qt-openzwave/rep_qtozwlog_source.h" 33 | #include 34 | 35 | 36 | class QTOZWLog_Internal : public QTOZWLogSimpleSource, public OpenZWave::i_LogImpl 37 | { 38 | friend class QTOZWLog; 39 | Q_OBJECT 40 | public: 41 | QTOZWLog_Internal(QObject *parent = nullptr); 42 | ~QTOZWLog_Internal(); 43 | 44 | virtual void Write(OpenZWave::LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args) override; 45 | virtual void QueueDump() override; 46 | virtual void QueueClear() override; 47 | virtual void SetLoggingState(OpenZWave::LogLevel _saveLevel, OpenZWave::LogLevel _queueLevel, OpenZWave::LogLevel _dumpTrigger) override; 48 | virtual void SetLogFileName(const std::string &_filename) override; 49 | virtual quint32 getLogCount() override; 50 | virtual bool syncroniseLogs() override; 51 | quint32 getLogBufSize() const; 52 | void sendSyncLogsBatch(); 53 | Q_SIGNALS: 54 | void sendLogLine(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg); 55 | void logLinesPopped(quint32 number); 56 | void logBufSizeChanged(quint32 logBufSize); 57 | 58 | public Q_SLOTS: 59 | void setLogBufSize(quint32 size); 60 | 61 | 62 | protected: 63 | QVector m_logData; 64 | QVector m_shadowLogData; 65 | 66 | quint32 m_maxLogLength; 67 | QTimer m_syncLogTrigger; 68 | }; 69 | 70 | #endif // QTOZW_LOG_P_H 71 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwnodemodel_p.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwnodemodel_p.h 4 | // 5 | // Node Model - Internal Class to Manage the Model 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWNODEMODEL_P_H 29 | #define QTOZWNODEMODEL_P_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include "qt-openzwave/qtozwnodemodel.h" 35 | 36 | class QTOZW_Nodes_internal : public QTOZW_Nodes { 37 | Q_OBJECT 38 | public: 39 | QTOZW_Nodes_internal(QObject *parent=nullptr); 40 | public Q_SLOTS: 41 | void addNode(quint8 _nodeID); 42 | void setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data, bool transaction); 43 | void setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value, bool transaction); 44 | void delNode(quint8 _nodeID); 45 | void resetModel(); 46 | void finishTransaction(quint8 _nodeID); 47 | 48 | }; 49 | 50 | 51 | #endif // QTOZWNODEMODEL_P_H 52 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwnotification.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwnotification.h 4 | // 5 | // The Notification Callback to Interface OZW and the QT Wrapper 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWNOTIFICATION_H 29 | #define QTOZWNOTIFICATION_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include "Notification.h" 35 | #include "Driver.h" 36 | 37 | class OZWNotification : public QObject { 38 | Q_OBJECT 39 | public: 40 | static OZWNotification *Get(); 41 | //----------------------------------------------------------------------------- 42 | // All our Signals that we emit - one for each type of Notification 43 | //----------------------------------------------------------------------------- 44 | signals: 45 | void valueAdded(quint64 vidKey); 46 | void valueRemoved(quint64 vidKey); 47 | void valueChanged(quint64 vidKey); 48 | void valueRefreshed(quint64 vidKey); 49 | void valuePollingEnabled(quint64 vidKey); 50 | void valuePollingDisabled(quint64 vidKey); 51 | void nodeGroupChanged(quint8 node, quint8 group); 52 | void nodeNew(quint8 node); 53 | void nodeAdded(quint8 node); 54 | void nodeRemoved(quint8 node); 55 | void nodeReset(quint8 node); 56 | void nodeNaming(quint8 node); 57 | void nodeEvent(quint8 node, quint8 event); 58 | void nodeProtocolInfo(quint8 node); 59 | void nodeEssentialNodeQueriesComplete(quint8 node); 60 | void nodeQueriesComplete(quint8 node); 61 | void driverReady(quint32 homeID); 62 | void driverFailed(quint32 homeID); 63 | void driverReset(quint32 homeID); 64 | void driverRemoved(quint32 homeID); 65 | void driverAllNodesQueriedSomeDead(); 66 | void driverAwakeNodesQueried(); 67 | void driverAllNodesQueried(); 68 | void controllerCommand(quint8 node, quint32 cmd, quint32 state, quint32 error); 69 | void ozwNotification(quint8 node, quint32 event); 70 | void ozwUserAlert(quint8 node, quint32 event, quint8 retry); 71 | void manufacturerSpecificDBReady(); 72 | //----------------------------------------------------------------------------- 73 | // 74 | // Callback that is triggered when a value, group or node changes 75 | //----------------------------------------------------------------------------- 76 | public: 77 | static void processNotification(OpenZWave::Notification const* _notification, void* _context); 78 | private: 79 | static OZWNotification *s_Instance; 80 | }; 81 | 82 | 83 | #endif // QTOZWNOTIFICATION_H 84 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwoptions_p.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwoptions_p.h 4 | // 5 | // OpenZWave Options Wrapper - Internal Class to interface with it 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWOPTIONS_P_H 29 | #define QTOZWOPTIONS_P_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include 35 | #include 36 | #include "qtozw_logging.h" 37 | #include "rep_qtozwoptions_source.h" 38 | #include "rep_qtozwoptions_replica.h" 39 | 40 | 41 | class QTOZWOptions_Internal : public QTOZWOptionsSimpleSource 42 | { 43 | Q_OBJECT 44 | public: 45 | QTOZWOptions_Internal(QString localConfigPath, QString localUserPath, QObject *parent = nullptr); 46 | 47 | public Q_SLOTS: 48 | bool AddOptionBool(QString option, bool value); 49 | bool AddOptionInt(QString option, qint32 value); 50 | bool AddOptionString(QString option, QString value); 51 | bool GetOptionAsBool(QString option); 52 | qint32 GetOptionAsInt(QString option); 53 | QString GetOptionAsString(QString option); 54 | bool isLocked(); 55 | 56 | private Q_SLOTS: 57 | void pvt_ConfigPathChanged(QString value); 58 | void pvt_UserPathChanged(QString value); 59 | void pvt_LoggingChanged(bool value); 60 | void pvt_LogFileNameChanged(QString value); 61 | void pvt_AppendLogFileChanged(bool value); 62 | void pvt_ConsoleOutputChanged(bool value); 63 | void pvt_SaveLogLevelChanged(OptionList value); 64 | void pvt_QueueLogLevelChanged(OptionList value); 65 | void pvt_DumpTriggerLevelChanged(OptionList value); 66 | void pvt_AssociateChanged(bool value); 67 | void pvt_ExcludeChanged(QString value); 68 | void pvt_IncludeChanged(QString value); 69 | void pvt_NotifyTransactionChanged(bool value); 70 | void pvt_InterfaceChanged(QString value); 71 | void pvt_SaveConfigurationChanged(bool value); 72 | void pvt_DriverMaxAttemptsChanged(qint32 value); 73 | void pvt_PollIntervalChanged(qint32 value); 74 | void pvt_IntervalBetweenPollsChanged(bool value); 75 | void pvt_SuppressValueRefreshChanged(bool value); 76 | void pvt_PerformReturnRoutesChanged(bool value); 77 | void pvt_NetworkKeyChanged(QString value); 78 | void pvt_RefreshAllUserCodesChanged(bool value); 79 | void pvt_RetryTimeoutChanged(qint32 value); 80 | void pvt_EnableSISChanged(bool value); 81 | void pvt_AssumeAwakeChanged(bool value); 82 | void pvt_NotifyOnDriverUnloadChanged(bool value); 83 | void pvt_SecurityStrategyChanged(OptionList value); 84 | void pvt_CustomSecuredCCChanged(QString value); 85 | void pvt_EnforceSecureReceptionChanged(bool value); 86 | void pvt_AutoUpdateConfigFileChanged(bool value); 87 | void pvt_ReloadAfterUpdateChanged(OptionList value); 88 | void pvt_LanguageChanged(QString value); 89 | void pvt_IncludeInstanceLabelsChanged(bool value); 90 | 91 | private: 92 | bool populateProperties(); 93 | bool m_updating; 94 | OpenZWave::Options *m_options; 95 | QString m_localConfigPath; 96 | QString m_localUserPath; 97 | }; 98 | 99 | #endif // QTOZWOPTIONS_P_H 100 | -------------------------------------------------------------------------------- /qt-openzwave/include/qtozwvalueidmodel_p.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwvalueidmodel_p.h 4 | // 5 | // ValueID Model - Internal Class to Manage the Model 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #ifndef QTOZWVALUEIDMODEL_P_H 29 | #define QTOZWVALUEIDMODEL_P_H 30 | 31 | #include "qt-openzwave/qtopenzwave.h" 32 | 33 | #include 34 | #include "qt-openzwave/qtozwvalueidmodel.h" 35 | 36 | class QTOZW_ValueIds_internal : public QTOZW_ValueIds { 37 | Q_OBJECT 38 | public: 39 | QTOZW_ValueIds_internal(QObject *parent=nullptr); 40 | public Q_SLOTS: 41 | void addValue(quint64 _vidKey); 42 | void setValueData(quint64 _vidKey, QTOZW_ValueIds::ValueIdColumns column, QVariant data, bool transaction); 43 | void setValueFlags(quint64 _vidKey, QTOZW_ValueIds::ValueIDFlags _flags, bool _value, bool transaction); 44 | void delValue(quint64 _vidKey); 45 | void delNodeValues(quint8 _node); 46 | void resetModel(); 47 | void finishTransaction(quint64 _vidKey); 48 | QVariant getValueData(quint64, ValueIdColumns); 49 | 50 | }; 51 | 52 | 53 | QString BitSettoQString(QBitArray ba); 54 | quint32 BitSettoInteger(QBitArray ba); 55 | 56 | 57 | #endif // QTOZWVALUEIDMODEL_P_H 58 | -------------------------------------------------------------------------------- /qt-openzwave/qt-openzwave.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-05-10T15:07:50 4 | # 5 | #------------------------------------------------- 6 | 7 | 8 | QT -= gui 9 | QT += remoteobjects 10 | QT += websockets 11 | 12 | TEMPLATE = lib 13 | 14 | VERSION = 1.2.0 15 | 16 | CONFIG += silent file_copies force_debug_info 17 | !versionAtLeast(QT_VERSION, 5.12.0):error("Use at least Qt version 5.12.0") 18 | 19 | include(../qt-openzwave.pri) 20 | 21 | 22 | qtConfig(static) { 23 | # this is a static build 24 | } 25 | 26 | DEFINES += QTOPENZWAVE_LIBRARY 27 | 28 | 29 | # The following define makes your compiler emit warnings if you use 30 | # any feature of Qt which has been marked as deprecated (the exact warnings 31 | # depend on your compiler). Please consult the documentation of the 32 | # deprecated API in order to know how to port your code away from it. 33 | DEFINES += QT_DEPRECATED_WARNINGS QT_MESSAGELOGCONTEXT LIB_VERSION=$$VERSION 34 | 35 | # You can also make your code fail to compile if you use deprecated APIs. 36 | # In order to do so, uncomment the following line. 37 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 38 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 39 | 40 | SOURCES += source/qtopenzwave.cpp \ 41 | source/qtozw_pods.cpp \ 42 | source/qtozwlog.cpp \ 43 | source/qtozwlog_p.cpp \ 44 | source/qtozwoptions.cpp \ 45 | source/qtozwoptions_p.cpp \ 46 | source/qtozwassociationmodel.cpp \ 47 | source/qtozwassociationmodel_p.cpp \ 48 | source/qtozwmanager.cpp \ 49 | source/qtozwmanager_p.cpp \ 50 | source/qtozwnodemodel_p.cpp \ 51 | source/qtozwnotification.cpp \ 52 | source/qtozwproxymodels.cpp \ 53 | source/qtozwnodemodel.cpp \ 54 | source/qtozwvalueidmodel.cpp \ 55 | source/qtozwvalueidmodel_p.cpp \ 56 | source/websocketiodevice.cpp \ 57 | source/qtozwreplica.cpp 58 | 59 | HEADERS += include/qtozwassociationmodel_p.h \ 60 | include/qtozw_logging.h \ 61 | include/qtozwlog_p.h \ 62 | include/qtozwmanager_p.h \ 63 | include/qtozwnodemodel_p.h \ 64 | include/qtozwnotification.h \ 65 | include/qtozwoptions_p.h \ 66 | include/qtozwvalueidmodel_p.h 67 | 68 | PUBLIC_HEADERS.files += include/qt-openzwave/qtopenzwave.h \ 69 | include/qt-openzwave/qtozwassociationmodel.h \ 70 | include/qt-openzwave/qtozwlog.h \ 71 | include/qt-openzwave/qtozwmanager.h \ 72 | include/qt-openzwave/qtozwnodemodel.h \ 73 | include/qt-openzwave/qtozwoptions.h \ 74 | include/qt-openzwave/qtozw_pods.h \ 75 | include/qt-openzwave/qtozwproxymodels.h \ 76 | include/qt-openzwave/qtozwvalueidmodel.h \ 77 | include/qt-openzwave/rep_qtozwmanager_replica.h \ 78 | include/qt-openzwave/rep_qtozwoptions_replica.h \ 79 | include/qt-openzwave/rep_qtozwmanager_source.h \ 80 | include/qt-openzwave/rep_qtozwoptions_source.h \ 81 | include/qt-openzwave/rep_qtozwlog_replica.h \ 82 | include/qt-openzwave/rep_qtozwlog_source.h \ 83 | include/qt-openzwave/websocketiodevice.h \ 84 | include/qt-openzwave/qtozwreplica.h 85 | 86 | PUBLIC_HEADERS.CONFIG += no_check_exist 87 | 88 | HEADERS += $$PUBLIC_HEADERS.files 89 | 90 | INCLUDEPATH += include/ 91 | 92 | REPC_SOURCE = include/qt-openzwave/qtozwmanager.rep include/qt-openzwave/qtozwoptions.rep include/qt-openzwave/qtozwlog.rep 93 | 94 | REPC_REPLICA = include/qt-openzwave/qtozwmanager.rep include/qt-openzwave/qtozwoptions.rep include/qt-openzwave/qtozwlog.rep 95 | 96 | copyrepheaders.path = include/qt-openzwave/ 97 | copyrepheaders.files = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h rep_qtozwoptions_replica.h rep_qtozwoptions_source.h rep_qtozwlog_source.h rep_qtozwlog_replica.h 98 | copyrepheaders.depends = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h rep_qtozwoptions_replica.h rep_qtozwoptions_source.h rep_qtozwlog_source.h rep_qtozwlog_replica.h 99 | 100 | COPIES += copyrepheaders 101 | unix { 102 | isEmpty(PREFIX) { 103 | PREFIX=/usr/local/ 104 | } 105 | isEmpty(LIBDIR) { 106 | target.path = $$[QT_INSTALL_LIBS] 107 | } else { 108 | target.path = $$PREFIX/$$LIBDIR 109 | } 110 | isEmpty(INCDIR) { 111 | PUBLIC_HEADERS.path = $$[QT_INSTALL_HEADERS]/$$TARGET/ 112 | } else { 113 | PUBLIC_HEADERS.path = $$PREFIX/$$INCDIR 114 | } 115 | message("Final Installation Directories:") 116 | message(" LibDir: $$target.path") 117 | message(" IncDir: $$PUBLIC_HEADERS.path") 118 | INSTALLS += target 119 | INSTALLS += PUBLIC_HEADERS 120 | QMAKE_CXXFLAGS += -g 121 | QMAKE_CFLAGS += -g 122 | QMAKE_LFLAGS += -rdynamic 123 | QMAKE_STRIP = echo 124 | 125 | #create pkg-config file for qt-openzwave 126 | CONFIG+= create_pc create_prl no_install_prl 127 | QMAKE_PKGCONFIG_NAME=qt-openzwave 128 | QMAKE_PKGCONFIG_DESCRIPTION="QT5 Bindings for OpenZWave" 129 | QMAKE_PKGCONFIG_PREFIX=$$INSTALLBASE 130 | QMAKE_PKGCONFIG_LIBDIR=$$target.path 131 | QMAKE_PKGCONFIG_INCDIR=$$PUBLIC_HEADERS.path 132 | QMAKE_PKGCONFIG_VERSION=$$VERSION 133 | QMAKE_PKGCONFIG_DESTDIR=pkgconfig 134 | QMAKE_PKGCONFIG_REQUIRES+=libopenzwave 135 | for(i, QT):QMAKE_PKGCONFIG_REQUIRES += $$replace(QT.$${i}.name, ^Qt, Qt$$section(QT.$${i}.VERSION, ., 0, 0)) 136 | } 137 | emscripten { 138 | SOURCES -= source/qtozwmanager_p.cpp source/qtozwoptions_p.cpp 139 | HEADERS -= include/qtozwmanager_p.h include/qtozwoptions_p.h 140 | } 141 | 142 | 143 | QMAKE_CFLAGS_RELEASE -= -O 144 | QMAKE_CFLAGS_RELEASE -= -O1 145 | QMAKE_CFLAGS_RELEASE -= -O2 146 | QMAKE_CXXFLAGS_RELEASE -= -O 147 | QMAKE_CXXFLAGS_RELEASE -= -O1 148 | QMAKE_CXXFLAGS_RELEASE -= -O2 149 | 150 | 151 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtopenzwave.cpp: -------------------------------------------------------------------------------- 1 | #include "qt-openzwave/qtopenzwave.h" 2 | #include "qt-openzwave/qtozwmanager.h" 3 | #include "qt-openzwave/qtozw_pods.h" 4 | #include "qt-openzwave/qtozwvalueidmodel.h" 5 | #include "qtozw_logging.h" 6 | 7 | 8 | Q_LOGGING_CATEGORY(manager, "ozw.manager"); 9 | Q_LOGGING_CATEGORY(valueModel, "ozw.values"); 10 | Q_LOGGING_CATEGORY(nodeModel, "ozw.nodes"); 11 | Q_LOGGING_CATEGORY(associationModel, "ozw.assocations"); 12 | Q_LOGGING_CATEGORY(notifications, "ozw.notifications"); 13 | Q_LOGGING_CATEGORY(logModel, "ozw.logging"); 14 | Q_LOGGING_CATEGORY(libopenzwave, "ozw.library"); 15 | Q_LOGGING_CATEGORY(qtrowebsocket, "ozw.remote"); 16 | Q_LOGGING_CATEGORY(options, "ozw.options"); 17 | 18 | 19 | QTOpenZwave::QTOpenZwave 20 | ( 21 | QObject *parent, 22 | QString ConfigPath, 23 | QString UserPath 24 | ) : 25 | QObject (parent), 26 | m_manager(nullptr), 27 | m_ozwconfigpath(ConfigPath), 28 | m_ozwuserpath(UserPath) 29 | { 30 | //qRegisterMetaType("uint32_t"); 31 | qRegisterMetaType("QTOZW_ValueIDList"); 32 | qRegisterMetaTypeStreamOperators("QTOZW_ValueIDList"); 33 | qRegisterMetaType("QTOZW_ValueIDBitSet"); 34 | qRegisterMetaTypeStreamOperators("QTOZW_ValueIDBitSet"); 35 | 36 | qRegisterMetaType("NodeStatistics"); 37 | qRegisterMetaTypeStreamOperators("NodeStatistics"); 38 | 39 | qRegisterMetaType("OptionList"); 40 | qRegisterMetaTypeStreamOperators("OptionList"); 41 | 42 | qRegisterMetaType("NotificationTypes::QTOZW_Notification_Code"); 43 | qRegisterMetaTypeStreamOperators("NotificationTypes::QTOZW_Notification_Code"); 44 | 45 | qRegisterMetaType("NotificationTypes::QTOZW_Notification_User>"); 46 | qRegisterMetaTypeStreamOperators("NotificationTypes::QTOZW_Notification_User>"); 47 | 48 | qRegisterMetaType("NotificationTypes::QTOZW_Notification_Controller_Error"); 49 | qRegisterMetaTypeStreamOperators("NotificationTypes::QTOZW_Notification_Controller_Error"); 50 | 51 | qRegisterMetaType("NotificationTypes::QTOZW_Notification_Controller_State"); 52 | qRegisterMetaTypeStreamOperators("NotificationTypes::QTOZW_Notification_Controller_State"); 53 | 54 | qRegisterMetaType("NotificationTypes::QTOZW_Notification_Controller_Cmd"); 55 | qRegisterMetaTypeStreamOperators("NotificationTypes::QTOZW_Notification_Controller_Cmd"); 56 | 57 | 58 | // qSetMessagePattern("[%{time yyyyMMdd h:mm:ss.zzz t}] %{category} %{file}:%{line}:%{function}: %{message}"); 59 | qSetMessagePattern("[%{time yyyyMMdd h:mm:ss.zzz t}] [%{category}] [%{type}]: %{message} %{if-fatal} %{backtrace [depth=10]} %{endif}"); 60 | } 61 | 62 | QTOZWManager *QTOpenZwave::GetManager 63 | ( 64 | ) 65 | { 66 | if (m_manager == nullptr) { 67 | this->m_manager = new QTOZWManager(this); 68 | this->m_manager->setOZWConfigPath(m_ozwconfigpath); 69 | this->m_manager->setOZWUserPath(m_ozwuserpath); 70 | } 71 | return this->m_manager; 72 | } 73 | 74 | #define VAL(str) #str 75 | #define TOSTRING(str) VAL(str) 76 | 77 | QString QTOpenZwave::getVersion() { 78 | return TOSTRING(LIB_VERSION); 79 | } 80 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtozw_pods.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozw_pods.cpp 4 | // 5 | // Common Structures for QTOZW Wrapper 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #include "qt-openzwave/qtozw_pods.h" 29 | #include "qtozw_logging.h" 30 | 31 | 32 | 33 | OptionList::OptionList() : 34 | enumnames(QStringList()), 35 | selected(0) 36 | { 37 | } 38 | OptionList::~OptionList() 39 | { 40 | } 41 | bool OptionList::operator!=(OptionList &c2) 42 | { 43 | return (this->selected != c2.selected) | (this->enumnames != c2.enumnames); 44 | } 45 | void OptionList::setEnums(QStringList list) 46 | { 47 | this->enumnames = list; 48 | } 49 | QStringList OptionList::getEnums() 50 | { 51 | return this->enumnames; 52 | } 53 | QString OptionList::getSelectedName() 54 | { 55 | return this->enumnames.at(this->selected); 56 | } 57 | int OptionList::getSelected() 58 | { 59 | return this->selected; 60 | } 61 | bool OptionList::setSelected(int index) 62 | { 63 | if (!this->enumnames.value(index).isEmpty()) { 64 | this->selected = index; 65 | return true; 66 | } 67 | return false; 68 | } 69 | bool OptionList::setSelected(QString value) 70 | { 71 | if (this->enumnames.count(value) > 0) { 72 | this->selected = this->enumnames.indexOf(value); 73 | return true; 74 | } 75 | return false; 76 | } 77 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtozwassociationmodel.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwassocationmodel.cpp 4 | // 5 | // Association Groups Exposed as a QAbstractTableModel 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #include 29 | #include 30 | #include "qtozw_logging.h" 31 | #include "qt-openzwave/qtozwassociationmodel.h" 32 | #include "qt-openzwave/qtopenzwave.h" 33 | 34 | 35 | QTOZW_Associations::QTOZW_Associations(QObject *parent) 36 | : QAbstractTableModel(parent) 37 | { 38 | } 39 | 40 | int QTOZW_Associations::rowCount(const QModelIndex &parent) const { 41 | if (parent.isValid()) 42 | return 0; 43 | return this->m_associationData.count(); 44 | } 45 | int QTOZW_Associations::columnCount(const QModelIndex &parent) const { 46 | if (parent.isValid()) 47 | return 0; 48 | return QTOZW_Associations::associationColumns::Count; 49 | } 50 | QVariant QTOZW_Associations::data(const QModelIndex &index, int role) const { 51 | if (!index.isValid()) 52 | return QVariant(); 53 | 54 | if (index.row() >= this->rowCount(index.parent()) || index.row() < 0) 55 | return QVariant(); 56 | 57 | if (role == Qt::DisplayRole) { 58 | QMap node = this->m_associationData[index.row()]; 59 | if (node.size() == 0) { 60 | qCWarning(associationModel) << "data: Cant find any Node on Row " << index.row(); 61 | return QVariant(); 62 | } 63 | return node[static_cast(index.column())]; 64 | } 65 | return QVariant(); 66 | 67 | } 68 | 69 | QVariant QTOZW_Associations::headerData(int section, Qt::Orientation orientation, int role) const { 70 | if (role != Qt::DisplayRole) 71 | return QVariant(); 72 | 73 | if (orientation == Qt::Horizontal) { 74 | switch (static_cast(section)) { 75 | case NodeID: 76 | return tr("NodeID"); 77 | 78 | case GroupID: 79 | return tr("Group ID"); 80 | 81 | case GroupName: 82 | return tr("Group Name"); 83 | 84 | case GroupHelp: 85 | return tr("Help"); 86 | 87 | case MaxAssocations: 88 | return tr("Max Assocations"); 89 | 90 | case Members: 91 | return tr("Members"); 92 | 93 | case Flags: 94 | return tr("Flags"); 95 | 96 | case Count: 97 | return QVariant(); 98 | } 99 | } 100 | return QVariant(); 101 | } 102 | #if 0 103 | bool QTOZW_Associations::setData(const QModelIndex &index, const QVariant &value, int role) { 104 | if (role != Qt::EditRole) { 105 | return false; 106 | } 107 | switch (static_cast(index.column())) { 108 | case Members: 109 | // if (this->m_valueData.at(index.row())[static_cast(index.column())] != value) { 110 | // qCDebug(valueModel) << "setData Called for Row" << index.row() << " With Value" << value; 111 | // this->m_valueData[index.row()][static_cast(index.column())] = value; 112 | // QVector roles; 113 | // roles << Qt::DisplayRole << QTOZW_UserRoles::ModelDataChanged; 114 | // this->dataChanged(index, index, roles); 115 | // } 116 | break; 117 | default: 118 | qCWarning(valueModel) << "got a setData for a Column other than Value. Ignoring" << index.column(); 119 | return false; 120 | } 121 | return true; 122 | } 123 | 124 | Qt::ItemFlags QTOZW_Associations::flags(const QModelIndex &index) const { 125 | if (!index.isValid()) 126 | return Qt::NoItemFlags; 127 | switch (static_cast(index.column())) { 128 | case Members: { 129 | return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; 130 | } 131 | break; 132 | default: 133 | return QAbstractTableModel::flags(index); 134 | } 135 | } 136 | #endif 137 | QVariant QTOZW_Associations::getassocationData(quint8 _node, quint8 _groupIDX, associationColumns _column) { 138 | int32_t row = this->getassocationRow(_node, _groupIDX); 139 | if (row >= 0) 140 | return this->m_associationData[row][_column]; 141 | qCWarning(associationModel) << "Can't find Group " << _groupIDX << " for node " << _node << " in m_associationData"; 142 | return QVariant(); 143 | } 144 | 145 | int32_t QTOZW_Associations::getassocationRow(quint8 _node, quint8 _groupIDX) { 146 | if (this->m_associationData.count() == 0) { 147 | return -1; 148 | } 149 | QMap >::iterator it; 150 | for (it = m_associationData.begin(); it != m_associationData.end(); ++it) { 151 | QMap group = it.value(); 152 | if (group.value(associationColumns::NodeID) == _node) { 153 | if (group.value(associationColumns::GroupID) == _groupIDX) { 154 | qCDebug(associationModel) << "getAssociationRow: Found Association at Row " << it.key(); 155 | return it.key(); 156 | } 157 | } 158 | } 159 | qCWarning(associationModel) << "Can't Find Group " << _groupIDX << " for node " << _node << " in m_associationData"; 160 | return -1; 161 | } 162 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtozwnodemodel_p.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwnodemodel_p.cpp 4 | // 5 | // Node Model - Internal Class to Manage the Model 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #include 29 | #include "qtozw_logging.h" 30 | #include "qtozwnodemodel_p.h" 31 | 32 | 33 | QTOZW_Nodes_internal::QTOZW_Nodes_internal(QObject *parent) 34 | : QTOZW_Nodes(parent) 35 | { 36 | 37 | } 38 | 39 | void QTOZW_Nodes_internal::addNode(quint8 _nodeID) 40 | { 41 | if (this->getNodeRow(_nodeID) >= 0) { 42 | qCWarning(nodeModel) << "Node " << _nodeID << " Already Exists"; 43 | return; 44 | } 45 | QMap newNode; 46 | newNode[QTOZW_Nodes::NodeID] = _nodeID; 47 | QBitArray flags(static_cast(QTOZW_Nodes::flagCount)); 48 | newNode[QTOZW_Nodes::NodeFlags] = flags; 49 | 50 | this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex())); 51 | this->m_nodeData.push_back(newNode); 52 | this->endInsertRows(); 53 | qCInfo(nodeModel) << "Adding Node " << _nodeID << "At Row " << this->getNodeRow(_nodeID); 54 | } 55 | 56 | void QTOZW_Nodes_internal::setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data, bool transaction) 57 | { 58 | int row = this->getNodeRow(_nodeID); 59 | if (row == -1) { 60 | qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist"; 61 | return; 62 | } 63 | if (this->m_nodeData.at(row)[column] != data) { 64 | this->m_nodeData[row][column] = data; 65 | QVector roles; 66 | roles << Qt::DisplayRole; 67 | if (!transaction) this->dataChanged(this->createIndex(row, column), this->createIndex(row, column), roles); 68 | qCDebug(nodeModel) << "setNodeData " << _nodeID << ": " << column << ":" << data << " Transaction:" << transaction; 69 | 70 | } 71 | } 72 | 73 | void QTOZW_Nodes_internal::setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value, bool transaction) 74 | { 75 | int row = this->getNodeRow(_nodeID); 76 | if (row == -1) { 77 | qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist"; 78 | return; 79 | } 80 | QBitArray flag = this->m_nodeData.at(row)[QTOZW_Nodes::NodeFlags].toBitArray(); 81 | if (flag.at(_flags) != _value) { 82 | flag.setBit(_flags, _value); 83 | this->m_nodeData[row][QTOZW_Nodes::NodeFlags] = flag; 84 | QVector roles; 85 | roles << Qt::DisplayRole; 86 | if (!transaction) this->dataChanged(this->createIndex(row, QTOZW_Nodes::NodeFlags), this->createIndex(row, QTOZW_Nodes::NodeFlags), roles); 87 | } 88 | } 89 | void QTOZW_Nodes_internal::delNode(quint8 _nodeID) { 90 | QVector< QMap >::iterator it; 91 | int i = 0; 92 | for (it = this->m_nodeData.begin(); it != this->m_nodeData.end();) { 93 | if ((*it)[QTOZW_Nodes::NodeColumns::NodeID] == _nodeID) { 94 | qCDebug(nodeModel) << "Removing Node " << (*it)[QTOZW_Nodes::NodeColumns::NodeID] << i; 95 | this->beginRemoveRows(QModelIndex(), i, i); 96 | it = this->m_nodeData.erase(it); 97 | this->endRemoveRows(); 98 | continue; 99 | } else { 100 | it++; 101 | } 102 | i++; 103 | } 104 | } 105 | 106 | void QTOZW_Nodes_internal::resetModel() { 107 | this->beginRemoveRows(QModelIndex(), 0, this->m_nodeData.count()); 108 | this->m_nodeData.clear(); 109 | this->endRemoveRows(); 110 | } 111 | 112 | void QTOZW_Nodes_internal::finishTransaction(quint8 _nodeID) { 113 | int row = this->getNodeRow(_nodeID); 114 | if (row == -1) { 115 | qCWarning(nodeModel) << "finishTransaction: Node " << _nodeID << " does not exist"; 116 | return; 117 | } 118 | this->dataChanged(this->createIndex(row, 0), this->createIndex(row, QTOZW_Nodes::NodeColumns::NodeCount-1)); 119 | 120 | } 121 | 122 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtozwproxymodels.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // qtozwproxymodels.cpp 4 | // 5 | // Various useful Filtering Proxy Models for QT-OpenZWave 6 | // 7 | // Copyright (c) 2019 Justin Hammond 8 | // 9 | // SOFTWARE NOTICE AND LICENSE 10 | // 11 | // This file is part of QT-OpenZWave. 12 | // 13 | // OpenZWave is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU Lesser General Public License as published 15 | // by the Free Software Foundation, either version 3 of the License, 16 | // or (at your option) any later version. 17 | // 18 | // OpenZWave is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with OpenZWave. If not, see . 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | #include 29 | #include "qt-openzwave/qtozwproxymodels.h" 30 | #include "qt-openzwave/qtozwvalueidmodel.h" 31 | #include "qt-openzwave/qtozwnodemodel.h" 32 | #include "qt-openzwave/qtozwassociationmodel.h" 33 | #include "qtozw_logging.h" 34 | 35 | 36 | QTOZW_proxyNodeModel::QTOZW_proxyNodeModel(QObject *parent) : QSortFilterProxyModel(parent) 37 | { 38 | 39 | } 40 | 41 | QTOZW_proxyValueModel::QTOZW_proxyValueModel(QObject *parent) : 42 | QSortFilterProxyModel (parent), 43 | m_genreFilter(QTOZW_ValueIds::ValueIdGenres::GenreCount) 44 | { 45 | 46 | } 47 | 48 | void QTOZW_proxyValueModel::setSelectionModel(QItemSelectionModel *model) { 49 | this->m_selectionmodel = model; 50 | QObject::connect(this->m_selectionmodel, &QItemSelectionModel::currentRowChanged, this, &QTOZW_proxyValueModel::currentSelectedRowChanged); 51 | } 52 | 53 | void QTOZW_proxyValueModel::currentSelectedRowChanged(const QModelIndex ¤t, const QModelIndex &previous) { 54 | Q_UNUSED(previous); 55 | this->m_nodeFilter = current.siblingAtColumn(QTOZW_Nodes::NodeColumns::NodeID).data().value(); 56 | qCDebug(valueModel) << "Selection Model Changed to Node " << this->m_nodeFilter; 57 | invalidateFilter(); 58 | } 59 | void QTOZW_proxyValueModel::setFilterGenre(QTOZW_ValueIds::ValueIdGenres genre) 60 | { 61 | this->m_genreFilter = genre; 62 | invalidateFilter(); 63 | } 64 | 65 | QTOZW_ValueIds::ValueIdGenres QTOZW_proxyValueModel::getFilterGenre() 66 | { 67 | return this->m_genreFilter; 68 | } 69 | 70 | QItemSelectionModel *QTOZW_proxyValueModel::getSelectionModel() 71 | { 72 | return this->m_selectionmodel; 73 | } 74 | 75 | quint8 QTOZW_proxyValueModel::getCurrentFilteredNode() 76 | { 77 | return this->m_nodeFilter; 78 | } 79 | 80 | 81 | 82 | bool QTOZW_proxyValueModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { 83 | if (this->m_genreFilter != QTOZW_ValueIds::ValueIdGenres::GenreCount) { 84 | QModelIndex genreIndex = sourceModel()->index(sourceRow, QTOZW_ValueIds::ValueIdColumns::Genre, sourceParent); 85 | if (genreIndex.data().value() != this->m_genreFilter) 86 | return false; 87 | } 88 | if (this->m_nodeFilter > 0) { 89 | QModelIndex nodeIDIndex = sourceModel()->index(sourceRow, QTOZW_ValueIds::ValueIdColumns::Node, sourceParent); 90 | if (nodeIDIndex.data().value() != this->m_nodeFilter) 91 | return false; 92 | } 93 | return true; 94 | } 95 | 96 | QTOZW_proxyAssociationModel::QTOZW_proxyAssociationModel(QObject *parent) : 97 | QSortFilterProxyModel (parent) 98 | { 99 | 100 | } 101 | 102 | void QTOZW_proxyAssociationModel::setSelectionModel(QItemSelectionModel *model) { 103 | this->m_selectionmodel = model; 104 | QObject::connect(this->m_selectionmodel, &QItemSelectionModel::currentRowChanged, this, &QTOZW_proxyAssociationModel::currentSelectedRowChanged); 105 | } 106 | 107 | void QTOZW_proxyAssociationModel::currentSelectedRowChanged(const QModelIndex ¤t, const QModelIndex &previous) { 108 | Q_UNUSED(previous); 109 | this->m_nodeFilter = current.siblingAtColumn(QTOZW_Nodes::NodeColumns::NodeID).data().value(); 110 | invalidateFilter(); 111 | } 112 | 113 | bool QTOZW_proxyAssociationModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { 114 | if (this->m_nodeFilter > 0) { 115 | QModelIndex nodeIDIndex = sourceModel()->index(sourceRow, QTOZW_Associations::associationColumns::NodeID, sourceParent); 116 | if (nodeIDIndex.data().value() != this->m_nodeFilter) 117 | return false; 118 | } 119 | return true; 120 | } 121 | 122 | -------------------------------------------------------------------------------- /qt-openzwave/source/qtozwreplica.cpp: -------------------------------------------------------------------------------- 1 | #include "qt-openzwave/qtozwreplica.h" 2 | #include "qtozw_logging.h" 3 | 4 | QTOZWReplicaBase::QTOZWReplicaBase(ConnectionType::Type connectionType, QObject *parent) : 5 | QObject(parent), 6 | m_connectionType(connectionType), 7 | m_ready(false) 8 | { 9 | } 10 | QTOZWReplicaBase::~QTOZWReplicaBase() 11 | { 12 | } 13 | 14 | ConnectionType::Type QTOZWReplicaBase::getConnectionType() const 15 | { 16 | return this->m_connectionType; 17 | } 18 | 19 | void QTOZWReplicaBase::setConnectionType(ConnectionType::Type connectionType) 20 | { 21 | if (this->m_connectionType != connectionType) { 22 | this->m_connectionType = connectionType; 23 | emit connectionTypeChanged(this->m_connectionType); 24 | } 25 | } 26 | 27 | bool QTOZWReplicaBase::isReady() const 28 | { 29 | return this->m_ready; 30 | } 31 | 32 | void QTOZWReplicaBase::setReady(bool ready) 33 | { 34 | if (this->m_ready != ready) { 35 | qCDebug(manager) << this->metaObject()->className() << "Ready!"; 36 | this->m_ready = ready; 37 | emit readyChanged(this->m_ready); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /qt-openzwavedatabase/include/qt-openzwave/qt-openzwavedatabase.h: -------------------------------------------------------------------------------- 1 | #ifndef QTOPENZWAVEDATABASE_H 2 | #define QTOPENZWAVEDATABASE_H 3 | #include 4 | #include 5 | 6 | #if defined(QTOZWDATABASE_SHARED_LIBRARY) 7 | # define QTOZWDATABASE_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define QTOZWDATABASE_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | Q_DECLARE_LOGGING_CATEGORY(qtozwdatabase); 13 | 14 | QTOZWDATABASE_EXPORT bool initConfigDatabase(QStringList paths); 15 | QTOZWDATABASE_EXPORT bool finiConfigDatabase(); 16 | 17 | QTOZWDATABASE_EXPORT bool copyConfigDatabase(QDir configpath); 18 | QTOZWDATABASE_EXPORT bool copyUserDatabase(QDir configpath); 19 | 20 | 21 | #endif // QTOPENZWAVEDATABASE_H 22 | -------------------------------------------------------------------------------- /qt-openzwavedatabase/qt-openzwavedatabase.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | TEMPLATE = lib 4 | 5 | VERSION = 1.0.0 6 | 7 | CONFIG += silent file_copies resources_big force_debug_info 8 | 9 | !versionAtLeast(QT_VERSION, 5.12.0):error("Use at least Qt version 5.12.0") 10 | 11 | include(../qt-openzwave.pri) 12 | 13 | win32-msvc* { 14 | CONFIG += dll 15 | } 16 | 17 | DEFINES += QTOZWDATABASE_SHARED_LIBRARY 18 | DEFINES += QT_INSTALL_DATA=\"$$[QT_INSTALL_DATA]\" 19 | 20 | win32:QMAKE_DEL_DIR = rmdir /s /q 21 | win32:QMAKE_DEL_FILE = del /q 22 | 23 | ozwconfig.target=qt-openzwavedatabase.rcc 24 | ozwconfig.commands+=echo "Generating qt-openzwavedatabase.rcc:" 25 | ozwconfig.commands+=&& $(DEL_FILE) $$shell_path($$OUT_PWD/qt-openzwavedatabase.rcc) 26 | ozwconfig.commands+=&& $(COPY_DIR) $$shell_path($$OZW_DATABASE_PATH) $$shell_path($$OUT_PWD/config/) 27 | ozwconfig.commands+=&& cd $$shell_path($$OUT_PWD/config/) 28 | ozwconfig.commands+=&& $$[QT_INSTALL_BINS]/rcc -project -o $$shell_path($$OUT_PWD/config/ozwconfig.qrc) 29 | ozwconfig.commands+=&& $$[QT_INSTALL_BINS]/rcc --name="ozwconfig" --root="/config/" $$shell_path($$OUT_PWD/config/ozwconfig.qrc) --binary -o $$shell_path($$OUT_PWD/qt-openzwavedatabase.rcc) 30 | ozwconfig.commands+=&& echo "Done" 31 | 32 | ozwrccdb.files+=qt-openzwavedatabase.rcc 33 | ozwrccdb.CONFIG+=no_check_exist 34 | 35 | extraclean.commands=-$(DEL_FILE) qt-openzwavedatabase.rcc 36 | extraclean.commands+=&& $(DEL_DIR) config 37 | clean.depends=extraclean 38 | 39 | 40 | SOURCES += source/qt-openzwavedatabase.cpp 41 | 42 | PUBLIC_HEADERS.files += include/qt-openzwave/qt-openzwavedatabase.h 43 | 44 | HEADERS += $$PUBLIC_HEADERS.files 45 | 46 | INCLUDEPATH += include/ 47 | isEmpty(PREFIX) { 48 | PREFIX=/usr/local/ 49 | } 50 | isEmpty(LIBDIR) { 51 | target.path = $$[QT_INSTALL_LIBS] 52 | } else { 53 | target.path = $$PREFIX/$$LIBDIR 54 | } 55 | isEmpty(INCDIR) { 56 | PUBLIC_HEADERS.path = $$[QT_INSTALL_HEADERS]/qt-openzwave/ 57 | } else { 58 | PUBLIC_HEADERS.path = $$PREFIX/$$INCDIR 59 | } 60 | isEmpty(DATADIR) { 61 | ozwrccdb.path=$$[QT_INSTALL_DATA] 62 | } else { 63 | ozwrccdb.path = $$PREFIX/share/$$TARGET 64 | } 65 | message("Final Installation Directories:") 66 | message(" LibDir: $$target.path") 67 | message(" IncDir: $$PUBLIC_HEADERS.path") 68 | message(" DataDir: $$ozwrccdb.path") 69 | INSTALLS += target 70 | INSTALLS += PUBLIC_HEADERS 71 | INSTALLS += ozwrccdb 72 | QMAKE_EXTRA_TARGETS += clean extraclean ozwconfig 73 | PRE_TARGETDEPS += qt-openzwavedatabase.rcc 74 | QMAKE_STRIP=@echo 75 | QMAKE_CXXFLAGS += -g1 76 | QMAKE_LFLAGS += -rdynamic 77 | 78 | macx { 79 | QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ 80 | } 81 | 82 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttAssociations.cpp: -------------------------------------------------------------------------------- 1 | #include "qt-openzwave/qtozwmanager.h" 2 | #include "mqttAssociations.h" 3 | #include "qtrj.h" 4 | 5 | 6 | Q_LOGGING_CATEGORY(ozwmpassociation, "ozw.mqtt.publisher.association"); 7 | 8 | mqttAssociationModel::mqttAssociationModel(QObject *parent) : 9 | QTOZW_Associations(parent) 10 | { 11 | 12 | } 13 | 14 | 15 | bool mqttAssociationModel::populateJsonObject(rapidjson::Document &jsonobject, quint8 node, quint8 group, QTOZWManager *mgr) { 16 | Q_UNUSED(mgr); 17 | if (jsonobject.IsNull()) 18 | jsonobject.SetObject(); 19 | 20 | QT2JS::SetString(jsonobject, "Name", getassocationData(node, group, QTOZW_Associations::associationColumns::GroupName).toString()); 21 | QT2JS::SetString(jsonobject, "Help", getassocationData(node, group, QTOZW_Associations::associationColumns::GroupHelp).toString()); 22 | QT2JS::SetUint(jsonobject, "MaxAssociations", getassocationData(node, group, QTOZW_Associations::associationColumns::MaxAssocations).toInt()); 23 | QStringList members = getassocationData(node, group, QTOZW_Associations::associationColumns::Members).toStringList(); 24 | rapidjson::Value N(rapidjson::kArrayType); 25 | for (int i = 0; i < members.size(); i++) { 26 | rapidjson::Value strVal; 27 | strVal.SetString(members.at(i).toStdString().c_str(), jsonobject.GetAllocator()); 28 | N.PushBack(strVal, jsonobject.GetAllocator()); 29 | } 30 | jsonobject.AddMember(rapidjson::Value("Members").Move(), N, jsonobject.GetAllocator()); 31 | return true; 32 | } 33 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttAssociations.h: -------------------------------------------------------------------------------- 1 | #ifndef MQTTASSOC_H 2 | #define MQTTASSOC_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "qt-openzwave/qtozwassociationmodel.h" 8 | 9 | class mqttAssociationModel : public QTOZW_Associations { 10 | Q_OBJECT 11 | public: 12 | explicit mqttAssociationModel(QObject *parent = nullptr); 13 | bool populateJsonObject(rapidjson::Document &, quint8, quint8, QTOZWManager *); 14 | }; 15 | 16 | 17 | #endif -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttNodes.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "qt-openzwave/qtozwmanager.h" 3 | #include "mqttNodes.h" 4 | #include "qtrj.h" 5 | 6 | 7 | Q_LOGGING_CATEGORY(ozwmpnode, "ozw.mqtt.publisher.node"); 8 | 9 | mqttNodeModel::mqttNodeModel(QObject *parent) : 10 | QTOZW_Nodes(parent) 11 | { 12 | 13 | } 14 | 15 | QVariant mqttNodeModel::getNodeData(quint8 node, NodeColumns col) { 16 | int row = this->getNodeRow(node); 17 | return this->data(this->index(row, col), Qt::DisplayRole); 18 | } 19 | 20 | bool mqttNodeModel::isValidNode(quint8 node) { 21 | if (this->getNodeRow(node) == -1) 22 | return false; 23 | return true; 24 | } 25 | 26 | 27 | bool mqttNodeModel::populateJsonObject(rapidjson::Document &jsonobject, quint8 node, QTOZWManager *mgr) { 28 | if (jsonobject.IsNull()) 29 | jsonobject.SetObject(); 30 | 31 | for (int i = 0; i < this->columnCount(QModelIndex()); i++) { 32 | QVariant data = this->getNodeData(node, static_cast(i)); 33 | if (data.type() == QVariant::Invalid) { 34 | continue; 35 | } 36 | switch (static_cast(i)) { 37 | case NodeColumns::NodeFlags: { 38 | QBitArray flag = data.toBitArray(); 39 | QMetaEnum metaEnum = QMetaEnum::fromType(); 40 | for (int j = 0; j < nodeFlags::flagCount; j++) { 41 | QT2JS::SetBool(jsonobject, metaEnum.valueToKey(j), flag.at(j)); 42 | } 43 | break; 44 | } 45 | default: { 46 | QMetaEnum metaEnum = QMetaEnum::fromType(); 47 | if (static_cast(data.type()) == QMetaType::QString) { 48 | QT2JS::SetString(jsonobject, metaEnum.valueToKey(i), data.toString()); 49 | } else if (static_cast(data.type()) == QMetaType::Bool) { 50 | QT2JS::SetBool(jsonobject, metaEnum.valueToKey(i), data.toBool()); 51 | } else if (static_cast(data.type()) == QMetaType::Int) { 52 | QT2JS::SetInt(jsonobject, metaEnum.valueToKey(i), data.toInt()); 53 | } else if (static_cast(data.type()) == QMetaType::UInt) { 54 | QT2JS::SetUint(jsonobject, metaEnum.valueToKey(i), data.toUInt()); 55 | } else { 56 | qCWarning(ozwmpnode) << "Can't Convert " << data.type() << "(" << metaEnum.valueToKey(i) << ") to store in JsonObject: " << node; 57 | } 58 | break; 59 | } 60 | } 61 | 62 | } 63 | /* MetaData */ 64 | rapidjson::Value metadata; 65 | if (!jsonobject.HasMember("MetaData")) { 66 | rapidjson::Value metadata; 67 | metadata.SetObject(); 68 | QMetaEnum metaEnum = QMetaEnum::fromType(); 69 | if (metadata.IsNull()) { 70 | metadata.SetObject(); 71 | } 72 | for (int i = 0; i < QTOZWManagerSource::Identifier; i++) { 73 | metadata.AddMember( 74 | rapidjson::Value(metaEnum.valueToKey(i), jsonobject.GetAllocator()).Move(), 75 | rapidjson::Value(mgr->GetMetaData(node, static_cast(i)).toStdString().c_str(), jsonobject.GetAllocator()).Move(), 76 | jsonobject.GetAllocator()); 77 | } 78 | metadata.AddMember(rapidjson::Value("ProductPicBase64").Move(), 79 | rapidjson::Value(QString(mgr->GetMetaDataProductPic(node).toBase64()).toStdString().c_str(), jsonobject.GetAllocator()).Move(), 80 | jsonobject.GetAllocator()); 81 | 82 | jsonobject.AddMember(rapidjson::Value("MetaData"), metadata, jsonobject.GetAllocator()); 83 | } 84 | /* Neighbors */ 85 | QVector neighbors = mgr->GetNodeNeighbors(node); 86 | if (neighbors.size() > 0) { 87 | rapidjson::Value N(rapidjson::kArrayType); 88 | for (int i = 0; i < neighbors.count(); i++) { 89 | N.PushBack(neighbors[i], jsonobject.GetAllocator()); 90 | } 91 | jsonobject.AddMember(rapidjson::Value("Neighbors").Move(), N, jsonobject.GetAllocator()); 92 | } 93 | return true; 94 | } 95 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttNodes.h: -------------------------------------------------------------------------------- 1 | #ifndef MQTTNODES_H 2 | #define MQTTNODES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "qt-openzwave/qtozwnodemodel.h" 8 | 9 | class mqttNodeModel : public QTOZW_Nodes { 10 | Q_OBJECT 11 | public: 12 | explicit mqttNodeModel(QObject *parent = nullptr); 13 | QVariant getNodeData(quint8, NodeColumns); 14 | bool populateJsonObject(rapidjson::Document &, quint8, QTOZWManager *); 15 | bool isValidNode(quint8); 16 | }; 17 | 18 | 19 | #endif -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttValues.h: -------------------------------------------------------------------------------- 1 | #ifndef MQTTVALUES_H 2 | #define MQTTVALUES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "qt-openzwave/qtozwvalueidmodel.h" 8 | 9 | 10 | class mqttValueIDModel : public QTOZW_ValueIds { 11 | Q_OBJECT 12 | public: 13 | using QTOZW_ValueIds::setData; 14 | explicit mqttValueIDModel(QObject *parent = nullptr); 15 | QVariant getValueData(quint64, ValueIdColumns); 16 | bool populateJsonObject(rapidjson::Document &, quint64, QTOZWManager *); 17 | bool encodeValue(rapidjson::Document &, quint64); 18 | bool isValidValueID(quint64); 19 | bool setData(quint64, QVariant); 20 | }; 21 | 22 | 23 | #endif -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/IsNodeFailed.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/IsNodeFailed.h" 2 | 3 | MqttCommand_IsNodeFailed::MqttCommand_IsNodeFailed(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_IsNodeFailed::Create(QObject *parent) { 9 | return new MqttCommand_IsNodeFailed(parent); 10 | } 11 | 12 | bool MqttCommand_IsNodeFailed::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->IsNodeFailed(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/IsNodeFailed.h: -------------------------------------------------------------------------------- 1 | #ifndef ISNODEFAILED_H 2 | #define ISNODEFAILED_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_IsNodeFailed : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "isnodefailed";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_IsNodeFailed(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // ISNODEFAILED_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/addAssociation.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/addAssociation.h" 2 | 3 | MqttCommand_AddAssociation::MqttCommand_AddAssociation(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node" << "group"; 7 | this->m_requiredStringFields << "target"; 8 | } 9 | MqttCommand* MqttCommand_AddAssociation::Create(QObject *parent) { 10 | return new MqttCommand_AddAssociation(parent); 11 | } 12 | 13 | bool MqttCommand_AddAssociation::processMessage(rapidjson::Document &msg) { 14 | if (!this->checkNode(msg, "node")) { 15 | return this->sendSimpleStatus(false, "Invalid Node Number"); 16 | } 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->AddAssociation(msg["node"].GetUint(), msg["group"].GetUint(), msg["target"].GetString())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/addAssociation.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDASSOCIATION_H 2 | #define ADDASSOCIATION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_AddAssociation : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "addassociation";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_AddAssociation(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/addNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/addNode.h" 2 | 3 | MqttCommand_AddNode::MqttCommand_AddNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredBoolFields << "secure"; 7 | } 8 | MqttCommand* MqttCommand_AddNode::Create(QObject *parent) { 9 | return new MqttCommand_AddNode(parent); 10 | } 11 | 12 | bool MqttCommand_AddNode::processMessage(rapidjson::Document &msg) { 13 | QTOZWManager *mgr = getOZWManager(); 14 | return this->sendSimpleStatus(mgr->addNode(msg["secure"].GetBool())); 15 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/addNode.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDNODE_H 2 | #define ADDNODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_AddNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "addnode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_AddNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/assignReturnRoute.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/assignReturnRoute.h" 2 | 3 | MqttCommand_AssignReturnRoute::MqttCommand_AssignReturnRoute(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_AssignReturnRoute::Create(QObject *parent) { 9 | return new MqttCommand_AssignReturnRoute(parent); 10 | } 11 | 12 | bool MqttCommand_AssignReturnRoute::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->assignReturnRoute(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/assignReturnRoute.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSIGNRETURNROUTE_H 2 | #define ASSIGNRETURNROUTE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_AssignReturnRoute : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "assignreturnroute";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_AssignReturnRoute(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/cancelControllerCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/cancelControllerCommand.h" 2 | 3 | MqttCommand_CancelControllerCommand::MqttCommand_CancelControllerCommand(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_CancelControllerCommand::Create(QObject *parent) { 8 | return new MqttCommand_CancelControllerCommand(parent); 9 | } 10 | 11 | bool MqttCommand_CancelControllerCommand::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | return this->sendSimpleStatus(mgr->cancelControllerCommand()); 15 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/cancelControllerCommand.h: -------------------------------------------------------------------------------- 1 | #ifndef CANCELCONTROLLERCOMMAND_H 2 | #define CANCELCONTROLLERCOMMAND_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_CancelControllerCommand : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "cancelcontrollercommand";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_CancelControllerCommand(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // CANCELCONTROLLERCOMMAND_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/checkLatestConfigFileRevision.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/checkLatestConfigFileRevision.h" 2 | 3 | MqttCommand_CheckLatestConfigFileRevision::MqttCommand_CheckLatestConfigFileRevision(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_CheckLatestConfigFileRevision::Create(QObject *parent) { 9 | return new MqttCommand_CheckLatestConfigFileRevision(parent); 10 | } 11 | 12 | bool MqttCommand_CheckLatestConfigFileRevision::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->checkLatestConfigFileRevision(msg["node"].GetUint())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/checkLatestConfigFileRevision.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKLATESTCONFIGFILEREVISION_H 2 | #define CHECKLATESTCONFIGFILEREVISION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_CheckLatestConfigFileRevision : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "checklatestconfigfilerevision";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_CheckLatestConfigFileRevision(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // CHECKLATESTCONFIGFILEREVISION_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/checkLatestMFSRevision.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/checkLatestMFSRevision.h" 2 | 3 | MqttCommand_CheckLatestMFSRevision::MqttCommand_CheckLatestMFSRevision(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_CheckLatestMFSRevision::Create(QObject *parent) { 8 | return new MqttCommand_CheckLatestMFSRevision(parent); 9 | } 10 | 11 | bool MqttCommand_CheckLatestMFSRevision::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->checkLatestMFSRevision(); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/checkLatestMFSRevision.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKLATESTMFSREVISION_H 2 | #define CHECKLATESTMFSREVISION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_CheckLatestMFSRevision : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "checklatestmfsrevision";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_CheckLatestMFSRevision(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // CHECKLATESTMFSREVISION_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/close.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/close.h" 2 | 3 | MqttCommand_Close::MqttCommand_Close(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_Close::Create(QObject *parent) { 8 | return new MqttCommand_Close(parent); 9 | } 10 | 11 | bool MqttCommand_Close::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | return this->sendSimpleStatus(mgr->close()); 15 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/close.h: -------------------------------------------------------------------------------- 1 | #ifndef CLOSE_H 2 | #define CLOSE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_Close : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "close";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_Close(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // CLOSE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/deleteAllReturnRoute.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/deleteAllReturnRoute.h" 2 | 3 | MqttCommand_DeleteAllReturnRoute::MqttCommand_DeleteAllReturnRoute(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_DeleteAllReturnRoute::Create(QObject *parent) { 9 | return new MqttCommand_DeleteAllReturnRoute(parent); 10 | } 11 | 12 | bool MqttCommand_DeleteAllReturnRoute::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->deleteAllReturnRoute(msg["node"].GetUint())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/deleteAllReturnRoute.h: -------------------------------------------------------------------------------- 1 | #ifndef DELETEALLRETURNROUTE_H 2 | #define DELETEALLRETURNROUTE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_DeleteAllReturnRoute : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "deleteallreturnroute";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_DeleteAllReturnRoute(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // DELETEALLRETURNROUTE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/disablePoll.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/disablePoll.h" 2 | 3 | MqttCommand_DisablePoll::MqttCommand_DisablePoll(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "ValueIDKey"; 7 | } 8 | MqttCommand* MqttCommand_DisablePoll::Create(QObject *parent) { 9 | return new MqttCommand_DisablePoll(parent); 10 | } 11 | 12 | bool MqttCommand_DisablePoll::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkValue(msg, "ValueIDKey")) { 14 | return this->sendSimpleStatus(false, "Invalid ValueIDKey Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->disablePoll(msg["ValueIDKey"].GetUint64())); 18 | } 19 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/disablePoll.h: -------------------------------------------------------------------------------- 1 | #ifndef DISABLEPOLL_H 2 | #define DISABLEPOLL_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_DisablePoll : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "disablepoll";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_DisablePoll(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/downloadLatestConfigFileRevision.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/downloadLatestConfigFileRevision.h" 2 | 3 | MqttCommand_DownloadLatestConfigFileRevision::MqttCommand_DownloadLatestConfigFileRevision(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_DownloadLatestConfigFileRevision::Create(QObject *parent) { 9 | return new MqttCommand_DownloadLatestConfigFileRevision(parent); 10 | } 11 | 12 | bool MqttCommand_DownloadLatestConfigFileRevision::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->downloadLatestConfigFileRevision(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/downloadLatestConfigFileRevision.h: -------------------------------------------------------------------------------- 1 | #ifndef DOWNLOADLATESTCONFIGFILEREVISION_H 2 | #define DOWNLOADLATESTCONFIGFILEREVISION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_DownloadLatestConfigFileRevision : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "downloadlatestconfigfilerevision";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_DownloadLatestConfigFileRevision(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // DOWNLOADLATESTCONFIGFILEREVISION_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/downloadLatestMFSRevision.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/downloadLatestMFSRevision.h" 2 | 3 | MqttCommand_DownloadLatestMFSRevision::MqttCommand_DownloadLatestMFSRevision(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_DownloadLatestMFSRevision::Create(QObject *parent) { 8 | return new MqttCommand_DownloadLatestMFSRevision(parent); 9 | } 10 | 11 | bool MqttCommand_DownloadLatestMFSRevision::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | return this->sendSimpleStatus(mgr->downloadLatestMFSRevision()); 15 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/downloadLatestMFSRevision.h: -------------------------------------------------------------------------------- 1 | #ifndef DOWNLOADLATESTMFSREVISION_H 2 | #define DOWNLOADLATESTMFSREVISION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_DownloadLatestMFSRevision : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "downloadlatestmfsrevision";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_DownloadLatestMFSRevision(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // DOWNLOADLATESTMFSREVISION_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/enablePoll.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/enablePoll.h" 2 | 3 | MqttCommand_EnablePoll::MqttCommand_EnablePoll(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "ValueIDKey" << "Intensity"; 7 | } 8 | MqttCommand* MqttCommand_EnablePoll::Create(QObject *parent) { 9 | return new MqttCommand_EnablePoll(parent); 10 | } 11 | 12 | bool MqttCommand_EnablePoll::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkValue(msg, "ValueIDKey")) { 14 | return this->sendSimpleStatus(false, "Invalid ValueIDKey Number"); 15 | } 16 | 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->enablePoll(msg["ValueIDKey"].GetUint64(), msg["Intensity"].GetUint())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/enablePoll.h: -------------------------------------------------------------------------------- 1 | #ifndef ENABLEPOLL_H 2 | #define ENABLEPOLL_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_EnablePoll : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "enablepoll";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_EnablePoll(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // ENABLEPOLL_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/getPollInterval.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/getPollInterval.h" 2 | 3 | MqttCommand_GetPollInterval::MqttCommand_GetPollInterval(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_GetPollInterval::Create(QObject *parent) { 8 | return new MqttCommand_GetPollInterval(parent); 9 | } 10 | 11 | bool MqttCommand_GetPollInterval::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | rapidjson::Document js; 15 | QT2JS::SetString(js, "status", "ok"); 16 | QT2JS::SetInt64(js, "pollInterval", mgr->getPollInterval()); 17 | emit sendCommandUpdate(GetCommand(), js); 18 | return true; 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/getPollInterval.h: -------------------------------------------------------------------------------- 1 | #ifndef GETPOLLINTERVAL_H 2 | #define GETPOLLINTERVAL_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_GetPollInterval : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "getpollinterval";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_GetPollInterval(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // GETPOLLINTERVAL_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/hardResetController.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/hardResetController.h" 2 | 3 | MqttCommand_HardResetController::MqttCommand_HardResetController(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_HardResetController::Create(QObject *parent) { 8 | return new MqttCommand_HardResetController(parent); 9 | } 10 | 11 | bool MqttCommand_HardResetController::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->hardResetController(); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/hardResetController.h: -------------------------------------------------------------------------------- 1 | #ifndef HARDRESETCONTROLLER_H 2 | #define HARDRESETCONTROLLER_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_HardResetController : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "hardresetcontroller";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_HardResetController(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // HARDRESETCONTROLLER_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/hasNodeFailed.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/hasNodeFailed.h" 2 | 3 | MqttCommand_HasNodeFailed::MqttCommand_HasNodeFailed(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_HasNodeFailed::Create(QObject *parent) { 9 | return new MqttCommand_HasNodeFailed(parent); 10 | } 11 | 12 | bool MqttCommand_HasNodeFailed::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->hasNodeFailed(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/hasNodeFailed.h: -------------------------------------------------------------------------------- 1 | #ifndef HASNODEFAILED_H 2 | #define HASNODEFAILED_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_HasNodeFailed : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "hasnodefailed";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_HasNodeFailed(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // HASNODEFAILED_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/healNetwork.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/healNetwork.h" 2 | 3 | MqttCommand_HealNetwork::MqttCommand_HealNetwork(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredBoolFields << "doreturnroute"; 7 | } 8 | MqttCommand* MqttCommand_HealNetwork::Create(QObject *parent) { 9 | return new MqttCommand_HealNetwork(parent); 10 | } 11 | 12 | bool MqttCommand_HealNetwork::processMessage(rapidjson::Document &msg) { 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->healNetwork(msg["doreturnroute"].GetBool()); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/healNetwork.h: -------------------------------------------------------------------------------- 1 | #ifndef HEALNETWORK_H 2 | #define HEALNETWORK_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_HealNetwork : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "healnetwork";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_HealNetwork(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/healNetworkNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/healNetworkNode.h" 2 | 3 | MqttCommand_HealNetworkNode::MqttCommand_HealNetworkNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | this->m_requiredBoolFields << "doreturnroute"; 8 | } 9 | MqttCommand* MqttCommand_HealNetworkNode::Create(QObject *parent) { 10 | return new MqttCommand_HealNetworkNode(parent); 11 | } 12 | 13 | bool MqttCommand_HealNetworkNode::processMessage(rapidjson::Document &msg) { 14 | if (!this->checkNode(msg, "node")) { 15 | return this->sendSimpleStatus(false, "Invalid Node Number"); 16 | } 17 | QTOZWManager *mgr = getOZWManager(); 18 | mgr->healNetworkNode(msg["node"].GetUint(), msg["doreturnroute"].GetBool()); 19 | return this->sendSimpleStatus(true); 20 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/healNetworkNode.h: -------------------------------------------------------------------------------- 1 | #ifndef HEALNETWORKNODE_H 2 | #define HEALNETWORKNODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_HealNetworkNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "healnetworknode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_HealNetworkNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // HEALNETWORKNODE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/mqttcommands.h: -------------------------------------------------------------------------------- 1 | #ifndef MQTTCOMMANDS_H 2 | #define MQTTCOMMANDS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include "mqttpublisher.h" 14 | #include "qtrj.h" 15 | 16 | 17 | 18 | class mqttpublisher; 19 | 20 | class MqttCommand : public QObject { 21 | Q_OBJECT 22 | public: 23 | void Setup(QMqttSubscription *); 24 | void messageReceived(QMqttMessage msg); 25 | virtual bool processMessage(rapidjson::Document &) = 0; 26 | virtual QString GetCommand() = 0; 27 | signals: 28 | void sendCommandUpdate(QString, rapidjson::Document &); 29 | protected: 30 | MqttCommand(QObject *parent = nullptr); 31 | QTOZWManager *getOZWManager(); 32 | mqttpublisher *getMqttPublisher(); 33 | bool checkNode(rapidjson::Document &, QString); 34 | bool checkValue(rapidjson::Document &, QString); 35 | QVariant getValueData(quint64, QTOZW_ValueIds::ValueIdColumns); 36 | bool setValue(quint64, QVariant); 37 | QVector m_requiredStringFields; 38 | QVector m_requiredIntFields; 39 | QVector m_requiredBoolFields; 40 | bool sendSimpleStatus(bool, QString error = QString()); 41 | 42 | private: 43 | QMqttSubscription *m_subscription; 44 | }; 45 | 46 | 47 | typedef MqttCommand* (*pfnCreateCommand_t)(QObject *); 48 | 49 | 50 | class MqttCommands : public QObject { 51 | Q_OBJECT 52 | public: 53 | MqttCommands(QObject *parent = nullptr); 54 | void Register(QString command, pfnCreateCommand_t _create); 55 | void setupCommands(); 56 | void setupSubscriptions(QMqttClient *, QString); 57 | private: 58 | QMap m_commands; 59 | }; 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/open.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/open.h" 2 | 3 | MqttCommand_Open::MqttCommand_Open(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredStringFields << "serialport"; 7 | } 8 | MqttCommand* MqttCommand_Open::Create(QObject *parent) { 9 | return new MqttCommand_Open(parent); 10 | } 11 | 12 | bool MqttCommand_Open::processMessage(rapidjson::Document &msg) { 13 | QTOZWManager *mgr = getOZWManager(); 14 | return this->sendSimpleStatus(mgr->open(msg["serialport"].GetString())); 15 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/open.h: -------------------------------------------------------------------------------- 1 | #ifndef OPEN_H 2 | #define OPEN_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_Open : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "open";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_Open(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/ping.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/ping.h" 2 | 3 | MqttCommand_Ping::MqttCommand_Ping(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredStringFields << "ping"; 7 | } 8 | MqttCommand* MqttCommand_Ping::Create(QObject *parent) { 9 | return new MqttCommand_Ping(parent); 10 | } 11 | 12 | bool MqttCommand_Ping::processMessage(rapidjson::Document &msg) { 13 | rapidjson::Document js; 14 | QT2JS::SetString(js, "pong", msg["ping"].GetString()); 15 | emit sendCommandUpdate(MqttCommand_Ping::GetCommand(), js); 16 | return true; 17 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/ping.h: -------------------------------------------------------------------------------- 1 | #ifndef PING_H 2 | #define PING_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_Ping : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "ping";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_Ping(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H 18 | -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/refreshValue.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/refreshValue.h" 2 | 3 | MqttCommand_RefreshValue::MqttCommand_RefreshValue(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "ValueIDKey"; 7 | } 8 | MqttCommand* MqttCommand_RefreshValue::Create(QObject *parent) { 9 | return new MqttCommand_RefreshValue(parent); 10 | } 11 | 12 | bool MqttCommand_RefreshValue::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkValue(msg, "ValueIDKey")) { 14 | return this->sendSimpleStatus(false, "Invalid ValueIDKey Number"); 15 | } 16 | 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->refreshValue(msg["ValueIDKey"].GetUint64())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/refreshValue.h: -------------------------------------------------------------------------------- 1 | #ifndef REFRESHVALUE_H 2 | #define REFRESHVALUE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RefreshValue : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "refreshvalue";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RefreshValue(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REFRESHVALUE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/refreshnodeinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/refreshnodeinfo.h" 2 | 3 | MqttCommand_RefreshNodeInfo::MqttCommand_RefreshNodeInfo(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RefreshNodeInfo::Create(QObject *parent) { 9 | return new MqttCommand_RefreshNodeInfo(parent); 10 | } 11 | 12 | bool MqttCommand_RefreshNodeInfo::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->refreshNodeInfo(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/refreshnodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef REFRESHNODEINFO_H 2 | #define REFRESHNODEINFO_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RefreshNodeInfo : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "refreshnodeinfo";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RefreshNodeInfo(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeAssociation.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/removeAssociation.h" 2 | 3 | MqttCommand_RemoveAssociation::MqttCommand_RemoveAssociation(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node" << "group"; 7 | this->m_requiredStringFields << "target"; 8 | } 9 | MqttCommand* MqttCommand_RemoveAssociation::Create(QObject *parent) { 10 | return new MqttCommand_RemoveAssociation(parent); 11 | } 12 | 13 | bool MqttCommand_RemoveAssociation::processMessage(rapidjson::Document &msg) { 14 | if (!this->checkNode(msg, "node")) { 15 | return this->sendSimpleStatus(false, "Invalid Node Number"); 16 | } 17 | QTOZWManager *mgr = getOZWManager(); 18 | return this->sendSimpleStatus(mgr->RemoveAssociation(msg["node"].GetUint(), msg["group"].GetUint(), msg["target"].GetString())); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeAssociation.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOVEASSOCIATION_H 2 | #define REMOVEASSOCIATION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RemoveAssociation : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "removeassociation";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RemoveAssociation(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeFailedNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/removeFailedNode.h" 2 | 3 | MqttCommand_RemoveFailedNode::MqttCommand_RemoveFailedNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RemoveFailedNode::Create(QObject *parent) { 9 | return new MqttCommand_RemoveFailedNode(parent); 10 | } 11 | 12 | bool MqttCommand_RemoveFailedNode::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->removeFailedNode(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeFailedNode.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOVEFAILEDNODE_H 2 | #define REMOVEFAILEDNODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RemoveFailedNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "removefailednode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RemoveFailedNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/removeNode.h" 2 | 3 | MqttCommand_RemoveNode::MqttCommand_RemoveNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_RemoveNode::Create(QObject *parent) { 8 | return new MqttCommand_RemoveNode(parent); 9 | } 10 | 11 | bool MqttCommand_RemoveNode::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->removeNode(); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/removeNode.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOVENODE_H 2 | #define REMOVENODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RemoveNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "removenode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RemoveNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/replaceFailedNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/replaceFailedNode.h" 2 | 3 | MqttCommand_ReplaceFailedNode::MqttCommand_ReplaceFailedNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_ReplaceFailedNode::Create(QObject *parent) { 9 | return new MqttCommand_ReplaceFailedNode(parent); 10 | } 11 | 12 | bool MqttCommand_ReplaceFailedNode::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->replaceFailedNode(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/replaceFailedNode.h: -------------------------------------------------------------------------------- 1 | #ifndef REPLACEFAILEDNODE_H 2 | #define REPLACEFAILEDNODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_ReplaceFailedNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "replacefailednode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_ReplaceFailedNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REPLACEFAILEDNODE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestAllConfigParam.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestAllConfigParam.h" 2 | 3 | MqttCommand_RequestAllConfigParam::MqttCommand_RequestAllConfigParam(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RequestAllConfigParam::Create(QObject *parent) { 9 | return new MqttCommand_RequestAllConfigParam(parent); 10 | } 11 | 12 | bool MqttCommand_RequestAllConfigParam::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | mgr->requestAllConfigParam(msg["node"].GetUint()); 18 | return this->sendSimpleStatus(true); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestAllConfigParam.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTALLCONFIGPARAM_H 2 | #define REQUESTALLCONFIGPARAM_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestAllConfigParam : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestallconfigparam";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestAllConfigParam(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REQUESTALLCONFIGPARAM_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestConfigParam.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestConfigParam.h" 2 | 3 | MqttCommand_RequestConfigParam::MqttCommand_RequestConfigParam(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node" << "param"; 7 | } 8 | MqttCommand* MqttCommand_RequestConfigParam::Create(QObject *parent) { 9 | return new MqttCommand_RequestConfigParam(parent); 10 | } 11 | 12 | bool MqttCommand_RequestConfigParam::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | mgr->requestConfigParam(msg["node"].GetUint(), msg["param"].GetUint()); 18 | return this->sendSimpleStatus(true); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestConfigParam.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTCONFIGPARAM_H 2 | #define REQUESTCONFIGPARAM_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestConfigParam : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestconfigparam";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestConfigParam(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNetworkUpdate.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestNetworkUpdate.h" 2 | 3 | MqttCommand_RequestNetworkUpdate::MqttCommand_RequestNetworkUpdate(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RequestNetworkUpdate::Create(QObject *parent) { 9 | return new MqttCommand_RequestNetworkUpdate(parent); 10 | } 11 | 12 | bool MqttCommand_RequestNetworkUpdate::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->requestNetworkUpdate(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNetworkUpdate.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTNETWORKUPDATE_H 2 | #define REQUESTNETWORKUPDATE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestNetworkUpdate : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestnetworkupdate";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestNetworkUpdate(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REQUESTNETWORKUPDATE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeDynamic.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestNodeDynamic.h" 2 | 3 | MqttCommand_RequestNodeDynamic::MqttCommand_RequestNodeDynamic(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RequestNodeDynamic::Create(QObject *parent) { 9 | return new MqttCommand_RequestNodeDynamic(parent); 10 | } 11 | 12 | bool MqttCommand_RequestNodeDynamic::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->requestNodeDynamic(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeDynamic.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTNODEDYNAMIC_H 2 | #define REQUESTNODEDYNAMIC_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestNodeDynamic : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestnodedynamic";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestNodeDynamic(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REQUESTNODEDYNAMIC_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeNeighborUpdate.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestNodeNeighborUpdate.h" 2 | 3 | MqttCommand_RequestNodeNeighborUpdate::MqttCommand_RequestNodeNeighborUpdate(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RequestNodeNeighborUpdate::Create(QObject *parent) { 9 | return new MqttCommand_RequestNodeNeighborUpdate(parent); 10 | } 11 | 12 | bool MqttCommand_RequestNodeNeighborUpdate::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->requestNodeNeighborUpdate(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeNeighborUpdate.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTNODENEIGHBORUPDATE_H 2 | #define REQUESTNODENEIGHBORUPDATE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestNodeNeighborUpdate : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestnodeneighborupdate";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestNodeNeighborUpdate(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REQUESTNODENEIGHBORUPDATE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeState.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/requestNodeState.h" 2 | 3 | MqttCommand_RequestNodeState::MqttCommand_RequestNodeState(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_RequestNodeState::Create(QObject *parent) { 9 | return new MqttCommand_RequestNodeState(parent); 10 | } 11 | 12 | bool MqttCommand_RequestNodeState::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->requestNodeState(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/requestNodeState.h: -------------------------------------------------------------------------------- 1 | #ifndef REQUESTNODESTATE_H 2 | #define REQUESTNODESTATE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_RequestNodeState : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "requestnodestate";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_RequestNodeState(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // REQUESTNODESTATE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/sendNodeInformation.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/sendNodeInformation.h" 2 | 3 | MqttCommand_SendNodeInformation::MqttCommand_SendNodeInformation(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_SendNodeInformation::Create(QObject *parent) { 9 | return new MqttCommand_SendNodeInformation(parent); 10 | } 11 | 12 | bool MqttCommand_SendNodeInformation::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | return this->sendSimpleStatus(mgr->sendNodeInformation(msg["node"].GetUint())); 18 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/sendNodeInformation.h: -------------------------------------------------------------------------------- 1 | #ifndef SENTNODEINFORMATION_H 2 | #define SENTNODEINFORMATION_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_SendNodeInformation : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "sendnodeinformation";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_SendNodeInformation(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/setPollInterval.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/setPollInterval.h" 2 | 3 | MqttCommand_SetPollInterval::MqttCommand_SetPollInterval(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "interval"; 7 | this->m_requiredBoolFields << "intervalBetweenPoll"; 8 | } 9 | MqttCommand* MqttCommand_SetPollInterval::Create(QObject *parent) { 10 | return new MqttCommand_SetPollInterval(parent); 11 | } 12 | 13 | bool MqttCommand_SetPollInterval::processMessage(rapidjson::Document &msg) { 14 | QTOZWManager *mgr = getOZWManager(); 15 | mgr->setPollInterval(msg["interval"].GetUint(), msg["intervalBetweenPoll"].GetBool()); 16 | return this->sendSimpleStatus(true); 17 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/setPollInterval.h: -------------------------------------------------------------------------------- 1 | #ifndef SETPOLLINTERVAL_H 2 | #define SETPOLLINTERVAL_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_SetPollInterval : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "setpollinterval";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_SetPollInterval(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // SETPOLLINTERVAL_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/setValue.h: -------------------------------------------------------------------------------- 1 | #ifndef SETVALUE_H 2 | #define SETVALUE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_SetValue : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "setvalue";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_SetValue(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // SETVALUE_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/softResetController.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/softResetController.h" 2 | 3 | MqttCommand_SoftResetController::MqttCommand_SoftResetController(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | } 7 | MqttCommand* MqttCommand_SoftResetController::Create(QObject *parent) { 8 | return new MqttCommand_SoftResetController(parent); 9 | } 10 | 11 | bool MqttCommand_SoftResetController::processMessage(rapidjson::Document &msg) { 12 | Q_UNUSED(msg); 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->softResetController(); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/softResetController.h: -------------------------------------------------------------------------------- 1 | #ifndef SOFTRESETCONTROLLER_H 2 | #define SOFTRESETCONTROLLER_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_SoftResetController : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "softresetcontroller";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_SoftResetController(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // SOFTRESETCONTROLLER_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/syncroniseNodeNeighbors.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/syncroniseNodeNeighbors.h" 2 | 3 | MqttCommand_SyncroniseNodeNeighbors::MqttCommand_SyncroniseNodeNeighbors(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node"; 7 | } 8 | MqttCommand* MqttCommand_SyncroniseNodeNeighbors::Create(QObject *parent) { 9 | return new MqttCommand_SyncroniseNodeNeighbors(parent); 10 | } 11 | 12 | bool MqttCommand_SyncroniseNodeNeighbors::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | 17 | QTOZWManager *mgr = getOZWManager(); 18 | mgr->syncroniseNodeNeighbors(msg["node"].GetInt()); 19 | return this->sendSimpleStatus(true); 20 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/syncroniseNodeNeighbors.h: -------------------------------------------------------------------------------- 1 | #ifndef SYNCNODENEIGHBORS_H 2 | #define SYNCNODENEIGHBORS_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_SyncroniseNodeNeighbors : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "syncronisenodeneighbors";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_SyncroniseNodeNeighbors(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // SYNCNODENEIGHBORS_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/testNetwork.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/testNetwork.h" 2 | 3 | MqttCommand_TestNetwork::MqttCommand_TestNetwork(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "count"; 7 | } 8 | MqttCommand* MqttCommand_TestNetwork::Create(QObject *parent) { 9 | return new MqttCommand_TestNetwork(parent); 10 | } 11 | 12 | bool MqttCommand_TestNetwork::processMessage(rapidjson::Document &msg) { 13 | QTOZWManager *mgr = getOZWManager(); 14 | mgr->testNetwork(msg["count"].GetUint()); 15 | return this->sendSimpleStatus(true); 16 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/testNetwork.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTNETWORK_H 2 | #define TESTNETWORK_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_TestNetwork : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "testnetwork";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_TestNetwork(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // TESTNETWORK_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/testNetworkNode.cpp: -------------------------------------------------------------------------------- 1 | #include "mqttcommands/testNetworkNode.h" 2 | 3 | MqttCommand_TestNetworkNode::MqttCommand_TestNetworkNode(QObject *parent) : 4 | MqttCommand(parent) 5 | { 6 | this->m_requiredIntFields << "node" << "count"; 7 | } 8 | MqttCommand* MqttCommand_TestNetworkNode::Create(QObject *parent) { 9 | return new MqttCommand_TestNetworkNode(parent); 10 | } 11 | 12 | bool MqttCommand_TestNetworkNode::processMessage(rapidjson::Document &msg) { 13 | if (!this->checkNode(msg, "node")) { 14 | return this->sendSimpleStatus(false, "Invalid Node Number"); 15 | } 16 | QTOZWManager *mgr = getOZWManager(); 17 | mgr->testNetworkNode(msg["node"].GetUint64(), msg["count"].GetUint()); 18 | return this->sendSimpleStatus(true); 19 | } -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttcommands/testNetworkNode.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTNETWORKNODE_H 2 | #define TESTNETWORKNODE_H 3 | 4 | #include "mqttcommands/mqttcommands.h" 5 | 6 | class MqttCommand_TestNetworkNode : public MqttCommand { 7 | Q_OBJECT 8 | public: 9 | static MqttCommand *Create(QObject *parent = nullptr); 10 | static QString StaticGetCommand() { return "testnetworknode";}; 11 | QString GetCommand() override { return StaticGetCommand(); }; 12 | bool processMessage(rapidjson::Document &) override; 13 | private: 14 | MqttCommand_TestNetworkNode(QObject *parent = nullptr); 15 | }; 16 | 17 | #endif // PING_H -------------------------------------------------------------------------------- /qt-ozwdaemon/mqttpublisher.h: -------------------------------------------------------------------------------- 1 | #ifndef MQTTPUBLISHER_H 2 | #define MQTTPUBLISHER_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "qtozwdaemon.h" 11 | #include "mqttNodes.h" 12 | #include "mqttValues.h" 13 | #include "mqttAssociations.h" 14 | #include "mqttcommands/mqttcommands.h" 15 | 16 | class MqttCommands; 17 | 18 | #define MQTT_OZW_TOP_TOPIC "OpenZWave/%1/" 19 | #define MQTT_OZW_STATS_TOPIC "statistics/" 20 | #define MQTT_OZW_STATS_NODE_TOPIC "node/%1/statistics/" 21 | #define MQTT_OZW_STATUS_TOPIC "status/" 22 | #define MQTT_OZW_NODE_TOPIC "node/%1/" 23 | #define MQTT_OZW_INSTANCE_TOPIC "node/%1/instance/%2/" 24 | #define MQTT_OZW_VID_TOPIC "node/%1/instance/%2/commandclass/%3/value/%4/" 25 | #define MQTT_OZW_COMMANDCLASS_TOPIC "node/%1/instance/%2/commandclass/%3/" 26 | #define MQTT_OZW_ASSOCIATION_TOPIC "node/%1/association/%2/" 27 | #define MQTT_OZW_COMMAND_TOPIC "command/%1/" 28 | #define MQTT_OZW_RESPONSE_TOPIC "event/%1/" 29 | 30 | 31 | class mqttpublisher : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | Q_PROPERTY(bool ready READ isReady WRITE setReady NOTIFY readyChanged); 36 | 37 | explicit mqttpublisher(QSettings *setting, QObject *parent = nullptr); 38 | ~mqttpublisher(); 39 | void setOZWDaemon(qtozwdaemon *ozwdaemon); 40 | QTOZWManager *getQTOZWManager(); 41 | bool sendCommandUpdate(QString, rapidjson::Document &); 42 | bool sendAssociationUpdate(quint8 node, quint8 group, rapidjson::Document &js); 43 | bool isValidNode(quint8 node); 44 | bool isValidValueID(quint64 vidKey); 45 | QVariant getValueData(quint64, mqttValueIDModel::ValueIdColumns); 46 | bool setValue(quint64, QVariant); 47 | bool isReady(); 48 | void setReady(bool ready); 49 | signals: 50 | void readyChanged(bool ready); 51 | 52 | public slots: 53 | void ready(bool); 54 | void valueAdded(quint64 vidKey); 55 | void valueRemoved(quint64 vidKey); 56 | void valueChanged(quint64 vidKey); 57 | void valueRefreshed(quint64 vidKey); 58 | void nodeNew(quint8 node); 59 | void nodeAdded(quint8 node); 60 | void nodeRemoved(quint8 node); 61 | void nodeReset(quint8 node); 62 | void nodeNaming(quint8 node); 63 | void nodeEvent(quint8 node, quint8 event); 64 | void nodeProtocolInfo(quint8 node); 65 | void nodeEssentialNodeQueriesComplete(quint8 node); 66 | void nodeQueriesComplete(quint8 node); 67 | void nodeGroupChanged(quint8 node, quint8 group); 68 | void driverReady(quint32 homeID); 69 | void driverFailed(quint32 homeID); 70 | void driverReset(quint32 homeID); 71 | void driverRemoved(quint32 homeID); 72 | void driverAllNodesQueriedSomeDead(); 73 | void driverAllNodesQueried(); 74 | void driverAwakeNodesQueried(); 75 | void controllerCommand(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error); 76 | void ozwNotification(quint8 node, NotificationTypes::QTOZW_Notification_Code event); 77 | void ozwUserAlert(quint8 node, NotificationTypes::QTOZW_Notification_User event, quint8 retry); 78 | void manufacturerSpecificDBReady(); 79 | 80 | void starting(); 81 | void started(quint32 homeID); 82 | void stopped(quint32 homeID); 83 | // void error(QTOZWErrorCodes errorcode); 84 | 85 | private slots: 86 | void updateLogStateChange(); 87 | void brokerDisconnected(); 88 | void doStats(); 89 | void cleanTopics(QMqttMessage msg); 90 | void brokerError(QMqttClient::ClientError error); 91 | 92 | private: 93 | 94 | QString getTopic(QString); 95 | QString getNodeTopic(QString, quint8); 96 | QString getInstanceTopic(QString, quint8, quint8); 97 | QString getCommandClassTopic(QString, quint8, quint8, quint8); 98 | QString getValueTopic(QString, quint8, quint8, quint8, quint64); 99 | QString getAssociationTopic(quint8, quint8); 100 | QString getCommandTopic(); 101 | QString getCommandResponseTopic(QString); 102 | bool sendStatusUpdate(); 103 | bool clearStatusUpdate(); 104 | bool sendNodeUpdate(quint8); 105 | bool sendValueUpdate(quint64); 106 | bool sendInstanceUpdate(quint8, quint8); 107 | bool sendCommandClassUpdate(quint8, quint8, quint8); 108 | 109 | bool delNodeTopic(quint8); 110 | bool delValueTopic(quint64); 111 | bool delInstanceTopic(quint8, quint8); 112 | bool delCommandClassTopic(quint8, quint8, quint8); 113 | bool delAssociationTopic(quint8, quint8); 114 | rapidjson::Document *getInstanceJSON(quint8, quint8); 115 | rapidjson::Document *getCommandClassJSON(quint8, quint8, quint8); 116 | 117 | rapidjson::Document m_ozwstatus; 118 | QMap m_nodes; 119 | QMap > m_instances; 120 | QMap > > m_CommandClasses; 121 | QMap > m_assoications; 122 | mqttNodeModel *m_nodeModel; 123 | QMap m_values; 124 | mqttValueIDModel *m_valueModel; 125 | mqttAssociationModel *m_assocModel; 126 | 127 | QMqttClient *m_client; 128 | qtozwdaemon *m_qtozwdaemon; 129 | QSettings *settings; 130 | QTimer m_statsTimer; 131 | MqttCommands *m_commands; 132 | QMqttSubscription *m_cleanTopicSubscription; 133 | QDateTime m_currentStartTime; 134 | bool m_ready; 135 | bool m_uncleanshutdown; 136 | }; 137 | 138 | #endif // MQTTPUBLISHER_H 139 | -------------------------------------------------------------------------------- /qt-ozwdaemon/qtozwdaemon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef _WIN32 3 | #include 4 | #include 5 | #endif 6 | 7 | #include "qtozwdaemon.h" 8 | 9 | Q_DECLARE_LOGGING_CATEGORY(ozwdaemon); 10 | 11 | #ifndef _WIN32 12 | int qtozwdaemon::sigtermFd[2] = {0, 0}; 13 | #endif 14 | 15 | qtozwdaemon::qtozwdaemon(QString configPath, QString userPath, QObject *parent) : 16 | QObject(parent), 17 | m_configPath(configPath), 18 | m_userPath(userPath) 19 | { 20 | 21 | #ifndef _WIN32 22 | if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd)) 23 | qCCritical(ozwdaemon) << "Couldn't create TERM socketpair"; 24 | snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this); 25 | connect(snTerm, SIGNAL(activated(int)), this, SLOT(handleSigTerm())); 26 | #endif 27 | 28 | 29 | QRegularExpression re("^(0[xX][a-fA-F0-9]{2}[ ,]*){16}$"); 30 | 31 | QString NetworkKeyTest = qgetenv("OZW_NETWORK_KEY"); 32 | QString NetworkKey; 33 | QRegularExpressionMatch match = re.match(NetworkKeyTest); 34 | if (match.hasMatch()) { 35 | NetworkKey = NetworkKeyTest; 36 | qCInfo(ozwdaemon) << "Network Key Specified in Enviroment is Valid"; 37 | } else { 38 | qCWarning(ozwdaemon) << "Network Key Specified in Enviroment is Invalid"; 39 | } 40 | 41 | QFile nwk_file("/run/secrets/OZW_Network_Key"); 42 | if (nwk_file.open(QIODevice::ReadOnly | QIODevice::Text)) { 43 | NetworkKeyTest = nwk_file.readLine().trimmed(); 44 | nwk_file.close(); 45 | match = re.match(NetworkKeyTest); 46 | if (match.hasMatch()) { 47 | NetworkKey = NetworkKeyTest; 48 | qCInfo(ozwdaemon) << "Network Key From File is Valid - Using File"; 49 | } else { 50 | if (NetworkKey.isEmpty()) { 51 | qCWarning(ozwdaemon) << "Network Key From File in Invalid - No Valid Network Key Found in Enviroment or File"; 52 | } 53 | } 54 | } else { 55 | qCInfo(ozwdaemon) << "Didn't Find Network Key File. Skipping"; 56 | } 57 | if (!NetworkKey.isEmpty()) { 58 | qCInfo(ozwdaemon) << "We Have what appears to be a valid Network Key - Passing to OZW"; 59 | } 60 | 61 | QString AuthKey = qgetenv("OZW_AUTH_KEY"); 62 | 63 | QFile ak_file("/run/secrets/OZW_Auth_Key"); 64 | if (ak_file.open(QIODevice::ReadOnly | QIODevice::Text)) { 65 | AuthKey = ak_file.readLine().trimmed(); 66 | ak_file.close(); 67 | } else { 68 | qCInfo(ozwdaemon) << "Didn't Find Auth Key File. Skipping"; 69 | } 70 | if (!AuthKey.isEmpty()) { 71 | qCInfo(ozwdaemon) << "Using Remote Authentication Key"; 72 | } 73 | QFileInfo cfgDir(this->getConfigPath()); 74 | QFileInfo userDir(this->getUserPath()); 75 | 76 | this->m_openzwave = new QTOpenZwave(this, cfgDir.absoluteFilePath(), userDir.absoluteFilePath()); 77 | this->m_qtozwmanager = this->m_openzwave->GetManager(); 78 | 79 | connect(this->m_qtozwmanager, &QTOZWManager::readyChanged, this, &qtozwdaemon::QTOZW_Ready); 80 | connect(this->m_qtozwmanager, &QTOZWManager::nodeQueriesComplete, this, &qtozwdaemon::nodeQueriesComplete); 81 | 82 | this->m_qtozwmanager->initilizeSource(true); 83 | if (!NetworkKey.isEmpty()) { 84 | this->m_qtozwmanager->getOptions()->setNetworkKey(NetworkKey); 85 | } 86 | if (!AuthKey.isEmpty()) { 87 | this->m_qtozwmanager->setClientAuth(AuthKey); 88 | } 89 | } 90 | 91 | void qtozwdaemon::QTOZW_Ready(bool ready) { 92 | if (ready) qCDebug(ozwdaemon) << "Ready"; 93 | } 94 | void qtozwdaemon::startOZW() { 95 | if (getSerialPort().size() == 0) { 96 | qCWarning(ozwdaemon) << "Serial Port is not Set"; 97 | return; 98 | } 99 | this->m_qtozwmanager->open(this->getSerialPort()); 100 | } 101 | 102 | QTOZWManager *qtozwdaemon::getManager() { 103 | return this->m_qtozwmanager; 104 | } 105 | 106 | QTOpenZwave *qtozwdaemon::getQTOpenZWave() { 107 | return this->m_openzwave; 108 | } 109 | 110 | void qtozwdaemon::termSignalHandler(int unused) { 111 | #ifndef _WIN32 112 | Q_UNUSED(unused); 113 | char a = 1; 114 | ::write(sigtermFd[0], &a, sizeof(a)); 115 | #endif 116 | } 117 | 118 | void qtozwdaemon::handleSigTerm() 119 | { 120 | #ifndef _WIN32 121 | snTerm->setEnabled(false); 122 | char tmp; 123 | ::read(sigtermFd[1], &tmp, sizeof(tmp)); 124 | qCInfo(ozwdaemon) << "Recieved SIGTERM: Shutting down ozwdaemon"; 125 | this->m_qtozwmanager->close(); 126 | QCoreApplication::exit(qtozwdaemon::EXIT_NORMAL); 127 | snTerm->setEnabled(true); 128 | #endif 129 | } 130 | 131 | void qtozwdaemon::aboutToQuit() { 132 | this->m_qtozwmanager->close(); 133 | } 134 | 135 | void qtozwdaemon::nodeQueriesComplete(quint8 node) { 136 | static QVector s_completedNodes; 137 | if (this->m_qtozwmanager->getControllerNodeId() != node) { 138 | /* Also Refresh out Configuration CC Values when starting up */ 139 | if (!s_completedNodes.contains(node)) { 140 | this->m_qtozwmanager->requestAllConfigParam(node); 141 | s_completedNodes.append(node); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /qt-ozwdaemon/qtozwdaemon.h: -------------------------------------------------------------------------------- 1 | #ifndef QTOZWDAEMON_H 2 | #define QTOZWDAEMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | #include 10 | #include 11 | 12 | class qtozwdaemon : public QObject 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(QString serialPort READ getSerialPort WRITE setSerialPort); 16 | Q_PROPERTY(QString configPath READ getConfigPath WRITE setConfigPath); 17 | Q_PROPERTY(QString userPath READ getUserPath WRITE setUserPath); 18 | public: 19 | enum ExitCodes { 20 | EXIT_NORMAL = 0, 21 | EXIT_NOMQTTPASS = -1, 22 | EXIT_ANOTHERINSTANCE = -2, 23 | EXIT_MQTTDISCONNECTED = -3, 24 | EXIT_OZWFAILED = -4, 25 | EXIT_SETUPFAILED = -5, 26 | EXIT_CRASH = -6 27 | }; 28 | Q_ENUM(ExitCodes); 29 | 30 | explicit qtozwdaemon(QString configPath = QString(), QString userPath = QString(), QObject *parent = nullptr); 31 | QString getSerialPort() { return this->m_serialPort; } 32 | void setSerialPort(QString serialPort) { this->m_serialPort = serialPort;} 33 | void startOZW(); 34 | QTOZWManager *getManager(); 35 | QTOpenZwave *getQTOpenZWave(); 36 | static void termSignalHandler(int unused); 37 | QString getConfigPath() { return this->m_configPath; } 38 | QString getUserPath() { return this->m_userPath; } 39 | signals: 40 | 41 | public slots: 42 | void QTOZW_Ready(bool ready); 43 | void handleSigTerm(); 44 | void aboutToQuit(); 45 | void setConfigPath(QString configPath) { this->m_configPath = configPath; } 46 | void setUserPath(QString userPath) { this->m_userPath = userPath; } 47 | void nodeQueriesComplete(quint8 node); 48 | 49 | 50 | private: 51 | QTOpenZwave *m_openzwave; 52 | QTOZWManager *m_qtozwmanager; 53 | QString m_serialPort; 54 | static int sigtermFd[2]; 55 | QSocketNotifier *snTerm; 56 | QString m_configPath; 57 | QString m_userPath; 58 | }; 59 | 60 | #endif // QTOZWDAEMON_H 61 | -------------------------------------------------------------------------------- /qt-ozwdaemon/qtrj.h: -------------------------------------------------------------------------------- 1 | #ifndef QTRJ_H 2 | #define QTRJ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QT2JS { 9 | public: 10 | static bool SetString(rapidjson::Document &, QString, QString); 11 | static bool SetInt(rapidjson::Document &, QString, qint32); 12 | static bool SetUint(rapidjson::Document &, QString, quint32); 13 | static bool SetInt64(rapidjson::Document &, QString, qint64); 14 | static bool SetUInt64(rapidjson::Document &, QString, quint64); 15 | static bool SetBool(rapidjson::Document &, QString, bool); 16 | static bool SetDouble(rapidjson::Document &, QString, double); 17 | static QByteArray getJSON(rapidjson::Document &); 18 | static bool removeField(rapidjson::Document &, QString); 19 | }; 20 | 21 | 22 | #endif // QTRJ_H -------------------------------------------------------------------------------- /qt-ozwdaemon/res/ozw_SF2_notext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-ozwdaemon/res/ozw_SF2_notext.png -------------------------------------------------------------------------------- /qt-ozwdaemon/res/ozw_logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-ozwdaemon/res/ozw_logo.icns -------------------------------------------------------------------------------- /qt-ozwdaemon/res/ozw_logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-ozwdaemon/res/ozw_logo.ico -------------------------------------------------------------------------------- /qt-simpleclient/bitsetwidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "bitsetwidget.h" 5 | #include "ui_bitsetwidget.h" 6 | 7 | BitSetWidget::BitSetWidget(QWidget *parent) : 8 | QFrame(parent), 9 | ui(new Ui::BitSetWidget) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | BitSetWidget::~BitSetWidget() 15 | { 16 | delete ui; 17 | } 18 | 19 | void BitSetWidget::setValue(QTOZW_ValueIDBitSet value) { 20 | this->m_value = value; 21 | for (uint8_t i = 0; i <= this->m_value.values.size() -1; ++i) { 22 | if (this->m_value.mask.at(i)) { 23 | QCheckBox *cb = new QCheckBox(this); 24 | cb->setText(this->m_value.label[i]); 25 | cb->setChecked(this->m_value.values.at(i)); 26 | cb->setToolTip(this->m_value.help[i]); 27 | cb->setProperty("BitSetIndex", i); 28 | QObject::connect(cb, &QCheckBox::stateChanged, this, &BitSetWidget::cbChanged); 29 | this->ui->gridLayout_2->addWidget(cb); 30 | } 31 | } 32 | } 33 | 34 | void BitSetWidget::cbChanged() { 35 | QCheckBox *cb = qobject_cast(sender()); 36 | if (!cb) 37 | throw std::logic_error("Widget is not of Type QCheckBox"); 38 | int index = cb->property("BitSetIndex").toInt(); 39 | if (this->m_value.values.at(index) != cb->isChecked()) 40 | this->m_value.values[index] = cb->isChecked(); 41 | emit stateChanged(); 42 | } 43 | 44 | QTOZW_ValueIDBitSet BitSetWidget::getValue() { 45 | return this->m_value; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /qt-simpleclient/bitsetwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef BITSETWIDGET_H 2 | #define BITSETWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class BitSetWidget; 9 | } 10 | 11 | class BitSetWidget : public QFrame 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit BitSetWidget(QWidget *parent = nullptr); 17 | ~BitSetWidget(); 18 | void setValue(QTOZW_ValueIDBitSet); 19 | QTOZW_ValueIDBitSet getValue(); 20 | 21 | Q_SIGNALS: 22 | void stateChanged(); 23 | 24 | private Q_SLOTS: 25 | void cbChanged(); 26 | 27 | private: 28 | Ui::BitSetWidget *ui; 29 | QTOZW_ValueIDBitSet m_value; 30 | }; 31 | 32 | #endif // BITSETWIDGET_H 33 | -------------------------------------------------------------------------------- /qt-simpleclient/bitsetwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | BitSetWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 640 10 | 480 11 | 12 | 13 | 14 | Frame 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /qt-simpleclient/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2017 Ford Motor Company 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the QtRemoteObjects module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** BSD License Usage 18 | ** Alternatively, you may use this file under the terms of the BSD license 19 | ** as follows: 20 | ** 21 | ** "Redistribution and use in source and binary forms, with or without 22 | ** modification, are permitted provided that the following conditions are 23 | ** met: 24 | ** * Redistributions of source code must retain the above copyright 25 | ** notice, this list of conditions and the following disclaimer. 26 | ** * Redistributions in binary form must reproduce the above copyright 27 | ** notice, this list of conditions and the following disclaimer in 28 | ** the documentation and/or other materials provided with the 29 | ** distribution. 30 | ** * Neither the name of The Qt Company Ltd nor the names of its 31 | ** contributors may be used to endorse or promote products derived 32 | ** from this software without specific prior written permission. 33 | ** 34 | ** 35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46 | ** 47 | ** $QT_END_LICENSE$ 48 | ** 49 | ****************************************************************************/ 50 | 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | #include "qt-openzwave/qtozwmanager.h" 57 | 58 | #include "mainwindow.h" 59 | 60 | 61 | 62 | int main(int argc, char **argv) 63 | { 64 | 65 | #if 1 66 | QLoggingCategory::setFilterRules("qt.remoteobjects.debug=true\n" 67 | "qt.remoteobjects.warning=true\n" 68 | "qt.remoteobjects.models.debug=true\n" 69 | "qt.remoteobjects.models.debug=true\n" 70 | "qt.remoteobjects.io.debug=true\n" 71 | "default.debug=true"); 72 | #else 73 | QLoggingCategory::setFilterRules("default.debug=true\n" 74 | "qt.modeltest.debug=false"); 75 | #endif 76 | QApplication app(argc, argv); 77 | QIcon icon(":res/ozw_SF2_notext.png"); 78 | MainWindow window; 79 | window.setWindowIcon(icon); 80 | window.resize(640, 480); 81 | window.show(); 82 | window.start(); 83 | 84 | return app.exec(); 85 | } 86 | -------------------------------------------------------------------------------- /qt-simpleclient/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MainWindow; 9 | } 10 | 11 | class MainWindow : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWindow(QWidget *parent = nullptr); 17 | ~MainWindow(); 18 | void start(); 19 | 20 | public Q_SLOTS: 21 | void startRemote(QString); 22 | void startLocal(QString, bool); 23 | void QTOZW_Ready(); 24 | void valueAdded(quint64 vidKey); 25 | void valueRemoved(quint64 vidKey); 26 | void valueChanged(quint64 vidKey); 27 | void valueRefreshed(quint64 vidKey); 28 | void nodeNew(quint8 node); 29 | void nodeAdded(quint8 node); 30 | void nodeRemoved(quint8 node); 31 | void nodeReset(quint8 node); 32 | void nodeNaming(quint8 node); 33 | void nodeEvent(quint8 node, quint8 event); 34 | void nodeProtocolInfo(quint8 node); 35 | void nodeEssentialNodeQueriesComplete(quint8 node); 36 | void nodeQueriesComplete(quint8 node); 37 | void driverReady(quint32 homeID); 38 | void driverFailed(quint32 homeID); 39 | void driverReset(quint32 homeID); 40 | void driverRemoved(quint32 homeID); 41 | void driverAllNodesQueriedSomeDead(); 42 | void driverAllNodesQueried(); 43 | void driverAwakeNodesQueried(); 44 | void controllerCommand(quint8 command); 45 | // void ozwNotification(OpenZWave::Notification::NotificationCode event); 46 | // void ozwUserAlert(OpenZWave::Notification::UserAlertNotification event); 47 | void manufacturerSpecificDBReady(); 48 | 49 | void starting(); 50 | void started(quint32 homeID); 51 | void stopped(quint32 homeID); 52 | // void error(QTOZWErrorCodes errorcode); 53 | 54 | 55 | 56 | private: 57 | Ui::MainWindow *ui; 58 | QTOpenZwave *m_openzwave; 59 | QTOZWManager *m_qtozwmanager; 60 | QString m_serialPort; 61 | }; 62 | 63 | #endif // MAINWINDOW_H 64 | -------------------------------------------------------------------------------- /qt-simpleclient/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 640 10 | 480 11 | 12 | 13 | 14 | OpenZWave Sample Client 15 | 16 | 17 | 18 | :/res/ozw_SF2_notext.png:/res/ozw_SF2_notext.png 19 | 20 | 21 | 22 | 23 | 0 24 | 25 | 26 | 0 27 | 28 | 29 | 0 30 | 31 | 32 | 0 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 0 42 | 2 43 | 44 | 45 | 46 | 0 47 | 48 | 49 | 50 | User 51 | 52 | 53 | 54 | 0 55 | 56 | 57 | 0 58 | 59 | 60 | 0 61 | 62 | 63 | 0 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | System 73 | 74 | 75 | 76 | 0 77 | 78 | 79 | 0 80 | 81 | 82 | 0 83 | 84 | 85 | 0 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | Config 95 | 96 | 97 | 98 | 0 99 | 100 | 101 | 0 102 | 103 | 104 | 0 105 | 106 | 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | Associations 117 | 118 | 119 | 120 | 0 121 | 122 | 123 | 0 124 | 125 | 126 | 0 127 | 128 | 129 | 0 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 0 144 | 0 145 | 640 146 | 22 147 | 148 | 149 | 150 | 151 | &File 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | E&xit 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /qt-simpleclient/qt-simpleclient.pro: -------------------------------------------------------------------------------- 1 | 2 | QT += widgets remoteobjects testlib websockets 3 | 4 | TARGET = ../simpleclient 5 | 6 | #CONFIG += silent 7 | DEFINES += remote 8 | 9 | #unix { 10 | # QMAKE_POST_LINK += "if [ ! -e config ]; then ln -s $$OZW_LIB_PATH/config config; fi" 11 | #} 12 | 13 | win32 { 14 | RC_ICONS += res/ozw_logo.ico 15 | } 16 | FORMS += \ 17 | bitsetwidget.ui \ 18 | mainwindow.ui \ 19 | startup.ui 20 | 21 | SOURCES = main.cpp \ 22 | bitsetwidget.cpp \ 23 | mainwindow.cpp \ 24 | qtozw_itemdelegate.cpp \ 25 | startup.cpp 26 | 27 | HEADERS += \ 28 | bitsetwidget.h \ 29 | mainwindow.h \ 30 | qtozw_itemdelegate.h \ 31 | startup.h 32 | 33 | RESOURCES += \ 34 | simpleclient.qrc 35 | 36 | include(../qt-openzwave.pri) 37 | 38 | unix { 39 | LIBS += -lresolv -L../qt-openzwave/ -lqt-openzwave 40 | QMAKE_CXXFLAGS += -Wno-deprecated-copy 41 | qtConfig(static) { 42 | QMAKE_LFLAGS += -static-libgcc 43 | LIBS += -lopenzwave -Wl,--allow-multiple-definition 44 | # this is a static build 45 | } 46 | } 47 | win32 { 48 | LIBS += -lDnsapi -L../qt-openzwave/$$BUILDTYPE/ -lqt-openzwave1 49 | } 50 | 51 | INCLUDEPATH += ../qt-openzwave/include/ 52 | 53 | macx { 54 | ICON = res/ozw_logo.icns 55 | LIBOZW.files = ../../open-zwave/libopenzwave-1.6.dylib ../qt-openzwave/libqt-openzwave.1.dylib 56 | LIBOZW.path = Contents/Frameworks/ 57 | QMAKE_BUNDLE_DATA += BUNDLE LIBOZW 58 | #QMAKE_POST_LINK=$$top_srcdir/updaterpath.sh $(TARGET) 59 | } 60 | -------------------------------------------------------------------------------- /qt-simpleclient/qtozw_itemdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef QTOZW_ITEMDELEGATE_H 2 | #define QTOZW_ITEMDELEGATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QTOZW_ItemDelegate : public QStyledItemDelegate 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit QTOZW_ItemDelegate(QObject *parent = nullptr); 14 | virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 15 | virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 16 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 17 | void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 18 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 19 | void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; 20 | 21 | 22 | private slots: 23 | void commitAndCloseEditor(); 24 | }; 25 | 26 | #endif // QTOZW_ITEMDELEGATE_H 27 | -------------------------------------------------------------------------------- /qt-simpleclient/res/ozw_SF2_notext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-simpleclient/res/ozw_SF2_notext.png -------------------------------------------------------------------------------- /qt-simpleclient/res/ozw_logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-simpleclient/res/ozw_logo.icns -------------------------------------------------------------------------------- /qt-simpleclient/res/ozw_logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZWave/qt-openzwave/7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef/qt-simpleclient/res/ozw_logo.ico -------------------------------------------------------------------------------- /qt-simpleclient/simpleclient.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/ozw_logo.icns 4 | res/ozw_logo.ico 5 | res/ozw_SF2_notext.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /qt-simpleclient/startup.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "startup.h" 4 | #include "ui_startup.h" 5 | 6 | 7 | Startup::Startup(QWidget *parent) : 8 | QDialog(parent), 9 | ui(new Ui::Startup) 10 | { 11 | ui->setupUi(this); 12 | 13 | QObject::connect(ui->startlocal, &QPushButton::clicked, this, &Startup::localPressed); 14 | QObject::connect(ui->startremote, &QPushButton::clicked, this, &Startup::remotePressed); 15 | 16 | } 17 | 18 | Startup::~Startup() 19 | { 20 | delete ui; 21 | } 22 | 23 | void Startup::localPressed() { 24 | QString serialport = ui->serialport->text(); 25 | if (serialport.length() == 0) { 26 | QMessageBox::critical(this, tr("Error"), tr("You Must Specify a Serial Port"), QMessageBox::Ok); 27 | } 28 | emit this->startLocal(serialport, ui->enableserver->isChecked()); 29 | this->close(); 30 | } 31 | void Startup::remotePressed() { 32 | QString remotehost = ui->remotehost->text(); 33 | if (remotehost.length() == 0) { 34 | QMessageBox::critical(this, tr("Error"), tr("You Must Specify a Remote Host"), QMessageBox::Ok); 35 | } 36 | emit this->startRemote(remotehost); 37 | this->close(); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /qt-simpleclient/startup.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUP_H 2 | #define STARTUP_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace Ui { 9 | class Startup; 10 | } 11 | 12 | class Startup : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public Q_SLOTS: 17 | void localPressed(); 18 | void remotePressed(); 19 | 20 | Q_SIGNALS: 21 | void startLocal(QString, bool); 22 | void startRemote(QString); 23 | 24 | public: 25 | explicit Startup(QWidget *parent = nullptr); 26 | ~Startup(); 27 | 28 | 29 | private: 30 | Ui::Startup *ui; 31 | }; 32 | 33 | #endif // STARTUP_H 34 | -------------------------------------------------------------------------------- /qt-simpleclient/startup.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Startup 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Lets Get Started! 15 | 16 | 17 | 18 | 19 | 20 | Local Client 21 | 22 | 23 | 24 | 25 | 26 | Serial Port 27 | 28 | 29 | 30 | 31 | 32 | 33 | Enable Server 34 | 35 | 36 | 37 | 38 | 39 | 40 | Enabled 41 | 42 | 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | Start 51 | 52 | 53 | 54 | 55 | 56 | 57 | /dev/cu.usbmodem14101 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Remote Client 68 | 69 | 70 | 71 | 72 | 73 | Remote Host 74 | 75 | 76 | 77 | 78 | 79 | 80 | 127.0.0.1 81 | 82 | 83 | 84 | 85 | 86 | 87 | Start 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /setenv.sh: -------------------------------------------------------------------------------- 1 | export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:`pwd`/qt-openzwave" 2 | export LD_LIBRARY_PATH="../open-zwave/:./qt-openzwave/:./qt-openzwavedatabase/" 3 | -------------------------------------------------------------------------------- /tools/sentry-upload-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | EXECUTABLE=$1 3 | 4 | if [ -z $EXECUTABLE ] 5 | then 6 | echo "Please Supply a Executable to process" 7 | exit -1 8 | fi 9 | 10 | if [ -z $SENTRY_TOKEN ] 11 | then 12 | echo "Please Set the SENTRY_TOKEN enviroment variable" 13 | exit -1 14 | fi 15 | echo "deb http://deb.debian.org/debian-debug/ buster-debug main" > /etc/apt/sources.list.d/debug.list 16 | if [ ! -f /usr/local/bin/sentry-cli ]; then 17 | apt-get update 18 | apt-get install -y curl elfutils debian-goodies 19 | for i in `find-dbgsym-packages $EXECUTABLE`; do 20 | apt-get install -y $i 21 | done 22 | ARCH=`uname -m` 23 | if [ "$ARCH" == "aarch64" ]; then 24 | echo "Installing sentry-cli for arm64" 25 | curl http://bamboo.my-ho.st/bamboo/browse/INFRA-SCL/latest/artifact/shared/sentry-cli-arm64/sentry-cli -o /usr/local/bin/sentry-cli 26 | chmod +x /usr/local/bin/sentry-cli 27 | elif [ "$ARCH" == "armv7l" ]; then 28 | echo "Installing sentry-cli for armhf" 29 | curl http://bamboo.my-ho.st/bamboo/browse/INFRA-SCL/latest/artifact/shared/sentry-cli-armhf/sentry-cli -o /usr/local/bin/sentry-cli 30 | chmod +x /usr/local/bin/sentry-cli 31 | else 32 | echo "Installing sentry-cli for $ARCH" 33 | curl -sL https://sentry.io/get-cli/ | bash 34 | fi 35 | fi 36 | 37 | function findDBGFile() { 38 | local DBGFILE 39 | DBGFILE=`eu-unstrip -n -e $1 | awk '{print $4}'` 40 | if (( $? != 0)); then 41 | return 1 42 | fi 43 | if [ "$DBGFILE" == "-" ]; then 44 | return 1 45 | elif [ "$DBGFILE" == "." ]; then 46 | return 1 47 | else 48 | echo $DBGFILE 49 | return 0 50 | fi 51 | } 52 | 53 | 54 | 55 | 56 | ldd $EXECUTABLE | awk '{print $3}' | 57 | { 58 | while IFS= read lib 59 | do 60 | if [ -f "$lib" ]; then 61 | useable=`sentry-cli difutil check $lib | grep "Usable: yes"` 62 | if [ ! -z "$useable" ]; then 63 | RP=`realpath $lib` 64 | DBGFILE=$(findDBGFile $lib) 65 | if (( $? == 0)); then 66 | LIBS+=" $DBGFILE" 67 | fi 68 | LIBS+=" $RP" 69 | echo "Got Lib:" $RP " " $DBGFILE 70 | fi 71 | fi 72 | 73 | done 74 | LIBS+=" /usr/local/bin/ozwdaemon" 75 | echo $LIBS 76 | sentry-cli --auth-token $SENTRY_TOKEN upload-dif -o openzwave -p qt-openzwave $LIBS --wait 77 | } 78 | 79 | -------------------------------------------------------------------------------- /tools/updaterpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OZWPATH=`otool -L $1 | grep libopenzwave | grep compatibility | awk '{print $1}'` 3 | echo $OZWPATH 4 | install_name_tool -change $OZWPATH @rpath/libopenzwave-1.6.dylib $1 5 | --------------------------------------------------------------------------------