From 36bcd8c2046f6f7d96b49c4b381b0bb4b5782dc4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 10:39:41 -1000 Subject: [PATCH 1/2] fix --- esphome/components/esp32_ble/ble.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/esphome/components/esp32_ble/ble.cpp b/esphome/components/esp32_ble/ble.cpp index e06ebaffc3..0c340c55cc 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"; @@ -132,6 +136,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) { @@ -156,6 +166,7 @@ bool ESP32BLE::ble_setup_() { return false; } } +#endif esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); @@ -247,6 +258,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) { @@ -270,6 +287,7 @@ bool ESP32BLE::ble_dismantle_() { return false; } } +#endif return true; } From d8af6e0c75e42801180563781a3c523805f8a5dd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Oct 2025 10:40:02 -1000 Subject: [PATCH 2/2] fix --- tests/components/esp32_ble/test.esp32-ard.yaml | 1 + tests/components/esp32_ble/test.esp32-c3-ard.yaml | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/components/esp32_ble/test.esp32-ard.yaml create mode 100644 tests/components/esp32_ble/test.esp32-c3-ard.yaml 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