From ad33f8fc762768ac887009d6d1e8587cec06b636 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 16 Dec 2018 16:50:37 +0100 Subject: [PATCH] deinit Bluetooth while device starts if not compiled --- src/blecsan.cpp | 2 +- src/main.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/blecsan.cpp b/src/blecsan.cpp index a708948a..c4d10865 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -272,7 +272,7 @@ void stop_BLEscan(void) { ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL)); ESP_ERROR_CHECK(esp_bluedroid_disable()); ESP_ERROR_CHECK(esp_bluedroid_deinit()); - btStop(); // disable & deinit bt_controller + btStop(); // disable bt_controller ESP_ERROR_CHECK(esp_coex_preference_set(( esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib ESP_LOGI(TAG, "Bluetooth scanner stopped"); diff --git a/src/main.cpp b/src/main.cpp index 192f7973..57ea9fcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -176,7 +176,14 @@ void setup() { } else btStop(); #else + // remove bluetooth stack to gain more free memory + ESP_ERROR_CHECK(esp_bluedroid_disable()); + ESP_ERROR_CHECK(esp_bluedroid_deinit()); btStop(); + ESP_ERROR_CHECK(esp_bt_controller_deinit()); + ESP_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM)); + ESP_ERROR_CHECK(esp_coex_preference_set(( + esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib #endif // initialize button