diff --git a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp index 76b7760..b6350d4 100644 --- a/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp +++ b/libnymea-zigbee/zcl/general/zigbeeclusteronoff.cpp @@ -206,6 +206,8 @@ void ZigbeeClusterOnOff::setAttribute(const ZigbeeClusterAttribute &attribute) if (valueOk) { qCDebug(dcZigbeeCluster()) << "OnOff state changed on" << m_node << m_endpoint << this << value; emit powerChanged(value); + } else { + qCWarning(dcZigbeeCluster()) << "Failed to parse attribute data" << m_node << m_endpoint << this << attribute; } } } diff --git a/libnymea-zigbee/zcl/zigbeecluster.cpp b/libnymea-zigbee/zcl/zigbeecluster.cpp index 1f3fc23..c2c5508 100644 --- a/libnymea-zigbee/zcl/zigbeecluster.cpp +++ b/libnymea-zigbee/zcl/zigbeecluster.cpp @@ -247,6 +247,7 @@ void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const Zigbe // Update the attributes from the attribut status reports internally 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)); } } @@ -254,7 +255,6 @@ void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const Zigbe // Increase the tsn for continuouse id increasing on both sides m_transactionSequenceNumber = frame.header.transactionSequenceNumber; - return; } @@ -262,18 +262,19 @@ void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const Zigbe if (m_direction == Server && frame.header.frameControl.frameType == ZigbeeClusterLibrary::FrameTypeGlobal) { ZigbeeClusterLibrary::Command globalCommand = static_cast(frame.header.command); if (globalCommand == ZigbeeClusterLibrary::CommandReportAttributes) { - qCDebug(dcZigbeeCluster()) << "Received attributes report received" << this << frame; // Read the attribute reports and update/set the attributes QDataStream stream(frame.payload); stream.setByteOrder(QDataStream::LittleEndian); - quint16 attributeId = 0; quint8 type = 0; - stream >> attributeId >> type; - ZigbeeDataType dataType = ZigbeeClusterLibrary::readDataType(&stream, static_cast(type)); - setAttribute(ZigbeeClusterAttribute(attributeId, dataType)); + while (!stream.atEnd()) { + quint16 attributeId = 0; quint8 type = 0; + stream >> attributeId >> type; + ZigbeeDataType dataType = ZigbeeClusterLibrary::readDataType(&stream, static_cast(type)); + qCDebug(dcZigbeeCluster()) << "Received attributes report" << this << frame; + setAttribute(ZigbeeClusterAttribute(attributeId, dataType)); + } // Increase the tsn for continuouse id increasing on both sides m_transactionSequenceNumber = frame.header.transactionSequenceNumber; - return; } } diff --git a/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp b/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp index 984ae86..a8d9c44 100644 --- a/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp +++ b/libnymea-zigbee/zcl/zigbeeclusterlibrary.cpp @@ -143,7 +143,6 @@ QList ZigbeeClusterLibrary::par ZigbeeDataType ZigbeeClusterLibrary::readDataType(QDataStream *stream, Zigbee::DataType dataType) { - QByteArray data; quint16 numberOfElenemts = 0; quint8 elementType = 0; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream.setByteOrder(QDataStream::LittleEndian); diff --git a/libnymea-zigbee/zigbeenodeendpoint.cpp b/libnymea-zigbee/zigbeenodeendpoint.cpp index 6f18d54..348d41d 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.cpp +++ b/libnymea-zigbee/zigbeenodeendpoint.cpp @@ -122,24 +122,6 @@ bool ZigbeeNodeEndpoint::hasOutputCluster(Zigbee::ClusterId clusterId) const return m_outputClusters.keys().contains(clusterId); } -void ZigbeeNodeEndpoint::createInputCluster(quint16 clusterId) -{ - Zigbee::ClusterId id = static_cast(clusterId); - if (hasInputCluster(id)) - return; - - addInputCluster(createCluster(static_cast(clusterId), ZigbeeCluster::Server)); -} - -void ZigbeeNodeEndpoint::createOutputCluster(quint16 clusterId) -{ - Zigbee::ClusterId id = static_cast(clusterId); - if (hasInputCluster(id)) - return; - - addOutputCluster(createCluster(static_cast(clusterId), ZigbeeCluster::Client)); -} - ZigbeeNodeEndpoint::ZigbeeNodeEndpoint(ZigbeeNetwork *network, ZigbeeNode *node, quint8 endpointId, QObject *parent) : QObject(parent), m_network(network), diff --git a/libnymea-zigbee/zigbeenodeendpoint.h b/libnymea-zigbee/zigbeenodeendpoint.h index cdaf5d1..2434770 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.h +++ b/libnymea-zigbee/zigbeenodeendpoint.h @@ -108,13 +108,6 @@ public: return qobject_cast(getOutputCluster(clusterId)); } - // Note: these methods can be used for devices which do not - // show the clusters in the simple descriptor. By default these methods - // should not be neccessary - void createInputCluster(quint16 clusterId); - void createOutputCluster(quint16 clusterId); - - private: explicit ZigbeeNodeEndpoint(ZigbeeNetwork *network, ZigbeeNode *node, quint8 endpointId, QObject *parent = nullptr); ~ZigbeeNodeEndpoint();