Merge branch 'components/helper_function' into 'main'

component: helper functions to get the attribute, cluster, endpoint handle

See merge request app-frameworks/esp-matter!841
This commit is contained in:
Shu Chen
2024-08-09 16:49:39 +08:00
2 changed files with 56 additions and 0 deletions
+19
View File
@@ -1226,6 +1226,12 @@ attribute_t *get(cluster_t *cluster, uint32_t attribute_id)
return (attribute_t *)current_attribute;
}
attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id)
{
cluster_t *cluster = cluster::get(endpoint_id, cluster_id);
return get(cluster, attribute_id);
}
attribute_t *get_first(cluster_t *cluster)
{
if (!cluster) {
@@ -1811,6 +1817,12 @@ cluster_t *get(endpoint_t *endpoint, uint32_t cluster_id)
return (cluster_t *)current_cluster;
}
cluster_t *get(uint16_t endpoint_id, uint32_t cluster_id)
{
endpoint_t *endpoint = endpoint::get(endpoint_id);
return get(endpoint, cluster_id);
}
cluster_t *get_first(endpoint_t *endpoint)
{
if (!endpoint) {
@@ -2076,6 +2088,13 @@ endpoint_t *get(node_t *node, uint16_t endpoint_id)
return (endpoint_t *)current_endpoint;
}
endpoint_t *get(uint16_t endpoint_id)
{
node_t *node = node::get();
return get(node, endpoint_id);
}
endpoint_t *get_first(node_t *node)
{
if (!node) {
+37
View File
@@ -185,6 +185,17 @@ esp_err_t destroy(node_t *node, endpoint_t *endpoint);
*/
endpoint_t *get(node_t *node, uint16_t endpoint_id);
/** Get endpoint
*
* Get the endpoint present on the node.
*
* @param[in] endpoint_id Endpoint ID of the endpoint.
*
* @return Endpoint handle on success.
* @return NULL in case of failure.
*/
endpoint_t *get(uint16_t endpoint_id);
/** Get first endpoint
*
* Get the first endpoint present on the node.
@@ -377,6 +388,18 @@ cluster_t *create(endpoint_t *endpoint, uint32_t cluster_id, uint8_t flags);
*/
cluster_t *get(endpoint_t *endpoint, uint32_t cluster_id);
/** Get cluster
*
* Get the cluster present on the endpoint.
*
* @param[in] endpoint_id Endpoint id.
* @param[in] cluster_id Cluster ID for the cluster.
*
* @return Cluster handle on success.
* @return NULL in case of failure.
*/
cluster_t *get(uint16_t endpoint_id, uint32_t cluster_id);
/** Get first cluster
*
* Get the first cluster present on the endpoint.
@@ -516,6 +539,20 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint8_t flags, es
*/
attribute_t *get(cluster_t *cluster, uint32_t attribute_id);
/** Get attribute
*
* Get the attribute present on the cluster.
*
* @param[in] endpoint_id Endpoint id..
* @param[in] cluster_id Cluster ID for the Cluster.
* @param[in] attribute_id Attribute ID for the attribute.
*
* @return Attribute handle on success.
* @return NULL in case of failure.
*/
attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id);
/** Get first attribute
*
* Get the first attribute present on the cluster.