Skip to content

Commit

Permalink
Rename emberAfFindCluster to emberAfFindServerCluster and remove the …
Browse files Browse the repository at this point in the history
…mask attribute - we always search for servers (#23329)
  • Loading branch information
andy31415 authored Oct 26, 2022
1 parent 9bd5049 commit e2571a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType)
// This function is used to call the per-cluster attribute changed callback
void emAfClusterAttributeChangedCallback(const app::ConcreteAttributePath & attributePath)
{
const EmberAfCluster * cluster = emberAfFindCluster(attributePath.mEndpointId, attributePath.mClusterId, CLUSTER_MASK_SERVER);
const EmberAfCluster * cluster = emberAfFindServerCluster(attributePath.mEndpointId, attributePath.mClusterId);
if (cluster != nullptr)
{
EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_ATTRIBUTE_CHANGED_FUNCTION);
Expand All @@ -313,7 +313,7 @@ void emAfClusterAttributeChangedCallback(const app::ConcreteAttributePath & attr
EmberAfStatus emAfClusterPreAttributeChangedCallback(const app::ConcreteAttributePath & attributePath,
EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
{
const EmberAfCluster * cluster = emberAfFindCluster(attributePath.mEndpointId, attributePath.mClusterId, CLUSTER_MASK_SERVER);
const EmberAfCluster * cluster = emberAfFindServerCluster(attributePath.mEndpointId, attributePath.mClusterId);
if (cluster == nullptr)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
Expand Down Expand Up @@ -666,7 +666,7 @@ uint8_t emberAfClusterIndex(EndpointId endpoint, ClusterId clusterId, EmberAfClu
// Returns whether the given endpoint has the server of the given cluster on it.
bool emberAfContainsServer(EndpointId endpoint, ClusterId clusterId)
{
return (emberAfFindCluster(endpoint, clusterId, CLUSTER_MASK_SERVER) != nullptr);
return (emberAfFindServerCluster(endpoint, clusterId) != nullptr);
}

// This will find the first server that has the clusterId given from the index of endpoint.
Expand Down Expand Up @@ -714,15 +714,15 @@ void EnabledEndpointsWithServerCluster::EnsureMatchingEndpoint()
} // namespace chip

// Finds the cluster that matches endpoint, clusterId, direction.
const EmberAfCluster * emberAfFindCluster(EndpointId endpoint, ClusterId clusterId, EmberAfClusterMask mask)
const EmberAfCluster * emberAfFindServerCluster(EndpointId endpoint, ClusterId clusterId)
{
uint16_t ep = emberAfIndexFromEndpoint(endpoint);
if (ep == kEmberInvalidEndpointIndex)
{
return nullptr;
}

return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, mask);
return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, CLUSTER_MASK_SERVER);
}

// Returns cluster within the endpoint; Does not ignore disabled endpoints
Expand All @@ -748,7 +748,7 @@ static uint16_t findClusterEndpointIndex(EndpointId endpoint, ClusterId clusterI
{
uint16_t i, epi = 0;

if (emberAfFindCluster(endpoint, clusterId, mask) == nullptr)
if (emberAfFindServerCluster(endpoint, clusterId) == nullptr)
{
return kEmberInvalidEndpointIndex;
}
Expand Down Expand Up @@ -1366,15 +1366,15 @@ app::AttributeAccessInterface * GetAttributeAccessOverride(EndpointId endpointId

uint16_t emberAfGetServerAttributeCount(chip::EndpointId endpoint, chip::ClusterId cluster)
{
const EmberAfCluster * clusterObj = emberAfFindCluster(endpoint, cluster, CLUSTER_MASK_SERVER);
const EmberAfCluster * clusterObj = emberAfFindServerCluster(endpoint, cluster);
VerifyOrReturnError(clusterObj != nullptr, 0);
return clusterObj->attributeCount;
}

uint16_t emberAfGetServerAttributeIndexByAttributeId(chip::EndpointId endpoint, chip::ClusterId cluster,
chip::AttributeId attributeId)
{
const EmberAfCluster * clusterObj = emberAfFindCluster(endpoint, cluster, CLUSTER_MASK_SERVER);
const EmberAfCluster * clusterObj = emberAfFindServerCluster(endpoint, cluster);
VerifyOrReturnError(clusterObj != nullptr, UINT16_MAX);

for (uint16_t i = 0; i < clusterObj->attributeCount; i++)
Expand All @@ -1389,7 +1389,7 @@ uint16_t emberAfGetServerAttributeIndexByAttributeId(chip::EndpointId endpoint,

Optional<AttributeId> emberAfGetServerAttributeIdByIndex(EndpointId endpoint, ClusterId cluster, uint16_t attributeIndex)
{
const EmberAfCluster * clusterObj = emberAfFindCluster(endpoint, cluster, CLUSTER_MASK_SERVER);
const EmberAfCluster * clusterObj = emberAfFindServerCluster(endpoint, cluster);
if (clusterObj == nullptr || clusterObj->attributeCount <= attributeIndex)
{
return Optional<AttributeId>::Missing();
Expand Down
7 changes: 2 additions & 5 deletions src/app/util/attribute-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,8 @@ chip::Optional<chip::ClusterId> emberAfGetNthClusterId(chip::EndpointId endpoint
// for the given endpoint and client/server polarity
uint8_t emberAfGetClustersFromEndpoint(chip::EndpointId endpoint, chip::ClusterId * clusterList, uint8_t listLen, bool server);

// Returns cluster within the endpoint, or NULL if it isn't there
//
// TODO: we likely now only have mask as CLUSTER_MASK_SERVER so this
// method should be renamed to emberAfFindServerCluster or similar and simplify the code.
const EmberAfCluster * emberAfFindCluster(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfClusterMask mask);
// Returns server cluster within the endpoint, or NULL if it isn't there
const EmberAfCluster * emberAfFindServerCluster(chip::EndpointId endpoint, chip::ClusterId clusterId);

// Returns cluster within the endpoint; Does not ignore disabled endpoints
const EmberAfCluster * emberAfFindClusterIncludingDisabledEndpoints(chip::EndpointId endpoint, chip::ClusterId clusterId,
Expand Down
4 changes: 2 additions & 2 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath)
{
if (attr == aPath.mAttributeId)
{
return (emberAfFindCluster(aPath.mEndpointId, aPath.mClusterId, CLUSTER_MASK_SERVER) != nullptr);
return (emberAfFindServerCluster(aPath.mEndpointId, aPath.mClusterId) != nullptr);
}
}
return (emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId) != nullptr);
Expand All @@ -563,7 +563,7 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b
if (attr == aPath.mAttributeId)
{
isGlobalAttributeNotInMetadata = true;
attributeCluster = emberAfFindCluster(aPath.mEndpointId, aPath.mClusterId, CLUSTER_MASK_SERVER);
attributeCluster = emberAfFindServerCluster(aPath.mEndpointId, aPath.mClusterId);
break;
}
}
Expand Down

0 comments on commit e2571a0

Please sign in to comment.