Skip to content

Commit

Permalink
Add API to find if an endpoint of given index contains the ZCL server. (
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored and pull[bot] committed Apr 13, 2022
1 parent 5225d41 commit ecf9154
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ bool emberAfContainsServerWithMfgCode(chip::EndpointId endpoint, chip::ClusterId
*/
bool emberAfContainsServer(chip::EndpointId endpoint, chip::ClusterId clusterId);

/**
* @brief Returns true if endpoint of given index contains the ZCL server with specified id.
*
* This function returns true if
* the endpoint of given index contains server of a given cluster.
* If this function is used with a manufacturer specific clusterId
* then this will return the first cluster that it finds in the Cluster table.
* and will not return any other clusters that share that id.
*/
bool emberAfContainsServerFromIndex(uint16_t index, chip::ClusterId clusterId);

/**
* @brief Returns true if endpoint contains cluster client.
*
Expand Down
14 changes: 14 additions & 0 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,20 @@ bool emberAfContainsClient(EndpointId endpoint, ClusterId clusterId)
return (emberAfFindClusterWithMfgCode(endpoint, clusterId, CLUSTER_MASK_CLIENT, EMBER_AF_NULL_MANUFACTURER_CODE) != NULL);
}

// This will find the first server that has the clusterId given from the index of endpoint, regardless of mfgCode.
bool emberAfContainsServerFromIndex(uint16_t index, ClusterId clusterId)
{
if (index == 0xFFFF)
{
return false;
}
else
{
return emberAfFindClusterInTypeWithMfgCode(emAfEndpoints[index].endpointType, clusterId, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
}
}

// Finds the cluster that matches endpoint, clusterId, direction, and manufacturerCode.
EmberAfCluster * emberAfFindClusterWithMfgCode(EndpointId endpoint, ClusterId clusterId, EmberAfClusterMask mask,
uint16_t manufacturerCode)
Expand Down

0 comments on commit ecf9154

Please sign in to comment.