Skip to content

Commit 0217ef8

Browse files
committed
Add conditional checks to ensure the stack is setup correctly.
1 parent 0ef3dec commit 0217ef8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/NimBLEDevice.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,11 @@ void NimBLEDevice::init(const std::string &deviceName) {
865865

866866
ESP_ERROR_CHECK(errRc);
867867

868+
#ifdef CONFIG_IDF_TARGET_ESP32
868869
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
870+
#endif
869871

870-
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
872+
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || !defined(CONFIG_NIMBLE_CPP_IDF)
871873
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
872874
# if defined (CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
873875
bt_cfg.bluetooth_mode = ESP_BT_MODE_BLE;
@@ -929,7 +931,7 @@ void NimBLEDevice::deinit(bool clearAll) {
929931
int ret = nimble_port_stop();
930932
if (ret == 0) {
931933
nimble_port_deinit();
932-
#if defined(CONFIG_NIMBLE_CPP_IDF)
934+
#ifdef CONFIG_NIMBLE_CPP_IDF
933935
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
934936
ret = esp_nimble_hci_and_controller_deinit();
935937
if (ret != ESP_OK) {

src/nimconfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@
293293
#define CONFIG_IDF_TARGET_ESP32 1
294294
#endif
295295

296+
#if !defined(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
297+
#define CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE 1
298+
#endif
299+
300+
#if !defined(CONFIG_BT_CONTROLLER_DISABLED)
301+
#define CONFIG_BT_CONTROLLER_DISABLED 0
302+
#endif
303+
296304
#if CONFIG_BT_NIMBLE_EXT_ADV || CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV
297305
# if defined(CONFIG_IDF_TARGET_ESP32)
298306
# error Extended advertising is not supported on ESP32.

0 commit comments

Comments
 (0)