@@ -66,6 +66,7 @@ using chip::DeviceLayer::ThreadStackMgr;
6666
6767static const char *TAG = " esp_matter_core" ;
6868static bool esp_matter_started = false ;
69+ static chip::CommonCaseDeviceServerInitParams *s_server_init_params = nullptr ;
6970
7071#ifndef CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
7172// If Matter Server is disabled, these functions are required by InteractionModelEngine but not linked
@@ -734,11 +735,18 @@ static void deinit_ble_if_commissioned(intptr_t unused)
734735static void esp_matter_chip_init_task (intptr_t context)
735736{
736737 TaskHandle_t task_to_notify = reinterpret_cast <TaskHandle_t>(context);
737- static chip::CommonCaseDeviceServerInitParams initParams;
738+ static chip::CommonCaseDeviceServerInitParams defaultInitParams;
739+
740+ chip::CommonCaseDeviceServerInitParams &initParams =
741+ s_server_init_params ? *s_server_init_params : defaultInitParams;
738742
739743 initParams.InitializeStaticResourcesBeforeServerInit ();
740- initParams.appDelegate = &s_app_delegate;
741- initParams.testEventTriggerDelegate = test_event_trigger::get_delegate ();
744+ if (!initParams.appDelegate ) {
745+ initParams.appDelegate = &s_app_delegate;
746+ }
747+ if (!initParams.testEventTriggerDelegate ) {
748+ initParams.testEventTriggerDelegate = test_event_trigger::get_delegate ();
749+ }
742750
743751#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
744752 // Group data provider injection for dynamic data model
@@ -891,6 +899,13 @@ bool is_started()
891899 return esp_matter_started;
892900}
893901
902+ esp_err_t set_server_init_params (chip::CommonCaseDeviceServerInitParams *server_init_params)
903+ {
904+ VerifyOrReturnError (!esp_matter_started, ESP_ERR_INVALID_STATE, ESP_LOGE (TAG, " esp_matter has started" ));
905+ s_server_init_params = server_init_params;
906+ return ESP_OK;
907+ }
908+
894909esp_err_t start (event_callback_t callback, intptr_t callback_arg)
895910{
896911 VerifyOrReturnError (!esp_matter_started, ESP_ERR_INVALID_STATE, ESP_LOGE (TAG, " esp_matter has started" ));
0 commit comments