From 024113d034db6daf0219ef0ae2814b45389b5919 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 30 May 2025 15:04:48 +0200 Subject: [PATCH 1/3] make code execution conditional from include esp_bt.h.h --- cores/esp32/esp32-hal-bt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 1e5f73e324c..12347cfebef 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -17,6 +17,9 @@ #if SOC_BT_SUPPORTED #ifdef CONFIG_BT_BLUEDROID_ENABLED +#if __has_include("esp_bt.h") +#include "esp_bt.h" + #if CONFIG_IDF_TARGET_ESP32 bool btInUse() { return true; @@ -28,8 +31,6 @@ __attribute__((weak)) bool btInUse() { } #endif -#include "esp_bt.h" - #ifdef CONFIG_BTDM_CONTROLLER_MODE_BTDM #define BT_MODE ESP_BT_MODE_BTDM #elif defined(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) @@ -56,7 +57,7 @@ bool btStartMode(bt_mode mode) { case BT_MODE_BTDM: esp_bt_mode = ESP_BT_MODE_BTDM; break; default: esp_bt_mode = BT_MODE; break; } - // esp_bt_controller_enable(MODE) This mode must be equal as the mode in “cfg” of esp_bt_controller_init(). + // esp_bt_controller_enable(MODE) This mode must be equal as the mode in "cfg" of esp_bt_controller_init(). cfg.mode = esp_bt_mode; if (cfg.mode == ESP_BT_MODE_CLASSIC_BT) { esp_bt_controller_mem_release(ESP_BT_MODE_BLE); @@ -116,6 +117,7 @@ bool btStop() { return false; } +#endif // __has_include("esp_bt.h") #else // CONFIG_BT_ENABLED bool btStarted() { return false; @@ -132,3 +134,4 @@ bool btStop() { #endif /* CONFIG_BT_ENABLED */ #endif /* SOC_BT_SUPPORTED */ + From 866475e96df279d7ebc5e37db17778225d96bbcc Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 30 May 2025 17:44:40 +0200 Subject: [PATCH 2/3] only one if --- cores/esp32/esp32-hal-bt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 12347cfebef..4cdd9a08c0a 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -15,9 +15,8 @@ #include "esp32-hal-bt.h" #if SOC_BT_SUPPORTED -#ifdef CONFIG_BT_BLUEDROID_ENABLED +#if defined(CONFIG_BT_BLUEDROID_ENABLED) && __has_include("esp_bt.h") -#if __has_include("esp_bt.h") #include "esp_bt.h" #if CONFIG_IDF_TARGET_ESP32 @@ -117,7 +116,6 @@ bool btStop() { return false; } -#endif // __has_include("esp_bt.h") #else // CONFIG_BT_ENABLED bool btStarted() { return false; @@ -134,4 +132,3 @@ bool btStop() { #endif /* CONFIG_BT_ENABLED */ #endif /* SOC_BT_SUPPORTED */ - From b1569b12fcb2655d961822c411296756b97288e1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 30 May 2025 17:47:52 +0200 Subject: [PATCH 3/3] Update esp32-hal-bt.c --- cores/esp32/esp32-hal-bt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 4cdd9a08c0a..5d512d448a3 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -17,8 +17,6 @@ #if SOC_BT_SUPPORTED #if defined(CONFIG_BT_BLUEDROID_ENABLED) && __has_include("esp_bt.h") -#include "esp_bt.h" - #if CONFIG_IDF_TARGET_ESP32 bool btInUse() { return true; @@ -30,6 +28,8 @@ __attribute__((weak)) bool btInUse() { } #endif +#include "esp_bt.h" + #ifdef CONFIG_BTDM_CONTROLLER_MODE_BTDM #define BT_MODE ESP_BT_MODE_BTDM #elif defined(CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY) @@ -56,7 +56,7 @@ bool btStartMode(bt_mode mode) { case BT_MODE_BTDM: esp_bt_mode = ESP_BT_MODE_BTDM; break; default: esp_bt_mode = BT_MODE; break; } - // esp_bt_controller_enable(MODE) This mode must be equal as the mode in "cfg" of esp_bt_controller_init(). + // esp_bt_controller_enable(MODE) This mode must be equal as the mode in “cfg” of esp_bt_controller_init(). cfg.mode = esp_bt_mode; if (cfg.mode == ESP_BT_MODE_CLASSIC_BT) { esp_bt_controller_mem_release(ESP_BT_MODE_BLE);