@@ -236,8 +236,9 @@ String BLEDevice::getValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID ch
236
236
*/
237
237
void BLEDevice::init (String deviceName) {
238
238
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)
241
242
if (!btStart ()) {
242
243
errRc = ESP_FAIL;
243
244
return ;
@@ -261,7 +262,6 @@ void BLEDevice::init(String deviceName) {
261
262
esp_bt_controller_mem_release (ESP_BT_MODE_CLASSIC_BT);
262
263
#endif
263
264
264
- #ifdef CONFIG_BLUEDROID_ENABLED
265
265
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT ();
266
266
errRc = esp_bt_controller_init (&bt_cfg);
267
267
if (errRc != ESP_OK) {
@@ -282,6 +282,7 @@ void BLEDevice::init(String deviceName) {
282
282
return ;
283
283
}
284
284
#endif
285
+ #endif // !ARDUINO_ARCH_ESP32
285
286
286
287
esp_bluedroid_status_t bt_state = esp_bluedroid_get_status ();
287
288
if (bt_state == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
@@ -335,8 +336,8 @@ void BLEDevice::init(String deviceName) {
335
336
log_e (" esp_ble_gap_set_security_param: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
336
337
return ;
337
338
};
338
- #endif
339
339
#endif // CONFIG_BLE_SMP_ENABLE
340
+ #endif // CONFIG_BLUEDROID_ENABLED
340
341
341
342
#if defined(CONFIG_NIMBLE_ENABLED)
342
343
errRc = nimble_port_init ();
@@ -373,7 +374,6 @@ void BLEDevice::init(String deviceName) {
373
374
while (!m_synced) {
374
375
ble_npl_time_delay (1 );
375
376
}
376
- #endif
377
377
#endif // CONFIG_NIMBLE_ENABLED
378
378
initialized = true ; // Set the initialization flag to ensure we are only initialized once.
379
379
}
0 commit comments