Skip to content

Commit 0e5df1e

Browse files
committed
Merge branch 'feat/v1.4/discovery_timeout' into 'release/v1.4'
Add new API to configure ServerInitParams See merge request app-frameworks/esp-matter!1218
2 parents 0d06804 + 0602d32 commit 0e5df1e

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ variables:
2525
IDF_CHECKOUT_REF: "v5.4.1"
2626
# This variable represents the short hash of the connectedhomeip submodule.
2727
# Note: Do change this short hash on submodule update MRs.
28-
CHIP_SHORT_HASH: "87cf8e5030"
28+
CHIP_SHORT_HASH: "7a54749dc9"
2929
DOCKER_IMAGE_NAME: "espressif/chip-idf"
3030

3131
.add_gitlab_ssh_key: &add_gitlab_ssh_key |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ section in the ESP-Matter Programming Guide.
2828

2929
## Supported ESP-IDF and connectedhomeip versions
3030

31-
- This SDK currently works with commit [87cf8e5030](https://github.com/project-chip/connectedhomeip/tree/87cf8e5030) of connectedhomeip.
31+
- This SDK currently works with commit [7a54749dc9](https://github.com/project-chip/connectedhomeip/tree/7a54749dc9) of connectedhomeip.
3232
- For Matter projects development with this SDK, it is recommended to utilize ESP-IDF [v5.4.1](https://github.com/espressif/esp-idf/tree/v5.4.1).
3333

3434
## Documentation

components/esp_matter/esp_matter_core.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ using chip::DeviceLayer::ThreadStackMgr;
6666

6767
static const char *TAG = "esp_matter_core";
6868
static 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)
734735
static 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+
894909
esp_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"));

components/esp_matter/esp_matter_core.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <app/AttributePathParams.h>
2424
#include <app/CommandPathParams.h>
2525
#include <app/EventPathParams.h>
26+
#include <app/server/Server.h>
2627

2728
using chip::app::ConcreteCommandPath;
2829
using chip::DeviceLayer::ChipDeviceEvent;
@@ -45,6 +46,30 @@ typedef handle_t command_t;
4546
/** Event handle */
4647
typedef handle_t event_t;
4748

49+
/**
50+
* @brief Set the server initialization parameters for Matter.
51+
*
52+
* This function must be called before Matter is started. `esp_matter::start()`
53+
* Calling it after Matter has started will have no effect and will return an error.
54+
*
55+
* @note Starting Matter without valid initialization parameters may lead to undefined behavior or startup failure.
56+
*
57+
* @note The provided pointer is stored internally and used later during Matter initialization.
58+
* It is not copied, so the caller must ensure that the memory pointed to by `server_init_params`
59+
* remains valid and unmodified until Matter is started.
60+
*
61+
* @note If this function is called with a `nullptr`, it will still return ESP_OK. The system
62+
* will proceed with default initialization behavior.
63+
*
64+
* @param[in] server_init_params Pointer to the server initialization parameters. May be nullptr.
65+
*
66+
* @return ESP_OK Successfully set the server initialization parameters.
67+
* @return ESP_ERR_INVALID_STATE If called after Matter has already started.
68+
* @return error in case of failure.
69+
*/
70+
71+
esp_err_t set_server_init_params(chip::CommonCaseDeviceServerInitParams *server_init_params);
72+
4873
/** Event callback
4974
*
5075
* @param[in] event event data pointer.

0 commit comments

Comments
 (0)