From 71d158cf9e57904eec61fd0e488e62c29f8f1895 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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 824df9835646f1..2e2ddf680a0a04 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -928,6 +928,10 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable) { emAfEndpoints[index].bitmask.Set(EmberAfEndpointOptions::isEnabled); } + else + { + emAfEndpoints[index].bitmask.Clear(EmberAfEndpointOptions::isEnabled); + } #if defined(EZSP_HOST) ezspSetEndpointFlags(endpoint, (enable ? EZSP_ENDPOINT_ENABLED : EZSP_ENDPOINT_DISABLED)); @@ -963,11 +967,6 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable) app::Clusters::Descriptor::Attributes::PartsList::Id); } - if (!enable) - { - emAfEndpoints[index].bitmask.Clear(EmberAfEndpointOptions::isEnabled); - } - return true; }