@@ -236,8 +236,9 @@ String BLEDevice::getValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID ch
236236 */
237237void BLEDevice::init (String deviceName) {
238238 if (!initialized) {
239- [[maybe_unused]] esp_err_t errRc = ESP_OK;
240- #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_NIMBLE_ENABLED)
239+ esp_err_t errRc = ESP_OK;
240+ #if defined(CONFIG_BLUEDROID_ENABLED)
241+ #if defined(ARDUINO_ARCH_ESP32)
241242 if (!btStart ()) {
242243 errRc = ESP_FAIL;
243244 return ;
@@ -261,7 +262,6 @@ void BLEDevice::init(String deviceName) {
261262 esp_bt_controller_mem_release (ESP_BT_MODE_CLASSIC_BT);
262263#endif
263264
264- #ifdef CONFIG_BLUEDROID_ENABLED
265265 esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT ();
266266 errRc = esp_bt_controller_init (&bt_cfg);
267267 if (errRc != ESP_OK) {
@@ -282,6 +282,7 @@ void BLEDevice::init(String deviceName) {
282282 return ;
283283 }
284284#endif
285+ #endif // !ARDUINO_ARCH_ESP32
285286
286287 esp_bluedroid_status_t bt_state = esp_bluedroid_get_status ();
287288 if (bt_state == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
@@ -335,8 +336,8 @@ void BLEDevice::init(String deviceName) {
335336 log_e (" esp_ble_gap_set_security_param: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
336337 return ;
337338 };
338- #endif
339339#endif // CONFIG_BLE_SMP_ENABLE
340+ #endif // CONFIG_BLUEDROID_ENABLED
340341
341342#if defined(CONFIG_NIMBLE_ENABLED)
342343 errRc = nimble_port_init ();
@@ -373,7 +374,6 @@ void BLEDevice::init(String deviceName) {
373374 while (!m_synced) {
374375 ble_npl_time_delay (1 );
375376 }
376- #endif
377377#endif // CONFIG_NIMBLE_ENABLED
378378 initialized = true ; // Set the initialization flag to ensure we are only initialized once.
379379 }
0 commit comments