From 1057186af7451b69df4c030155f09c846f22fab7 Mon Sep 17 00:00:00 2001 From: Anton Grey Date: Wed, 22 Jun 2022 05:50:24 +0300 Subject: [PATCH] Iterate over parent endpoints chain to fill Aggregator PartsList properly. (#19721) --- src/app/clusters/descriptor/descriptor.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/descriptor/descriptor.cpp b/src/app/clusters/descriptor/descriptor.cpp index 543c8efb9eb490..fc28fa673322c6 100644 --- a/src/app/clusters/descriptor/descriptor.cpp +++ b/src/app/clusters/descriptor/descriptor.cpp @@ -82,13 +82,23 @@ CHIP_ERROR DescriptorAttrAccess::ReadPartsAttribute(EndpointId endpoint, Attribu err = aEncoder.EncodeList([endpoint](const auto & encoder) -> CHIP_ERROR { for (uint16_t index = 0; index < emberAfEndpointCount(); index++) { - if (emberAfEndpointIndexIsEnabled(index)) + if (!emberAfEndpointIndexIsEnabled(index)) + continue; + + uint16_t childIndex = index; + while (childIndex != chip::kInvalidListIndex) { - EndpointId composedEndpointId = emberAfParentEndpointFromIndex(index); - if (composedEndpointId == chip::kInvalidEndpointId || composedEndpointId != endpoint) - continue; + EndpointId parentEndpointId = emberAfParentEndpointFromIndex(childIndex); + if (parentEndpointId == chip::kInvalidEndpointId) + break; + + if (parentEndpointId == endpoint) + { + ReturnErrorOnFailure(encoder.Encode(emberAfEndpointFromIndex(index))); + break; + } - ReturnErrorOnFailure(encoder.Encode(emberAfEndpointFromIndex(index))); + childIndex = emberAfIndexFromEndpoint(parentEndpointId); } }