Skip to content

Commit

Permalink
Remove emberAfIsCluster* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Jan 19, 2024
1 parent 4d33155 commit b261e2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
30 changes: 13 additions & 17 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endp
{
const EmberAfCluster * cluster = &(endpointType->cluster[i]);

if ((mask == 0 || (mask == CLUSTER_MASK_CLIENT && emberAfClusterIsClient(cluster)) ||
(mask == CLUSTER_MASK_SERVER && emberAfClusterIsServer(cluster))))
if ((mask == 0 || ((cluster->mask & mask) != 0)))
{
if (cluster->clusterId == clusterId)
{
Expand Down Expand Up @@ -1026,16 +1025,13 @@ uint8_t emberAfClusterCountByIndex(uint16_t endpointIndex, bool server)

uint8_t emberAfClusterCountForEndpointType(const EmberAfEndpointType * type, bool server)
{
const EmberAfClusterMask cluster_mask = server ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT;
uint8_t c = 0;
for (uint8_t i = 0; i < type->clusterCount; i++)
const uint8_t clusterCount = type->clusterCount;

for (uint8_t i = 0; i < clusterCount; i++)
{
auto * cluster = &(type->cluster[i]);
if (server && emberAfClusterIsServer(cluster))
{
c++;
}
if ((!server) && emberAfClusterIsClient(cluster))
{
if ((type->cluster[i].mask & cluster_mask) != 0) {
c++;
}
}
Expand Down Expand Up @@ -1136,21 +1132,21 @@ CHIP_ERROR SetTagList(EndpointId endpoint, Span<const Clusters::Descriptor::Stru
const EmberAfCluster * emberAfGetNthCluster(EndpointId endpoint, uint8_t n, bool server)
{
uint16_t index = emberAfIndexFromEndpoint(endpoint);
EmberAfDefinedEndpoint * de;
uint8_t i, c = 0;
uint8_t c = 0;
const EmberAfCluster * cluster;

if (index == kEmberInvalidEndpointIndex)
{
return nullptr;
}
de = &(emAfEndpoints[index]);

for (i = 0; i < de->endpointType->clusterCount; i++)
{
cluster = &(de->endpointType->cluster[i]);
const EmberAfEndpointType *endpointType = emAfEndpoints[index].endpointType;
const EmberAfClusterMask cluster_mask = server ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT;
const uint8_t clusterCount = endpointType->clusterCount;

if ((server && emberAfClusterIsServer(cluster)) || ((!server) && emberAfClusterIsClient(cluster)))
for (uint8_t i = 0; i < clusterCount; i++)
{
if ((endpointType->cluster[i].mask & cluster_mask) != 0)
{
if (c == n)
{
Expand Down
3 changes: 0 additions & 3 deletions src/app/util/attribute-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ extern uint8_t attributeDefaults[]; // storage bucked for > 2b default values

void emAfCallInits(void);

#define emberAfClusterIsClient(cluster) ((bool) (((cluster)->mask & CLUSTER_MASK_CLIENT) != 0))
#define emberAfClusterIsServer(cluster) ((bool) (((cluster)->mask & CLUSTER_MASK_SERVER) != 0))

// Initial configuration
void emberAfEndpointConfigure(void);

Expand Down

0 comments on commit b261e2d

Please sign in to comment.