From e8f71415644846ca0f4195afcad4a9e8b2469ded Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 20 Feb 2020 12:15:56 -0800 Subject: [PATCH] Disable BLE file service for now Fixes #2633 --- py/circuitpy_mpconfig.mk | 5 +++++ supervisor/shared/bluetooth.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 93e5982d5c..d6e033daf3 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -328,6 +328,11 @@ CIRCUITPY_SERIAL_BLE = 0 endif CFLAGS += -DCIRCUITPY_SERIAL_BLE=$(CIRCUITPY_SERIAL_BLE) +ifndef CIRCUITPY_BLE_FILE_SERVICE +CIRCUITPY_BLE_FILE_SERVICE = 0 +endif +CFLAGS += -DCIRCUITPY_BLE_FILE_SERVICE=$(CIRCUITPY_BLE_FILE_SERVICE) + # REPL over UART ifndef CIRCUITPY_SERIAL_UART CIRCUITPY_SERIAL_UART = 0 diff --git a/supervisor/shared/bluetooth.c b/supervisor/shared/bluetooth.c index 18caa2eb4a..b463160cf5 100644 --- a/supervisor/shared/bluetooth.c +++ b/supervisor/shared/bluetooth.c @@ -64,6 +64,9 @@ mp_obj_list_t characteristic_list; mp_obj_t characteristic_list_items[4]; void supervisor_bluetooth_start_advertising(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif bool is_connected = common_hal_bleio_adapter_get_connected(&common_hal_bleio_adapter_obj); if (is_connected) { return; @@ -79,6 +82,10 @@ void supervisor_bluetooth_start_advertising(void) { } void supervisor_start_bluetooth(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, true); supervisor_ble_service_uuid.base.type = &bleio_uuid_type; @@ -203,6 +210,9 @@ uint32_t current_command[1024 / sizeof(uint32_t)]; volatile size_t current_offset; void supervisor_bluetooth_background(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif if (!run_ble_background) { return; } @@ -296,6 +306,9 @@ void supervisor_bluetooth_background(void) { // This happens in an interrupt so we need to be quick. bool supervisor_bluetooth_hook(ble_evt_t *ble_evt) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return false; + #endif // Catch writes to filename or contents. Length is read-only. bool done = false;