Merge branch 'fix/delegate_initialisation' into 'main'

components/esp-matter: Fix the delegate initialization flow

See merge request app-frameworks/esp-matter!1387
This commit is contained in:
Hrishikesh Dhayagude
2026-01-14 22:08:34 +08:00
5 changed files with 19 additions and 24 deletions
@@ -143,24 +143,17 @@ void plugin_init_callback_common()
}
}
void delegate_init_callback_common()
void delegate_init_callback_common(endpoint_t *endpoint)
{
node_t *node = node::get();
/* Skip delegate_init_callback_common when ESP Matter data model is not used */
VerifyOrReturn(node);
endpoint_t *endpoint = endpoint::get_first(node);
while (endpoint) {
uint16_t endpoint_id = endpoint::get_id(endpoint);
cluster_t *cluster = get_first(endpoint);
while (cluster) {
/* Delegate server init callback */
delegate_init_callback_t delegate_init_callback = get_delegate_init_callback(cluster);
if (delegate_init_callback) {
delegate_init_callback(get_delegate_impl(cluster), endpoint_id);
}
cluster = get_next(cluster);
uint16_t endpoint_id = endpoint::get_id(endpoint);
cluster_t *cluster = get_first(endpoint);
while (cluster) {
/* Delegate server init callback */
delegate_init_callback_t delegate_init_callback = get_delegate_init_callback(cluster);
if (delegate_init_callback) {
delegate_init_callback(get_delegate_impl(cluster), endpoint_id);
}
endpoint = endpoint::get_next(endpoint);
cluster = get_next(cluster);
}
}
@@ -35,12 +35,6 @@ namespace cluster {
*/
void plugin_init_callback_common();
/** Common cluster delegate init callback
*
* This is the common delegate init callback which calls the delegate init callbacks in the clusters.
*/
void delegate_init_callback_common();
/** Common cluster add bounds callback
*
* This is the common add bounds callback which set the bounds to all the attributes of the clusters.
@@ -246,6 +246,7 @@ esp_err_t enable(endpoint_t *endpoint)
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
current_endpoint->enabled = true;
init_identification(endpoint);
esp_matter::cluster::delegate_init_callback_common(endpoint);
return ESP_OK;
}
@@ -40,6 +40,15 @@ esp_err_t enable_all();
}
namespace cluster {
/** Common cluster delegate init callback
*
* This is the common delegate init callback which calls the delegate init callbacks in the clusters.
*/
void delegate_init_callback_common(endpoint_t *endpoint);
}
namespace attribute {
/** Get the attribute value from the esp-matter storage
@@ -225,8 +225,6 @@ static void esp_matter_chip_init_task(intptr_t context)
if (endpoint::enable_all() != ESP_OK) {
ESP_LOGE(TAG, "Enable all endpoints failure");
}
// Initialise clusters which have delegate implemented
esp_matter::cluster::delegate_init_callback_common();
#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
#if CHIP_CONFIG_ENABLE_ICD_SERVER
if (!icd::get_icd_server_enabled()) {