diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 0d73c2eb86..05d3827489 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -290,7 +290,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_get_previous_traceback_obj, supervisor_get_ //| ... //| STATIC mp_obj_t supervisor_disable_ble_workflow(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE + mp_raise_NotImplementedError(NULL); + #else supervisor_bluetooth_disable_workflow(); + #endif return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow); diff --git a/supervisor/shared/bluetooth/bluetooth.c b/supervisor/shared/bluetooth/bluetooth.c index 1db027bf7d..7762a5655d 100644 --- a/supervisor/shared/bluetooth/bluetooth.c +++ b/supervisor/shared/bluetooth/bluetooth.c @@ -95,12 +95,8 @@ STATIC bool ble_started = false; STATIC uint8_t workflow_state = WORKFLOW_UNSET; STATIC bool was_connected = false; -#endif STATIC void supervisor_bluetooth_start_advertising(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - return; - #else if (workflow_state != WORKFLOW_ENABLED) { return; } @@ -144,16 +140,15 @@ STATIC void supervisor_bluetooth_start_advertising(void) { NULL); // This may fail if we are already advertising. advertising = status == NRF_SUCCESS; - #endif } +#endif // CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE + #define BLE_DISCOVERY_DATA_GUARD 0xbb0000bb #define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff void supervisor_bluetooth_init(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - return; - #endif + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE uint32_t reset_state = port_get_saved_word(); uint32_t ble_mode = 0; if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) { @@ -223,9 +218,11 @@ void supervisor_bluetooth_init(void) { status_led_deinit(); #endif port_set_saved_word(reset_state); + #endif } void supervisor_bluetooth_background(void) { + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE if (!ble_started) { return; } @@ -244,12 +241,11 @@ void supervisor_bluetooth_background(void) { #if CIRCUITPY_BLE_FILE_SERVICE supervisor_bluetooth_file_transfer_background(); #endif + #endif } void supervisor_start_bluetooth(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - return; - #endif + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE if (workflow_state != WORKFLOW_ENABLED) { return; @@ -270,12 +266,12 @@ void supervisor_start_bluetooth(void) { // Kick off advertisements supervisor_bluetooth_background(); + + #endif } void supervisor_stop_bluetooth(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - return; - #endif + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE if (!ble_started && workflow_state != WORKFLOW_ENABLED) { return; @@ -284,24 +280,22 @@ void supervisor_stop_bluetooth(void) { #if CIRCUITPY_SERIAL_BLE supervisor_stop_bluetooth_serial(); #endif + + #endif } void supervisor_bluetooth_enable_workflow(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - return; - #endif - + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE if (workflow_state == WORKFLOW_DISABLED) { return; } workflow_state = WORKFLOW_ENABLED; + #endif } void supervisor_bluetooth_disable_workflow(void) { - #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE - mp_raise_NotImplementedError(); - #endif - + #if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE workflow_state = WORKFLOW_DISABLED; + #endif }