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