From 9383fcd187b7c35582e4626f793f04464c0daf99 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 19 Dec 2023 15:43:19 +0530 Subject: [PATCH 1/2] Added an event when BLE is deinitialized and memory is reclaimed Fixes https://github.com/espressif/esp-matter/issues/777 --- components/esp_matter/esp_matter.h | 2 ++ components/esp_matter/esp_matter_core.cpp | 1 + examples/light/main/app_main.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/components/esp_matter/esp_matter.h b/components/esp_matter/esp_matter.h index 74ef3aa95..3a7b40de3 100644 --- a/components/esp_matter/esp_matter.h +++ b/components/esp_matter/esp_matter.h @@ -127,6 +127,8 @@ enum /** Signals that operational credentials are changed, which may not be persistent. Can be used to affect what is needed for UpdateNOC prior to commit */ kFabricUpdated, + /** Signals that BLE is deinitialized and heap memory is reclaimed */ + kBLEDeinitialized, }; } // DeviceEventType diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index 9a1b05bf3..a9bccd22b 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -876,6 +876,7 @@ static void deinit_ble_if_commissioned(void) return; } ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed"); + PostEvent(chip::DeviceLayer::DeviceEventType::kBLEDeinitialized); } #endif /* CONFIG_BT_ENABLED && CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING */ } diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index aabdb264f..b3c39040b 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -106,6 +106,11 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) case chip::DeviceLayer::DeviceEventType::kFabricCommitted: ESP_LOGI(TAG, "Fabric is committed"); break; + + case chip::DeviceLayer::DeviceEventType::kBLEDeinitialized: + ESP_LOGI(TAG, "BLE deinitialized and memory reclaimed"); + break; + default: break; } From ffbf28382de2189f190b3b5b110fc2397b013b5e Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Wed, 6 Mar 2024 14:13:32 +0800 Subject: [PATCH 2/2] Pin esp-now component to 2.4.0 --- examples/esp-now_bridge_light/main/idf_component.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/esp-now_bridge_light/main/idf_component.yml b/examples/esp-now_bridge_light/main/idf_component.yml index 05f6503ad..9cdc538aa 100644 --- a/examples/esp-now_bridge_light/main/idf_component.yml +++ b/examples/esp-now_bridge_light/main/idf_component.yml @@ -1,6 +1,6 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp-now: ">=2.2.0" + espressif/esp-now: "==2.4.0" ## Required IDF version idf: version: ">=4.1.0"