diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 67b15686e18282..94ff5920adca58 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -65,6 +65,18 @@ static bool emAfMatchCluster(const EmberAfCluster * cluster, const EmberAfAttrib static bool emAfMatchAttribute(const EmberAfCluster * cluster, const EmberAfAttributeMetadata * am, const EmberAfAttributeSearchRecord * attRecord); +// If server == true, returns the number of server clusters, +// otherwise number of client clusters on the endpoint at the given index. +static uint8_t emberAfClusterCountForEndpointType(const EmberAfEndpointType * endpointType, bool server); + +// If server == true, returns the number of server clusters, +// otherwise number of client clusters on the endpoint at the given index. +static uint8_t emberAfClusterCountByIndex(uint16_t endpointIndex, bool server); + +// Check whether there is an endpoint defined with the given endpoint id that is +// enabled. +static bool emberAfEndpointIsEnabled(chip::EndpointId endpoint); + namespace { #if (!defined(ATTRIBUTE_SINGLETONS_SIZE)) || (ATTRIBUTE_SINGLETONS_SIZE == 0) @@ -1052,33 +1064,6 @@ uint8_t emberAfGetClusterCountForEndpoint(EndpointId endpoint) return emAfEndpoints[index].endpointType->clusterCount; } -// Note the difference in implementation from emberAfGetNthCluster(). -// emberAfGetClusterByIndex() retrieves the cluster by index regardless of server/client -// and those indexes may be DIFFERENT than the indexes returned from -// emberAfGetNthCluster(). In other words: -// -// - Use emberAfGetClustersFromEndpoint() with emberAfGetNthCluster() -// - Use emberAfGetClusterCountForEndpoint() with emberAfGetClusterByIndex() -// -// Don't mix them. -const EmberAfCluster * emberAfGetClusterByIndex(EndpointId endpoint, uint8_t clusterIndex) -{ - uint16_t endpointIndex = emberAfIndexFromEndpoint(endpoint); - EmberAfDefinedEndpoint * definedEndpoint; - - if (endpointIndex == kEmberInvalidEndpointIndex) - { - return nullptr; - } - definedEndpoint = &(emAfEndpoints[endpointIndex]); - - if (clusterIndex >= definedEndpoint->endpointType->clusterCount) - { - return nullptr; - } - return &(definedEndpoint->endpointType->cluster[clusterIndex]); -} - chip::Span emberAfDeviceTypeListFromEndpoint(chip::EndpointId endpoint, CHIP_ERROR & err) { uint16_t endpointIndex = emberAfIndexFromEndpoint(endpoint); diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index c91fae9a0e52e7..5107bf66573f49 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -114,14 +114,6 @@ uint8_t emberAfClusterIndex(chip::EndpointId endpoint, chip::ClusterId clusterId // otherwise number of client clusters on this endpoint uint8_t emberAfClusterCount(chip::EndpointId endpoint, bool server); -// If server == true, returns the number of server clusters, -// otherwise number of client clusters on the endpoint at the given index. -uint8_t emberAfClusterCountByIndex(uint16_t endpointIndex, bool server); - -// If server == true, returns the number of server clusters, -// otherwise number of client clusters on the endpoint at the given index. -uint8_t emberAfClusterCountForEndpointType(const EmberAfEndpointType * endpointType, bool server); - // Returns the cluster of Nth server or client cluster, // depending on server toggle. const EmberAfCluster * emberAfGetNthCluster(chip::EndpointId endpoint, uint8_t n, bool server); @@ -160,21 +152,12 @@ void emAfClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath EmberAfStatus emAfClusterPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); -// Check whether there is an endpoint defined with the given endpoint id that is -// enabled. -bool emberAfEndpointIsEnabled(chip::EndpointId endpoint); - -// Note the difference in implementation from emberAfGetNthCluster(). -// emberAfGetClusterByIndex() retrieves the cluster by index regardless of server/client -// and those indexes may be DIFFERENT than the indexes returned from -// emberAfGetNthCluster(). In other words: -// +// Note the difference in for server filtering. +// This method will return the cluster count for BOTH client and server +// and those do NOT work with NthCluster/NthClusterId // - Use emberAfGetClustersFromEndpoint() with emberAfGetNthCluster() emberAfGetNthClusterId() -// - Use emberAfGetClusterCountForEndpoint() with emberAfGetClusterByIndex() // -// Don't mix them. uint8_t emberAfGetClusterCountForEndpoint(chip::EndpointId endpoint); -const EmberAfCluster * emberAfGetClusterByIndex(chip::EndpointId endpoint, uint8_t clusterIndex); // // Retrieve the device type list associated with a specific endpoint.