Implement multiple attributes report parsing
parent
74995ce401
commit
b5b6709da3
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ void ZigbeeCluster::processApsDataIndication(const QByteArray &asdu, const Zigbe
|
|||
// Update the attributes from the attribut status reports internally
|
||||
QList<ZigbeeClusterLibrary::ReadAttributeStatusRecord> 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<ZigbeeClusterLibrary::Command>(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);
|
||||
while (!stream.atEnd()) {
|
||||
quint16 attributeId = 0; quint8 type = 0;
|
||||
stream >> attributeId >> type;
|
||||
ZigbeeDataType dataType = ZigbeeClusterLibrary::readDataType(&stream, static_cast<Zigbee::DataType>(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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ QList<ZigbeeClusterLibrary::ReadAttributeStatusRecord> 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);
|
||||
|
|
|
|||
|
|
@ -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<Zigbee::ClusterId>(clusterId);
|
||||
if (hasInputCluster(id))
|
||||
return;
|
||||
|
||||
addInputCluster(createCluster(static_cast<Zigbee::ClusterId>(clusterId), ZigbeeCluster::Server));
|
||||
}
|
||||
|
||||
void ZigbeeNodeEndpoint::createOutputCluster(quint16 clusterId)
|
||||
{
|
||||
Zigbee::ClusterId id = static_cast<Zigbee::ClusterId>(clusterId);
|
||||
if (hasInputCluster(id))
|
||||
return;
|
||||
|
||||
addOutputCluster(createCluster(static_cast<Zigbee::ClusterId>(clusterId), ZigbeeCluster::Client));
|
||||
}
|
||||
|
||||
ZigbeeNodeEndpoint::ZigbeeNodeEndpoint(ZigbeeNetwork *network, ZigbeeNode *node, quint8 endpointId, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_network(network),
|
||||
|
|
|
|||
|
|
@ -108,13 +108,6 @@ public:
|
|||
return qobject_cast<T *>(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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue