mirror of
https://github.com/Fishwaldo/qt-openzwave.git
synced 2025-07-08 06:08:21 +00:00
Add catchsegv to Docker Container, and Delete Nodes/Values from MQTT when necessary
This commit is contained in:
parent
6a088c931b
commit
fe7daab975
7 changed files with 69 additions and 31 deletions
|
@ -14,9 +14,9 @@ WORKDIR /opt
|
||||||
RUN git clone https://github.com/qt/qtmqtt.git && cd qtmqtt && /opt/Qt/5.12.4/bin/qmake && make && make install
|
RUN git clone https://github.com/qt/qtmqtt.git && cd qtmqtt && /opt/Qt/5.12.4/bin/qmake && make && make install
|
||||||
RUN git clone https://github.com/OpenZWave/open-zwave.git && cd open-zwave && make -j4 && make install
|
RUN git clone https://github.com/OpenZWave/open-zwave.git && cd open-zwave && make -j4 && make install
|
||||||
RUN git clone https://github.com/OpenZWave/qt-openzwave.git && cd qt-openzwave && git checkout mqtt && /opt/Qt/5.12.4/bin/qmake && make -j4 && make install
|
RUN git clone https://github.com/OpenZWave/qt-openzwave.git && cd qt-openzwave && git checkout mqtt && /opt/Qt/5.12.4/bin/qmake && make -j4 && make install
|
||||||
RUN ls -lah /usr/local/lib64/
|
#RUN ls -lah /usr/local/lib64/
|
||||||
RUN ls /opt/
|
#RUN ls /opt/
|
||||||
RUN ls -lah /ozwdaemon/bin/
|
#RUN ls -lah /ozwdaemon/bin/
|
||||||
#RUN LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH" /ozwdaemon/bin/ozwdaemon
|
#RUN LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH" /ozwdaemon/bin/ozwdaemon
|
||||||
RUN mkdir /opt/ozw/ && mkdir /opt/ozw/config/
|
RUN mkdir /opt/ozw/ && mkdir /opt/ozw/config/
|
||||||
|
|
||||||
|
@ -27,5 +27,5 @@ ENV MQTT_PORT="1883"
|
||||||
WORKDIR /opt/ozw/
|
WORKDIR /opt/ozw/
|
||||||
EXPOSE 1983
|
EXPOSE 1983
|
||||||
VOLUME ["/opt/ozw/config/"]
|
VOLUME ["/opt/ozw/config/"]
|
||||||
ENTRYPOINT /ozwdaemon/bin/ozwdaemon -s $USBPATH -c /opt/ozw/config/ -u /opt/ozw/config/ --mqtt-server $MQTT_SERVER --mqtt-port $MQTT_PORT
|
ENTRYPOINT /usr/bin/catchsegv /ozwdaemon/bin/ozwdaemon -s $USBPATH -c /opt/ozw/config/ -u /opt/ozw/config/ --mqtt-server $MQTT_SERVER --mqtt-port $MQTT_PORT
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ COPIES += copyrepheaders
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/local/lib
|
target.path = /usr/local/lib
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
QMAKE_CXXFLAGS += -g1
|
||||||
}
|
}
|
||||||
#LIBS += -L../../open-zwave -lopenzwave
|
#LIBS += -L../../open-zwave -lopenzwave
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,5 @@ ozwconfig.commands=cp -R ../../open-zwave/config config/ && cd config && $$[QT_I
|
||||||
include/qt-openzwave/qt-openzwavedatabase.h
|
include/qt-openzwave/qt-openzwavedatabase.h
|
||||||
|
|
||||||
INCLUDEPATH += include/
|
INCLUDEPATH += include/
|
||||||
|
QMAKE_CXXFLAGS += -g1
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
@ -5,8 +10,24 @@
|
||||||
#include "mqttpublisher.h"
|
#include "mqttpublisher.h"
|
||||||
#include <qt-openzwave/qt-openzwavedatabase.h>
|
#include <qt-openzwave/qt-openzwavedatabase.h>
|
||||||
|
|
||||||
|
void handler(int sig) {
|
||||||
|
void *array[10];
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
// get void*'s for all entries on the stack
|
||||||
|
size = backtrace(array, 10);
|
||||||
|
|
||||||
|
// print out all the frames to stderr
|
||||||
|
fprintf(stderr, "Error: signal %d:\n", sig);
|
||||||
|
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
//signal(SIGSEGV, handler); // install our handler
|
||||||
|
|
||||||
|
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
QCoreApplication::setApplicationName("ozwdaemon");
|
QCoreApplication::setApplicationName("ozwdaemon");
|
||||||
QCoreApplication::setApplicationVersion("0.1");
|
QCoreApplication::setApplicationVersion("0.1");
|
||||||
|
|
|
@ -29,13 +29,13 @@ bool mqttNodeModel::populateJsonObject(QJsonObject *jsonobject, quint8 node, QTO
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<NodeColumns>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<NodeColumns>();
|
||||||
if (data.type() == QMetaType::QString) {
|
if (static_cast<QMetaType::Type>(data.type()) == QMetaType::QString) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toString());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toString());
|
||||||
} else if (data.type() == QMetaType::Bool) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Bool) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toBool());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toBool());
|
||||||
} else if (data.type() == QMetaType::Int) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Int) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
||||||
} else if (data.type() == QMetaType::UInt) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::UInt) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Can't Convert " << data.type() << "(" << metaEnum.valueToKey(i) << ") to store in JsonObject: " << node;
|
qWarning() << "Can't Convert " << data.type() << "(" << metaEnum.valueToKey(i) << ") to store in JsonObject: " << node;
|
||||||
|
@ -55,7 +55,7 @@ bool mqttNodeModel::populateJsonObject(QJsonObject *jsonobject, quint8 node, QTO
|
||||||
metadata.insert("ProductPicBase64", QString(mgr->GetMetaDataProductPic(node).toBase64()));
|
metadata.insert("ProductPicBase64", QString(mgr->GetMetaDataProductPic(node).toBase64()));
|
||||||
jsonobject->insert("MetaData", metadata);
|
jsonobject->insert("MetaData", metadata);
|
||||||
}
|
}
|
||||||
/* Neihbors */
|
/* Neighbors */
|
||||||
QVector<quint8> neighbors = mgr->GetNodeNeighbors(node);
|
QVector<quint8> neighbors = mgr->GetNodeNeighbors(node);
|
||||||
if (neighbors.size() > 0) {
|
if (neighbors.size() > 0) {
|
||||||
QJsonArray N;
|
QJsonArray N;
|
||||||
|
@ -109,17 +109,17 @@ bool mqttValueIDModel::populateJsonObject(QJsonObject *jsonobject, quint64 vidKe
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<ValueIdColumns>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<ValueIdColumns>();
|
||||||
if (data.type() == QMetaType::QString) {
|
if (static_cast<QMetaType::Type>(data.type()) == QMetaType::QString) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toString());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toString());
|
||||||
} else if (data.type() == QMetaType::Bool) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Bool) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toBool());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toBool());
|
||||||
} else if (data.type() == QMetaType::Int) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Int) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
||||||
} else if (data.type() == QMetaType::UInt) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::UInt) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toInt());
|
||||||
} else if (data.type() == QMetaType::Float) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Float) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), data.toDouble());
|
jsonobject->insert(metaEnum.valueToKey(i), data.toDouble());
|
||||||
} else if (data.type() == QMetaType::ULongLong) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::ULongLong) {
|
||||||
jsonobject->insert(metaEnum.valueToKey(i), static_cast<qint64>(data.toULongLong()));
|
jsonobject->insert(metaEnum.valueToKey(i), static_cast<qint64>(data.toULongLong()));
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Can't Convert " << data.type() << "(" << metaEnum.valueToKey(i) << ") to store in JsonObject: " << vidKey;
|
qWarning() << "Can't Convert " << data.type() << "(" << metaEnum.valueToKey(i) << ") to store in JsonObject: " << vidKey;
|
||||||
|
@ -137,19 +137,19 @@ bool mqttValueIDModel::populateJsonObject(QJsonObject *jsonobject, quint64 vidKe
|
||||||
QJsonValue mqttValueIDModel::encodeValue(quint64 vidKey) {
|
QJsonValue mqttValueIDModel::encodeValue(quint64 vidKey) {
|
||||||
QJsonValue value;
|
QJsonValue value;
|
||||||
QVariant data = this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Value);
|
QVariant data = this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Value);
|
||||||
if (data.type() == QMetaType::QString) {
|
if (static_cast<QMetaType::Type>(data.type()) == QMetaType::QString) {
|
||||||
value = data.toString();
|
value = data.toString();
|
||||||
} else if (data.type() == QMetaType::Bool) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Bool) {
|
||||||
value = data.toBool();
|
value = data.toBool();
|
||||||
} else if (data.type() == QMetaType::Int) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Int) {
|
||||||
value = data.toInt();
|
value = data.toInt();
|
||||||
} else if (data.type() == QMetaType::UInt) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::UInt) {
|
||||||
value = data.toInt();
|
value = data.toInt();
|
||||||
} else if (data.type() == QMetaType::Float) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Float) {
|
||||||
value = data.toDouble();
|
value = data.toDouble();
|
||||||
} else if (data.type() == QMetaType::ULongLong) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::ULongLong) {
|
||||||
value = static_cast<qint64>(data.toULongLong());
|
value = static_cast<qint64>(data.toULongLong());
|
||||||
} else if (data.type() == QMetaType::Short) {
|
} else if (static_cast<QMetaType::Type>(data.type()) == QMetaType::Short) {
|
||||||
value = static_cast<qint16>(data.toInt());
|
value = static_cast<qint16>(data.toInt());
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Can't Convert " << data.type() << " to store in JsonObject: " << vidKey << this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Label).toString() << this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Type);
|
qWarning() << "Can't Convert " << data.type() << " to store in JsonObject: " << vidKey << this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Label).toString() << this->getValueData(vidKey, mqttValueIDModel::ValueIdColumns::Type);
|
||||||
|
@ -333,8 +333,10 @@ bool mqttpublisher::sendNodeUpdate(quint8 node) {
|
||||||
|
|
||||||
bool mqttpublisher::sendValueUpdate(quint64 vidKey) {
|
bool mqttpublisher::sendValueUpdate(quint64 vidKey) {
|
||||||
quint8 node = this->m_valueModel->getValueData(vidKey, QTOZW_ValueIds::Node).value<quint8>();
|
quint8 node = this->m_valueModel->getValueData(vidKey, QTOZW_ValueIds::Node).value<quint8>();
|
||||||
if (node == 0)
|
if (node == 0) {
|
||||||
|
qWarning() << "sendValueUpdate: Can't find Node for Value: " << vidKey;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
this->m_client->publish(QMqttTopicName(getValueTopic(MQTT_OZW_VID_TOPIC, node, vidKey)), QJsonDocument(this->m_values[vidKey]).toJson(), 0, true);
|
this->m_client->publish(QMqttTopicName(getValueTopic(MQTT_OZW_VID_TOPIC, node, vidKey)), QJsonDocument(this->m_values[vidKey]).toJson(), 0, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -343,6 +345,21 @@ void mqttpublisher::sendCommandUpdate(QString command, QJsonObject js) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mqttpublisher::delNodeTopic(quint8 node) {
|
||||||
|
this->m_client->publish(QMqttTopicName(getNodeTopic(MQTT_OZW_NODE_TOPIC, node)), NULL, 0, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mqttpublisher::delValueTopic(quint64 vidKey) {
|
||||||
|
quint8 node = this->m_valueModel->getValueData(vidKey, QTOZW_ValueIds::Node).value<quint8>();
|
||||||
|
if (node == 0) {
|
||||||
|
qWarning() << "delValueTopic: Can't find Node for Value: " << vidKey;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this->m_client->publish(QMqttTopicName(getValueTopic(MQTT_OZW_VID_TOPIC, node, vidKey)), NULL, 0, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void mqttpublisher::ready() {
|
void mqttpublisher::ready() {
|
||||||
qDebug() << "Publishing Event ready:";
|
qDebug() << "Publishing Event ready:";
|
||||||
|
@ -357,9 +374,7 @@ void mqttpublisher::valueAdded(quint64 vidKey) {
|
||||||
}
|
}
|
||||||
void mqttpublisher::valueRemoved(quint64 vidKey) {
|
void mqttpublisher::valueRemoved(quint64 vidKey) {
|
||||||
qDebug() << "Publishing Event valueRemoved:" << vidKey;
|
qDebug() << "Publishing Event valueRemoved:" << vidKey;
|
||||||
this->m_values[vidKey]["Event"] = "valueRemoved";
|
this->delValueTopic(vidKey);
|
||||||
this->sendValueUpdate(vidKey);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void mqttpublisher::valueChanged(quint64 vidKey) {
|
void mqttpublisher::valueChanged(quint64 vidKey) {
|
||||||
qDebug() << "Publishing Event valueChanged:" << vidKey;
|
qDebug() << "Publishing Event valueChanged:" << vidKey;
|
||||||
|
@ -388,13 +403,11 @@ void mqttpublisher::nodeAdded(quint8 node) {
|
||||||
}
|
}
|
||||||
void mqttpublisher::nodeRemoved(quint8 node) {
|
void mqttpublisher::nodeRemoved(quint8 node) {
|
||||||
qDebug() << "Publishing Event nodeRemoved:" << node;
|
qDebug() << "Publishing Event nodeRemoved:" << node;
|
||||||
this->m_nodes[node]["Event"] = "nodeRemoved";
|
this->delNodeTopic(node);
|
||||||
this->sendNodeUpdate(node);
|
|
||||||
}
|
}
|
||||||
void mqttpublisher::nodeReset(quint8 node) {
|
void mqttpublisher::nodeReset(quint8 node) {
|
||||||
qDebug() << "Publishing Event nodeReset:" << node;
|
qDebug() << "Publishing Event nodeReset:" << node;
|
||||||
this->m_nodes[node]["Event"] = "nodeReset";
|
this->delNodeTopic(node);
|
||||||
this->sendNodeUpdate(node);
|
|
||||||
}
|
}
|
||||||
void mqttpublisher::nodeNaming(quint8 node) {
|
void mqttpublisher::nodeNaming(quint8 node) {
|
||||||
qDebug() << "Publishing Event nodeNaming:" << node;
|
qDebug() << "Publishing Event nodeNaming:" << node;
|
||||||
|
|
|
@ -101,7 +101,8 @@ private:
|
||||||
bool sendStatusUpdate();
|
bool sendStatusUpdate();
|
||||||
bool sendNodeUpdate(quint8);
|
bool sendNodeUpdate(quint8);
|
||||||
bool sendValueUpdate(quint64);
|
bool sendValueUpdate(quint64);
|
||||||
|
bool delNodeTopic(quint8);
|
||||||
|
bool delValueTopic(quint64);
|
||||||
|
|
||||||
QJsonObject m_ozwstatus;
|
QJsonObject m_ozwstatus;
|
||||||
QMap<quint8, QJsonObject> m_nodes;
|
QMap<quint8, QJsonObject> m_nodes;
|
||||||
|
|
|
@ -104,6 +104,7 @@ INCLUDEPATH += ../qt-openzwave/include/
|
||||||
unix {
|
unix {
|
||||||
LIBS += -lresolv -L../qt-openzwave/ -lqt-openzwave -L../qt-openzwavedatabase/ -lqt-openzwavedatabase
|
LIBS += -lresolv -L../qt-openzwave/ -lqt-openzwave -L../qt-openzwavedatabase/ -lqt-openzwavedatabase
|
||||||
INCLUDEPATH += ../qt-openzwavedatabase/include/
|
INCLUDEPATH += ../qt-openzwavedatabase/include/
|
||||||
|
QMAKE_CXXFLAGS += -g1
|
||||||
}
|
}
|
||||||
win32 {
|
win32 {
|
||||||
LIBS += -lDnsapi -L../qt-openzwave/$$BUILDTYPE/ -lqt-openzwave1
|
LIBS += -lDnsapi -L../qt-openzwave/$$BUILDTYPE/ -lqt-openzwave1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue