From 46690ffa52c0ebef1c0f7f54469fb81cd7e57f72 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Tue, 10 Oct 2023 09:07:32 +0200 Subject: [PATCH] Clear endpoint bitmask before reporting the PartList attribute When we set a low value to the minimum subscription interval for subscription for the PartList attribute of the Description cluster, and then remove a dynamic endpoint the related bitmask may change after reporting it to a controller. The controller receives the old number of endpoints and does not update it within the following subscriptions until the next change of the PartList attribute occurs. To resolve the issue the endpoint bitmask should be cleared before reporting the PartList attribute of the Descriptor cluster to avoid race conditions. --- src/app/util/attribute-storage.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 824df9835646f1..ce37246c4b3d9f 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -943,6 +943,7 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable) else { shutdownEndpoint(&(emAfEndpoints[index])); + emAfEndpoints[index].bitmask.Clear(EmberAfEndpointOptions::isEnabled); } EndpointId parentEndpointId = emberAfParentEndpointFromIndex(index); @@ -963,11 +964,6 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable) app::Clusters::Descriptor::Attributes::PartsList::Id); } - if (!enable) - { - emAfEndpoints[index].bitmask.Clear(EmberAfEndpointOptions::isEnabled); - } - return true; }