Fix Z-Wave security mode display

This commit is contained in:
Michael Zanetti 2022-08-26 00:31:36 +02:00
parent 3b9a780a78
commit 16f2ca3139
4 changed files with 67 additions and 42 deletions

View File

@ -325,6 +325,7 @@ ZWaveNode *ZWaveManager::unpackNode(const QVariantMap &nodeMap, ZWaveNode *node)
node->setFailed(nodeMap.value("failed").toBool()); node->setFailed(nodeMap.value("failed").toBool());
node->setSleeping(nodeMap.value("sleeping").toBool()); node->setSleeping(nodeMap.value("sleeping").toBool());
node->setLinkQuality(nodeMap.value("linkQuality").toUInt()); node->setLinkQuality(nodeMap.value("linkQuality").toUInt());
node->setSecurityMode(nodeMap.value("securityMode").toUInt());
QMetaEnum nodeTypeEnum = QMetaEnum::fromType<ZWaveNode::ZWaveNodeType>(); QMetaEnum nodeTypeEnum = QMetaEnum::fromType<ZWaveNode::ZWaveNodeType>();
node->setNodeType(static_cast<ZWaveNode::ZWaveNodeType>(nodeTypeEnum.keyToValue(nodeMap.value("nodeType").toByteArray()))); node->setNodeType(static_cast<ZWaveNode::ZWaveNodeType>(nodeTypeEnum.keyToValue(nodeMap.value("nodeType").toByteArray())));
@ -341,9 +342,9 @@ ZWaveNode *ZWaveManager::unpackNode(const QVariantMap &nodeMap, ZWaveNode *node)
node->setProductType(nodeMap.value("productType").toUInt()); node->setProductType(nodeMap.value("productType").toUInt());
node->setVersion(nodeMap.value("version").toUInt()); node->setVersion(nodeMap.value("version").toUInt());
node->setIsZWavePlus(nodeMap.value("isZWavePlus").toBool()); node->setIsZWavePlusDevice(nodeMap.value("isZWavePlusDevice").toBool());
node->setIsSecure(nodeMap.value("isSecure").toBool()); node->setIsSecurityDevice(nodeMap.value("isSecurityDevice").toBool());
node->setIsBeaming(nodeMap.value("isBeaming").toBool()); node->setIsBeamingDevice(nodeMap.value("isBeamingDevice").toBool());
return node; return node;

View File

@ -164,42 +164,42 @@ void ZWaveNode::setVersion(quint8 version)
} }
} }
bool ZWaveNode::isZWavePlus() const bool ZWaveNode::isZWavePlusDevice() const
{ {
return m_isZWavePlus;; return m_isZWavePlusDevice;
} }
void ZWaveNode::setIsZWavePlus(bool isZWavePlus) void ZWaveNode::setIsZWavePlusDevice(bool isZWavePlusDevice)
{ {
if (m_isZWavePlus != isZWavePlus) { if (m_isZWavePlusDevice != isZWavePlusDevice) {
m_isZWavePlus = isZWavePlus; m_isZWavePlusDevice = isZWavePlusDevice;
emit isZWavePlusChanged(); emit isZWavePlusDeviceChanged();
} }
} }
bool ZWaveNode::isSecure() const bool ZWaveNode::isSecurityDevice() const
{ {
return m_isSecure; return m_isSecurityDevice;
} }
void ZWaveNode::setIsSecure(bool isSecure) void ZWaveNode::setIsSecurityDevice(bool isSecurityDevice)
{ {
if (m_isSecure != isSecure) { if (m_isSecurityDevice != isSecurityDevice) {
m_isSecure = isSecure; m_isSecurityDevice = isSecurityDevice;
emit isSecureChanged(); emit isSecurityDeviceChanged();
} }
} }
bool ZWaveNode::isBeaming() const bool ZWaveNode::isBeamingDevice() const
{ {
return m_isBeaming; return m_isBeamingDevice;
} }
void ZWaveNode::setIsBeaming(bool isBeaming) void ZWaveNode::setIsBeamingDevice(bool isBeamingDevice)
{ {
if (m_isBeaming != isBeaming) { if (m_isBeamingDevice != isBeamingDevice) {
m_isBeaming = isBeaming; m_isBeamingDevice = isBeamingDevice;
emit isBeamingChanged(); emit isBeamingDeviceChanged();
} }
} }
@ -255,6 +255,19 @@ void ZWaveNode::setLinkQuality(quint8 linkQuality)
} }
} }
quint8 ZWaveNode::securityMode() const
{
return m_securityMode;
}
void ZWaveNode::setSecurityMode(quint8 securityMode)
{
if (m_securityMode != securityMode) {
m_securityMode = securityMode;
emit securityModeChanged();
}
}
bool ZWaveNode::initialized() const bool ZWaveNode::initialized() const
{ {
return m_initialized; return m_initialized;

View File

@ -16,6 +16,7 @@ class ZWaveNode : public QObject
Q_PROPERTY(bool failed READ failed NOTIFY failedChanged) Q_PROPERTY(bool failed READ failed NOTIFY failedChanged)
Q_PROPERTY(bool sleeping READ sleeping NOTIFY sleepingChanged) Q_PROPERTY(bool sleeping READ sleeping NOTIFY sleepingChanged)
Q_PROPERTY(quint8 linkQuality READ linkQuality NOTIFY linkQualityChanged) Q_PROPERTY(quint8 linkQuality READ linkQuality NOTIFY linkQualityChanged)
Q_PROPERTY(quint8 securityMode READ securityMode NOTIFY securityModeChanged)
Q_PROPERTY(ZWaveNodeType nodeType READ nodeType NOTIFY nodeTypeChanged) Q_PROPERTY(ZWaveNodeType nodeType READ nodeType NOTIFY nodeTypeChanged)
Q_PROPERTY(QString nodeTypeString READ nodeTypeString NOTIFY nodeTypeChanged) Q_PROPERTY(QString nodeTypeString READ nodeTypeString NOTIFY nodeTypeChanged)
Q_PROPERTY(ZWaveNodeRole role READ role NOTIFY roleChanged) Q_PROPERTY(ZWaveNodeRole role READ role NOTIFY roleChanged)
@ -29,9 +30,9 @@ class ZWaveNode : public QObject
Q_PROPERTY(QString productName READ productName NOTIFY productNameChanged) Q_PROPERTY(QString productName READ productName NOTIFY productNameChanged)
Q_PROPERTY(quint16 productType READ productType NOTIFY productTypeChanged) Q_PROPERTY(quint16 productType READ productType NOTIFY productTypeChanged)
Q_PROPERTY(quint8 version READ version NOTIFY versionChanged) Q_PROPERTY(quint8 version READ version NOTIFY versionChanged)
Q_PROPERTY(bool isZWavePlus READ isZWavePlus NOTIFY isZWavePlusChanged) Q_PROPERTY(bool isZWavePlusDevice READ isZWavePlusDevice NOTIFY isZWavePlusDeviceChanged)
Q_PROPERTY(bool isSecure READ isSecure NOTIFY isSecureChanged) Q_PROPERTY(bool isSecurityDevice READ isSecurityDevice NOTIFY isSecurityDeviceChanged)
Q_PROPERTY(bool isBeaming READ isBeaming NOTIFY isBeamingChanged) Q_PROPERTY(bool isBeamingDevice READ isBeamingDevice NOTIFY isBeamingDeviceChanged)
public: public:
enum ZWaveNodeType { enum ZWaveNodeType {
@ -155,6 +156,9 @@ public:
quint8 linkQuality() const; quint8 linkQuality() const;
void setLinkQuality(quint8 linkQuality); void setLinkQuality(quint8 linkQuality);
quint8 securityMode() const;
void setSecurityMode(quint8 securityMode);
ZWaveNodeType nodeType() const; ZWaveNodeType nodeType() const;
void setNodeType(ZWaveNodeType nodeType); void setNodeType(ZWaveNodeType nodeType);
QString nodeTypeString() const; QString nodeTypeString() const;
@ -190,14 +194,14 @@ public:
quint8 version() const; quint8 version() const;
void setVersion(quint8 version); void setVersion(quint8 version);
bool isZWavePlus() const; bool isZWavePlusDevice() const;
void setIsZWavePlus(bool isZWavePlus); void setIsZWavePlusDevice(bool isZWavePlusDevice);
bool isSecure() const; bool isSecurityDevice() const;
void setIsSecure(bool isSecure); void setIsSecurityDevice(bool isSecurityDevice);
bool isBeaming() const; bool isBeamingDevice() const;
void setIsBeaming(bool isBeaming); void setIsBeamingDevice(bool isBeamingDevice);
signals: signals:
void initializedChanged(); void initializedChanged();
@ -205,6 +209,7 @@ signals:
void failedChanged(); void failedChanged();
void sleepingChanged(); void sleepingChanged();
void linkQualityChanged(); void linkQualityChanged();
void securityModeChanged();
void nodeTypeChanged(); void nodeTypeChanged();
void deviceTypeChanged(); void deviceTypeChanged();
void roleChanged(); void roleChanged();
@ -217,9 +222,9 @@ signals:
void productNameChanged(); void productNameChanged();
void productTypeChanged(); void productTypeChanged();
void versionChanged(); void versionChanged();
void isZWavePlusChanged(); void isZWavePlusDeviceChanged();
void isSecureChanged(); void isSecurityDeviceChanged();
void isBeamingChanged(); void isBeamingDeviceChanged();
private: private:
quint8 m_nodeId = 0; quint8 m_nodeId = 0;
@ -230,6 +235,7 @@ private:
bool m_failed = false; bool m_failed = false;
bool m_sleeping = false; bool m_sleeping = false;
quint8 m_linkQuality = 0; quint8 m_linkQuality = 0;
quint8 m_securityMode = 0;
ZWaveNodeType m_nodeType = ZWaveNodeTypeUnknown; ZWaveNodeType m_nodeType = ZWaveNodeTypeUnknown;
ZWaveNodeRole m_role = ZWaveNodeRoleUnknown; ZWaveNodeRole m_role = ZWaveNodeRoleUnknown;
@ -241,9 +247,9 @@ private:
QString m_productName; QString m_productName;
quint16 m_productType = 0; quint16 m_productType = 0;
quint8 m_version = 0; quint8 m_version = 0;
bool m_isZWavePlus = false; bool m_isZWavePlusDevice = false;
bool m_isSecure = false; bool m_isSecurityDevice = false;
bool m_isBeaming = false; bool m_isBeamingDevice = false;
}; };
class ZWaveNodes: public QAbstractListModel class ZWaveNodes: public QAbstractListModel

View File

@ -315,11 +315,6 @@ SettingsPageBase {
tertiaryIconColor: node.reachable ? Style.iconColor : Style.red tertiaryIconColor: node.reachable ? Style.iconColor : Style.red
Connections {
target: node
onLastSeenChanged: communicationIndicatorLedTimer.start()
}
Timer { Timer {
id: communicationIndicatorLedTimer id: communicationIndicatorLedTimer
interval: 200 interval: 200
@ -429,6 +424,16 @@ SettingsPageBase {
font: Style.smallFont font: Style.smallFont
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Label {
text: qsTr("Security mode:")
font: Style.smallFont
}
Label {
Layout.fillWidth: true
text: nodeInfoDialog.node.securityMode
font: Style.smallFont
horizontalAlignment: Text.AlignRight
}
Label { Label {
text: qsTr("Z-Wave plus:") text: qsTr("Z-Wave plus:")
@ -441,7 +446,7 @@ SettingsPageBase {
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
} }
Label { Label {
text: qsTr("Security supported:") text: qsTr("Security device:")
font: Style.smallFont font: Style.smallFont
} }
Label { Label {