From c66a020e8067f657e730d018700e7de5b23175d4 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 21 Sep 2017 19:08:18 +0800 Subject: [PATCH] Add guards to not compile BT code if not enabled --- cores/esp32/esp32-hal-bt.c | 3 ++- .../SimpleBLE/examples/SimpleBleDevice/SimpleBleDevice.ino | 4 ++++ libraries/SimpleBLE/src/SimpleBLE.cpp | 4 ++++ libraries/SimpleBLE/src/SimpleBLE.h | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 0d19e5d5..08b8d3fd 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -14,7 +14,8 @@ #include "esp32-hal-bt.h" -#if CONFIG_BT_ENABLED +#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) + #include "bt.h" #include "esp_bt_defs.h" diff --git a/libraries/SimpleBLE/examples/SimpleBleDevice/SimpleBleDevice.ino b/libraries/SimpleBLE/examples/SimpleBleDevice/SimpleBleDevice.ino index 249363d4..03097ebc 100644 --- a/libraries/SimpleBLE/examples/SimpleBleDevice/SimpleBleDevice.ino +++ b/libraries/SimpleBLE/examples/SimpleBleDevice/SimpleBleDevice.ino @@ -16,6 +16,10 @@ // Useful if you want to advertise some sort of message // Button is attached between GPIO 0 and GND, and the device name changes each time the button is pressed +#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) +#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it +#endif + #include "SimpleBLE.h" SimpleBLE ble; diff --git a/libraries/SimpleBLE/src/SimpleBLE.cpp b/libraries/SimpleBLE/src/SimpleBLE.cpp index 01753052..59ca4327 100644 --- a/libraries/SimpleBLE/src/SimpleBLE.cpp +++ b/libraries/SimpleBLE/src/SimpleBLE.cpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) + #include "SimpleBLE.h" #include "esp32-hal-log.h" @@ -125,3 +127,5 @@ void SimpleBLE::end() { _stop_gap(); } + +#endif diff --git a/libraries/SimpleBLE/src/SimpleBLE.h b/libraries/SimpleBLE/src/SimpleBLE.h index 23ba2e7b..1da74131 100644 --- a/libraries/SimpleBLE/src/SimpleBLE.h +++ b/libraries/SimpleBLE/src/SimpleBLE.h @@ -15,6 +15,7 @@ #ifndef _SIMPLE_BLE_H_ #define _SIMPLE_BLE_H_ +#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) #include #include @@ -58,3 +59,5 @@ class SimpleBLE { }; #endif + +#endif