mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
components/esp_matter: call init callbacks for endpoints created before esp_matter::start
This commit is contained in:
@@ -266,7 +266,7 @@ static esp_err_t init_identification(endpoint_t *endpoint)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void invoke_init_callbacks_internal(endpoint_t *endpoint)
|
||||
void invoke_init_callbacks_internal(endpoint_t *endpoint)
|
||||
{
|
||||
cluster_t *cluster = cluster::get_first(endpoint);
|
||||
while (cluster) {
|
||||
@@ -314,7 +314,8 @@ esp_err_t enable(endpoint_t *endpoint)
|
||||
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
|
||||
current_endpoint->enabled = true;
|
||||
init_identification(endpoint);
|
||||
{
|
||||
/* Call the init callbacks for the endpoints which are created after esp_matter::start(). (e.g. for bridged endpoints) */
|
||||
if (esp_matter::is_started()) {
|
||||
// Use the lock instead of schedule lambda to ensure the callbacks are invoked before esp_matter::start() returns.
|
||||
esp_matter::lock::ScopedChipStackLock lock(portMAX_DELAY);
|
||||
invoke_init_callbacks_internal(endpoint);
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace endpoint {
|
||||
|
||||
esp_err_t enable_all();
|
||||
|
||||
/** Invoke the init callbacks for the clusters on the endpoint
|
||||
*
|
||||
* @param[in] endpoint Endpoint handle.
|
||||
*/
|
||||
void invoke_init_callbacks_internal(endpoint_t *endpoint);
|
||||
}
|
||||
|
||||
namespace attribute {
|
||||
|
||||
@@ -466,6 +466,12 @@ CHIP_ERROR provider::Startup(InteractionModelContext context)
|
||||
ReturnErrorOnFailure(gDefaultAttributePersistence.Init(&Server::GetInstance().GetPersistentStorage()));
|
||||
SetAttributePersistenceProvider(&gDefaultAttributePersistence);
|
||||
}
|
||||
/* Call the init callbacks for the endpoints which are created before esp_matter::start() */
|
||||
endpoint_t *ep = endpoint::get_first(node::get());
|
||||
while (ep) {
|
||||
endpoint::invoke_init_callbacks_internal(ep);
|
||||
ep = endpoint::get_next(ep);
|
||||
}
|
||||
return mRegistry.SetContext(ServerClusterContext{
|
||||
.provider = *this,
|
||||
.storage = Server::GetInstance().GetPersistentStorage(),
|
||||
|
||||
Reference in New Issue
Block a user