Skip to content

Commit 713c8e7

Browse files
committed
Fix builds without the ble workflow
1 parent 1e22561 commit 713c8e7

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

shared-bindings/supervisor/__init__.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_get_previous_traceback_obj, supervisor_get_
290290
//| ...
291291
//|
292292
STATIC mp_obj_t supervisor_disable_ble_workflow(void) {
293+
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
294+
mp_raise_NotImplementedError(NULL);
295+
#else
293296
supervisor_bluetooth_disable_workflow();
297+
#endif
294298
return mp_const_none;
295299
}
296300
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow);

supervisor/shared/bluetooth/bluetooth.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,8 @@ STATIC bool ble_started = false;
9595

9696
STATIC uint8_t workflow_state = WORKFLOW_UNSET;
9797
STATIC bool was_connected = false;
98-
#endif
9998

10099
STATIC void supervisor_bluetooth_start_advertising(void) {
101-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
102-
return;
103-
#else
104100
if (workflow_state != WORKFLOW_ENABLED) {
105101
return;
106102
}
@@ -144,16 +140,15 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
144140
NULL);
145141
// This may fail if we are already advertising.
146142
advertising = status == NRF_SUCCESS;
147-
#endif
148143
}
149144

145+
#endif // CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
146+
150147
#define BLE_DISCOVERY_DATA_GUARD 0xbb0000bb
151148
#define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff
152149

153150
void supervisor_bluetooth_init(void) {
154-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
155-
return;
156-
#endif
151+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
157152
uint32_t reset_state = port_get_saved_word();
158153
uint32_t ble_mode = 0;
159154
if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) {
@@ -223,9 +218,11 @@ void supervisor_bluetooth_init(void) {
223218
status_led_deinit();
224219
#endif
225220
port_set_saved_word(reset_state);
221+
#endif
226222
}
227223

228224
void supervisor_bluetooth_background(void) {
225+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
229226
if (!ble_started) {
230227
return;
231228
}
@@ -244,12 +241,11 @@ void supervisor_bluetooth_background(void) {
244241
#if CIRCUITPY_BLE_FILE_SERVICE
245242
supervisor_bluetooth_file_transfer_background();
246243
#endif
244+
#endif
247245
}
248246

249247
void supervisor_start_bluetooth(void) {
250-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
251-
return;
252-
#endif
248+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
253249

254250
if (workflow_state != WORKFLOW_ENABLED) {
255251
return;
@@ -270,12 +266,12 @@ void supervisor_start_bluetooth(void) {
270266

271267
// Kick off advertisements
272268
supervisor_bluetooth_background();
269+
270+
#endif
273271
}
274272

275273
void supervisor_stop_bluetooth(void) {
276-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
277-
return;
278-
#endif
274+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
279275

280276
if (!ble_started && workflow_state != WORKFLOW_ENABLED) {
281277
return;
@@ -284,24 +280,22 @@ void supervisor_stop_bluetooth(void) {
284280
#if CIRCUITPY_SERIAL_BLE
285281
supervisor_stop_bluetooth_serial();
286282
#endif
287-
}
288283

289-
void supervisor_bluetooth_enable_workflow(void) {
290-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
291-
return;
292284
#endif
285+
}
293286

287+
void supervisor_bluetooth_enable_workflow(void) {
288+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
294289
if (workflow_state == WORKFLOW_DISABLED) {
295290
return;
296291
}
297292

298293
workflow_state = WORKFLOW_ENABLED;
294+
#endif
299295
}
300296

301297
void supervisor_bluetooth_disable_workflow(void) {
302-
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
303-
mp_raise_NotImplementedError();
304-
#endif
305-
298+
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
306299
workflow_state = WORKFLOW_DISABLED;
300+
#endif
307301
}

0 commit comments

Comments
 (0)