From 5563d5716245464f58223e3356ed21c5652ccbe1 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Wed, 17 Jul 2024 14:45:09 +0530 Subject: [PATCH] components/esp-matter: Add feature the administrator commissioning cluster --- components/esp_matter/esp_matter_cluster.cpp | 8 ++++-- components/esp_matter/esp_matter_cluster.h | 2 +- components/esp_matter/esp_matter_endpoint.cpp | 3 ++- components/esp_matter/esp_matter_feature.cpp | 26 ++++++++++++++++++- components/esp_matter/esp_matter_feature.h | 12 +++++++++ 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index a2fbd31d2..04cc15393 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -543,7 +543,7 @@ namespace administrator_commissioning { const function_generic_t *function_list = NULL; const int function_flags = CLUSTER_FLAG_NONE; -cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, AdministratorCommissioning::Id, flags); if (!cluster) { @@ -575,9 +575,13 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } + /* Features */ + if (features & feature::basic::get_id()) { + feature::basic::add(cluster); + } + /* Commands */ command::create_open_commissioning_window(cluster); - command::create_open_basic_commissioning_window(cluster); command::create_revoke_commissioning(cluster); return cluster; diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 11705bee9..24b17605e 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -160,7 +160,7 @@ typedef struct config { config() : cluster_revision(1) {} } config_t; -cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); } /* administrator_commissioning */ namespace operational_credentials { diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index dc997dc17..a037a9220 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -58,7 +58,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) general_commissioning::create(endpoint, &(config->general_commissioning), CLUSTER_FLAG_SERVER); network_commissioning::create(endpoint, &(config->network_commissioning), CLUSTER_FLAG_SERVER); general_diagnostics::create(endpoint, &(config->general_diagnostics), CLUSTER_FLAG_SERVER); - administrator_commissioning::create(endpoint, &(config->administrator_commissioning), CLUSTER_FLAG_SERVER); + administrator_commissioning::create(endpoint, &(config->administrator_commissioning), CLUSTER_FLAG_SERVER, + ESP_MATTER_NONE_FEATURE_ID); operational_credentials::create(endpoint, &(config->operational_credentials), CLUSTER_FLAG_SERVER); group_key_management::create(endpoint, CLUSTER_FLAG_SERVER); diff --git a/components/esp_matter/esp_matter_feature.cpp b/components/esp_matter/esp_matter_feature.cpp index 8ed828376..5fa637bf0 100644 --- a/components/esp_matter/esp_matter_feature.cpp +++ b/components/esp_matter/esp_matter_feature.cpp @@ -82,12 +82,36 @@ esp_err_t add(cluster_t *cluster) /* Attributes managed internally */ attribute::create_tag_list(cluster, NULL, 0, 0); - return ESP_OK; } } /* taglist */ +} +} + +namespace administrator_commissioning { +namespace feature { +namespace basic { + +uint32_t get_id() +{ + return (uint32_t)AdministratorCommissioning::Feature::kBasic; +} + +esp_err_t add(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + update_feature_map(cluster, get_id()); + + command::create_open_basic_commissioning_window(cluster); + + return ESP_OK; +} +} /* basic */ } } diff --git a/components/esp_matter/esp_matter_feature.h b/components/esp_matter/esp_matter_feature.h index 0a64add9e..e0dbf5439 100644 --- a/components/esp_matter/esp_matter_feature.h +++ b/components/esp_matter/esp_matter_feature.h @@ -43,6 +43,18 @@ esp_err_t add(cluster_t *cluster); } /* feature */ } /* descriptor */ +namespace administrator_commissioning { +namespace feature { +namespace basic { + +uint32_t get_id(); +esp_err_t add(cluster_t *cluster); + +} /* basic */ + +} /* feature */ +} /* administrator_commissioning */ + namespace power_source { namespace feature { namespace wired {