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->setSleeping(nodeMap.value("sleeping").toBool());
node->setLinkQuality(nodeMap.value("linkQuality").toUInt());
node->setSecurityMode(nodeMap.value("securityMode").toUInt());
QMetaEnum nodeTypeEnum = QMetaEnum::fromType<ZWaveNode::ZWaveNodeType>();
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->setVersion(nodeMap.value("version").toUInt());
node->setIsZWavePlus(nodeMap.value("isZWavePlus").toBool());
node->setIsSecure(nodeMap.value("isSecure").toBool());
node->setIsBeaming(nodeMap.value("isBeaming").toBool());
node->setIsZWavePlusDevice(nodeMap.value("isZWavePlusDevice").toBool());
node->setIsSecurityDevice(nodeMap.value("isSecurityDevice").toBool());
node->setIsBeamingDevice(nodeMap.value("isBeamingDevice").toBool());
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) {
m_isZWavePlus = isZWavePlus;
emit isZWavePlusChanged();
if (m_isZWavePlusDevice != isZWavePlusDevice) {
m_isZWavePlusDevice = isZWavePlusDevice;
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) {
m_isSecure = isSecure;
emit isSecureChanged();
if (m_isSecurityDevice != isSecurityDevice) {
m_isSecurityDevice = isSecurityDevice;
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) {
m_isBeaming = isBeaming;
emit isBeamingChanged();
if (m_isBeamingDevice != isBeamingDevice) {
m_isBeamingDevice = isBeamingDevice;
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
{
return m_initialized;

View File

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

View File

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