diff --git a/components/esp_matter_controller/Kconfig b/components/esp_matter_controller/Kconfig index d2ed0720c..ba33c395b 100644 --- a/components/esp_matter_controller/Kconfig +++ b/components/esp_matter_controller/Kconfig @@ -22,7 +22,7 @@ menu "ESP Matter Controller" config ESP_MATTER_CONTROLLER_CUSTOM_CLUSTER_ENABLE bool "Enable controller custom cluster" - depends on !ESP_MATTER_COMMISSIONER_ENABLE + depends on ESP_MATTER_CONTROLLER_ENABLE && !ESP_MATTER_COMMISSIONER_ENABLE default y help Enable the custom cluster of matter controller in the ESP Matter controller for Rainmaker Fabric suppport. diff --git a/components/esp_matter_controller/controller_custom_cluster/matter_controller_cluster.cpp b/components/esp_matter_controller/controller_custom_cluster/matter_controller_cluster.cpp index d09ca869c..f012c6d58 100644 --- a/components/esp_matter_controller/controller_custom_cluster/matter_controller_cluster.cpp +++ b/components/esp_matter_controller/controller_custom_cluster/matter_controller_cluster.cpp @@ -378,7 +378,7 @@ cleanup: static esp_err_t generate_user_noc_csr(ScopedMemoryBufferWithSize &csr_pem, uint8_t fabric_index, size_t &out_len) { - uint8_t csr_der_buf[chip::Crypto::kMAX_CSR_Length]; + uint8_t csr_der_buf[chip::Crypto::kMIN_CSR_Buffer_Size]; MutableByteSpan csr_span(csr_der_buf); chip::Server::GetInstance().GetFabricTable().AllocatePendingOperationalKey(chip::MakeOptional(fabric_index), csr_span); diff --git a/components/esp_matter_controller/controller_custom_cluster/matter_controller_device_mgr.cpp b/components/esp_matter_controller/controller_custom_cluster/matter_controller_device_mgr.cpp index 184bd7bc5..6351b7ad9 100644 --- a/components/esp_matter_controller/controller_custom_cluster/matter_controller_device_mgr.cpp +++ b/components/esp_matter_controller/controller_custom_cluster/matter_controller_device_mgr.cpp @@ -35,6 +35,7 @@ namespace device_mgr { static matter_device_t *s_matter_device_list = NULL; static device_list_update_callback_t s_device_list_update_cb = NULL; static QueueHandle_t s_task_queue = NULL; +static TaskHandle_t s_device_mgr_task = NULL; static SemaphoreHandle_t s_device_mgr_mutex = NULL; typedef esp_err_t (*esp_matter_device_mgr_task_t)(void *); @@ -454,6 +455,10 @@ static esp_err_t update_device_list_task(void *endpoint_id_ptr) esp_err_t update_device_list(uint16_t endpoint_id) { + if (!s_task_queue) { + ESP_LOGE(TAG, "Failed to update device list as the task queue is not initialized"); + return ESP_ERR_INVALID_STATE; + } uint16_t *endpoint_id_ptr = (uint16_t *)malloc(sizeof(uint16_t)); *endpoint_id_ptr = endpoint_id; task_post_t task_post = { @@ -494,10 +499,13 @@ static void device_mgr_task(void *aContext) esp_err_t init(uint16_t endpoint_id, device_list_update_callback_t dev_list_update_cb) { + if (s_device_mgr_task) { + return ESP_OK; + } uint8_t fabric_index; bool user_noc_installed = false; s_device_list_update_cb = dev_list_update_cb; - if (xTaskCreate(device_mgr_task, "device_mgr", 4096, NULL, 5, NULL) != pdTRUE) { + if (xTaskCreate(device_mgr_task, "device_mgr", 4096, NULL, 5, &s_device_mgr_task) != pdTRUE) { ESP_LOGE(TAG, "Failed to create device mgr task"); return ESP_ERR_NO_MEM; }