mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
components/esp_matter: call init function during enabling endpoint
This commit is contained in:
@@ -246,6 +246,39 @@ esp_err_t enable(endpoint_t *endpoint)
|
||||
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
|
||||
current_endpoint->enabled = true;
|
||||
init_identification(endpoint);
|
||||
chip::DeviceLayer::SystemLayer().ScheduleLambda([endpoint] {
|
||||
cluster_t *cluster = cluster::get_first(endpoint);
|
||||
while (cluster) {
|
||||
cluster::add_bounds_callback_t add_bounds_callback =
|
||||
cluster::get_add_bounds_callback(cluster);
|
||||
if (add_bounds_callback) {
|
||||
add_bounds_callback(cluster);
|
||||
}
|
||||
cluster::plugin_server_init_callback_t plugin_server_init_callback =
|
||||
cluster::get_plugin_server_init_callback(cluster);
|
||||
if (plugin_server_init_callback) {
|
||||
plugin_server_init_callback();
|
||||
}
|
||||
uint8_t flags = cluster::get_flags(cluster);
|
||||
cluster::initialization_callback_t init_callback = cluster::get_init_callback(cluster);
|
||||
if (init_callback) {
|
||||
init_callback(endpoint::get_id(endpoint));
|
||||
}
|
||||
if ((flags & CLUSTER_FLAG_SERVER) && (flags & CLUSTER_FLAG_INIT_FUNCTION)) {
|
||||
cluster::function_cluster_init_t init_function =
|
||||
(cluster::function_cluster_init_t)cluster::get_function(cluster, CLUSTER_FLAG_INIT_FUNCTION);
|
||||
if (init_function) {
|
||||
init_function(endpoint::get_id(endpoint));
|
||||
}
|
||||
}
|
||||
cluster::delegate_init_callback_t delegate_init_callback =
|
||||
cluster::get_delegate_init_callback(cluster);
|
||||
if (delegate_init_callback) {
|
||||
delegate_init_callback(cluster::get_delegate_impl(cluster), endpoint::get_id(endpoint));
|
||||
}
|
||||
cluster = cluster::get_next(cluster);
|
||||
}
|
||||
});
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,28 +235,6 @@ CHIP_ERROR provider::Startup(InteractionModelContext context)
|
||||
{
|
||||
ReturnErrorOnFailure(DataModel::Provider::Startup(context));
|
||||
mContext.emplace(context);
|
||||
esp_matter::cluster::add_bounds_callback_common();
|
||||
esp_matter::cluster::plugin_init_callback_common();
|
||||
endpoint_t *ep = endpoint::get_first(node::get());
|
||||
while (ep) {
|
||||
cluster_t *cluster = cluster::get_first(ep);
|
||||
while (cluster) {
|
||||
uint8_t flags = cluster::get_flags(cluster);
|
||||
cluster::initialization_callback_t init_callback = cluster::get_init_callback(cluster);
|
||||
if (init_callback) {
|
||||
init_callback(endpoint::get_id(ep));
|
||||
}
|
||||
if ((flags & CLUSTER_FLAG_SERVER) && (flags & CLUSTER_FLAG_INIT_FUNCTION)) {
|
||||
cluster::function_cluster_init_t init_function =
|
||||
(cluster::function_cluster_init_t)cluster::get_function(cluster, CLUSTER_FLAG_INIT_FUNCTION);
|
||||
if (init_function) {
|
||||
init_function(endpoint::get_id(ep));
|
||||
}
|
||||
}
|
||||
cluster = cluster::get_next(cluster);
|
||||
}
|
||||
ep = endpoint::get_next(ep);
|
||||
}
|
||||
if (GetAttributePersistenceProvider() == nullptr) {
|
||||
gDefaultAttributePersistence.Init(&Server::GetInstance().GetPersistentStorage());
|
||||
SetAttributePersistenceProvider(&gDefaultAttributePersistence);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user