Bugfix: only report devtype for the queried endpoint

This commit is contained in:
ivmarkov 2023-04-28 06:13:54 +00:00
parent 09a523fc50
commit 2a57ecbd87

View file

@ -71,7 +71,12 @@ impl DescriptorCluster {
} else {
match attr.attr_id.try_into()? {
Attributes::DeviceTypeList => {
self.encode_devtype_list(attr.node, AttrDataWriter::TAG, &mut writer)?;
self.encode_devtype_list(
attr.node,
attr.endpoint_id,
AttrDataWriter::TAG,
&mut writer,
)?;
writer.complete()
}
Attributes::ServerList => {
@ -111,14 +116,17 @@ impl DescriptorCluster {
fn encode_devtype_list(
&self,
node: &Node,
endpoint_id: u16,
tag: TagType,
tw: &mut TLVWriter,
) -> Result<(), Error> {
tw.start_array(tag)?;
for endpoint in node.endpoints {
if endpoint.id == endpoint_id {
let dev_type = endpoint.device_type;
dev_type.to_tlv(tw, TagType::Anonymous)?;
}
}
tw.end_container()
}