From d803b87593328707d538dfa64ab0ce6fc7756706 Mon Sep 17 00:00:00 2001 From: chendejin Date: Mon, 14 Apr 2025 21:09:29 +0800 Subject: [PATCH] components/esp_matter: init identify after chip::Platform::MemoryInit (backport) --- components/esp_matter/esp_matter_cluster.cpp | 4 ---- components/esp_matter/esp_matter_core.cpp | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index 8647d1a11..f4e854f25 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -945,10 +945,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } - /* Extra initialization */ - uint16_t endpoint_id = endpoint::get_id(endpoint); - identification::init(endpoint_id, config->identify_type); - /* Commands */ command::create_identify(cluster); diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index aa2e95a09..b2d887b3d 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -513,6 +513,23 @@ esp_err_t enable(endpoint_t *endpoint) generated_command_ids = NULL; cluster_id = cluster::get_id((cluster_t*)cluster); + /* Init identify if exists and not initialized */ + if (cluster_id == chip::app::Clusters::Identify::Id && current_endpoint->identify == NULL) { + _attribute_t *identify_type_attr = (_attribute_t *)attribute::get( + current_endpoint->endpoint_id, cluster_id, chip::app::Clusters::Identify::Attributes::IdentifyType::Id); + if (identify_type_attr) { + if (identification::init(current_endpoint->endpoint_id, identify_type_attr->val.val.u8) != ESP_OK) { + ESP_LOGE(TAG, "Failed to init identification"); + err = ESP_FAIL; + break; + } + } else { + ESP_LOGE(TAG, "Can't get IdentifyType attribute in Identify cluster"); + err = ESP_ERR_INVALID_STATE; + break; + } + } + /* Client Generated Commands */ command_flag = COMMAND_FLAG_ACCEPTED; command = cluster->command_list;