diff --git a/libnymea-zigbee/zcl/zigbeecluster.cpp b/libnymea-zigbee/zcl/zigbeecluster.cpp index e3687b8..5c69615 100644 --- a/libnymea-zigbee/zcl/zigbeecluster.cpp +++ b/libnymea-zigbee/zcl/zigbeecluster.cpp @@ -34,6 +34,7 @@ #include "zigbeenetworkrequest.h" #include +#include ZigbeeCluster::ZigbeeCluster(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, ZigbeeClusterLibrary::ClusterId clusterId, Direction direction, QObject *parent) : QObject(parent), @@ -381,7 +382,11 @@ void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const Zigbe QList attributeStatusRecords = ZigbeeClusterLibrary::parseAttributeStatusRecords(frame.payload); foreach (const ZigbeeClusterLibrary::ReadAttributeStatusRecord &attributeStatusRecord, attributeStatusRecords) { qCDebug(dcZigbeeCluster()) << "Received read attribute status record" << this << attributeStatusRecord; - setAttribute(ZigbeeClusterAttribute(attributeStatusRecord.attributeId, attributeStatusRecord.dataType)); + if (attributeStatusRecord.attributeStatus == ZigbeeClusterLibrary::StatusSuccess) { + setAttribute(ZigbeeClusterAttribute(attributeStatusRecord.attributeId, attributeStatusRecord.dataType)); + } else { + qCWarning(dcZigbeeCluster()) << "Reading attribute status record returned an error" << attributeStatusRecord; + } } } } @@ -420,9 +425,16 @@ QDebug operator<<(QDebug debug, ZigbeeCluster *cluster) { debug.nospace().noquote() << "ZigbeeCluster(" << ZigbeeUtils::convertUint16ToHexString(static_cast(cluster->clusterId())) << ", " - << cluster->clusterName() << ", " - << cluster->direction() - << ")"; + << cluster->clusterName() << ", "; + switch (cluster->direction()) { + case ZigbeeCluster::Server: + debug.nospace().noquote() << "Servers)"; + break; + case ZigbeeCluster::Client: + debug.nospace().noquote() << "Client)"; + break; + } + return debug.space(); } diff --git a/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp b/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp index 8255a2b..2a2bf24 100644 --- a/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp +++ b/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp @@ -352,10 +352,11 @@ QDebug operator<<(QDebug debug, const ZigbeeClusterLibrary::ReadAttributeStatusR { debug.nospace() << "ReadAttributeStatusRecord(" << ZigbeeUtils::convertUint16ToHexString(attributeStatusRecord.attributeId) << ", " - << attributeStatusRecord.attributeStatus << ", " - << attributeStatusRecord.dataType - << ")"; - + << attributeStatusRecord.attributeStatus; + if (attributeStatusRecord.attributeStatus == ZigbeeClusterLibrary::StatusSuccess) { + debug.nospace() << ", " << attributeStatusRecord.dataType; + } + debug.nospace() << ")"; return debug.space(); } diff --git a/libnymea-zigbee/zigbeeutils.cpp b/libnymea-zigbee/zigbeeutils.cpp index 5223aa5..6b0f7a5 100644 --- a/libnymea-zigbee/zigbeeutils.cpp +++ b/libnymea-zigbee/zigbeeutils.cpp @@ -245,10 +245,9 @@ QString ZigbeeUtils::convertUint64ToHexString(const quint64 &value) QString ZigbeeUtils::clusterIdToString(const ZigbeeClusterLibrary::ClusterId &clusterId) { - QMetaObject metaObject = ZigbeeClusterLibrary::staticMetaObject; - QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("ClusterId")); - QString enumString = metaEnum.valueToKey(clusterId); - QString clusterName = enumString.remove("ZigbeeClusterLibrary::ClusterId(ClusterId").remove(")"); + QMetaEnum metaEnum = QMetaEnum::fromType(); + QString enumString = QString(metaEnum.valueToKey(clusterId)); + QString clusterName = enumString.remove("ClusterId").remove(")"); if (clusterName.isEmpty()) clusterName = "Unknown"; @@ -257,10 +256,10 @@ QString ZigbeeUtils::clusterIdToString(const ZigbeeClusterLibrary::ClusterId &cl QString ZigbeeUtils::profileIdToString(const Zigbee::ZigbeeProfile &profileId) { - QMetaObject metaObject = Zigbee::staticMetaObject; - QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("ZigbeeProfile")); - QString enumString = metaEnum.valueToKey(profileId); - return enumString.remove("Zigbee::ZigbeeProfile(ZigbeeProfile").remove(")"); + QMetaEnum metaEnum = QMetaEnum::fromType(); + QString enumString = QString(metaEnum.valueToKey(profileId)); + QString profileName = enumString.remove("ZigbeeProfile").remove(")"); + return profileName; } quint64 ZigbeeUtils::generateRandomPanId()