diff --git a/esphome/components/esp32_ble/ble.cpp b/esphome/components/esp32_ble/ble.cpp index 3139e3f8ab..41a90150ef 100644 --- a/esphome/components/esp32_ble/ble.cpp +++ b/esphome/components/esp32_ble/ble.cpp @@ -15,6 +15,10 @@ #include #include +#ifdef USE_ARDUINO +#include +#endif + namespace esphome::esp32_ble { static const char *const TAG = "esp32_ble"; @@ -136,6 +140,12 @@ void ESP32BLE::advertising_init_() { bool ESP32BLE::ble_setup_() { esp_err_t err; +#ifdef USE_ARDUINO + if (!btStart()) { + ESP_LOGE(TAG, "btStart failed: %d", esp_bt_controller_get_status()); + return false; + } +#else if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) { // start bt controller if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) { @@ -160,6 +170,7 @@ bool ESP32BLE::ble_setup_() { return false; } } +#endif esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); @@ -251,6 +262,12 @@ bool ESP32BLE::ble_dismantle_() { return false; } +#ifdef USE_ARDUINO + if (!btStop()) { + ESP_LOGE(TAG, "btStop failed: %d", esp_bt_controller_get_status()); + return false; + } +#else if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) { // stop bt controller if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED) { @@ -274,6 +291,7 @@ bool ESP32BLE::ble_dismantle_() { return false; } } +#endif return true; } diff --git a/tests/components/esp32_ble/test.esp32-ard.yaml b/tests/components/esp32_ble/test.esp32-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esp32_ble/test.esp32-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/esp32_ble/test.esp32-c3-ard.yaml b/tests/components/esp32_ble/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esp32_ble/test.esp32-c3-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml