@@ -203,6 +203,7 @@ bool pbsys_bluetooth_tx_is_idle(void) {
203203 return !send_busy && lwrb_get_full (& stdout_ring_buf ) == 0 ;
204204}
205205
206+ #if PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE
206207static pbsys_storage_settings_t * settings ;
207208
208209bool pbsys_bluetooth_is_user_enabled (void ) {
@@ -233,6 +234,13 @@ void pbsys_bluetooth_is_user_enabled_request_toggle(void) {
233234 pbsys_storage_request_write ();
234235 pbsys_bluetooth_process_poll ();
235236}
237+ #else // PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE
238+ bool pbsys_bluetooth_is_user_enabled (void ) {
239+ return true;
240+ }
241+ void pbsys_bluetooth_is_user_enabled_request_toggle (void ) {
242+ }
243+ #endif // PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE
236244
237245// Contiki process
238246
@@ -321,7 +329,9 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
321329
322330 PROCESS_BEGIN ();
323331
332+ #if PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE
324333 PROCESS_WAIT_EVENT_UNTIL (pbsys_storage_get_settings (& settings ) == PBIO_SUCCESS );
334+ #endif // PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE
325335
326336 pbdrv_bluetooth_set_on_event (pbsys_bluetooth_process_poll );
327337 pbdrv_bluetooth_set_receive_handler (handle_receive );
@@ -330,7 +340,7 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
330340
331341 // Show inactive status only if user requested Bluetooth as disabled to
332342 // avoid always flashing red in between program runs when disconnected.
333- if (!settings -> bluetooth_ble_user_enabled ) {
343+ if (!pbsys_bluetooth_is_user_enabled () ) {
334344 pbsys_status_light_bluetooth_set_color (PBIO_COLOR_RED );
335345 }
336346
@@ -339,7 +349,7 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
339349 PROCESS_WAIT_EVENT_UNTIL (ev == PROCESS_EVENT_TIMER && etimer_expired (& timer ));
340350
341351 // Wait until Bluetooth enabled requested by user, but stop waiting on shutdown.
342- PROCESS_WAIT_UNTIL (settings -> bluetooth_ble_user_enabled || pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN ));
352+ PROCESS_WAIT_UNTIL (pbsys_bluetooth_is_user_enabled () || pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN ));
343353 if (pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN )) {
344354 break ;
345355 }
@@ -360,7 +370,7 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
360370 pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )
361371 || pbsys_status_test (PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING )
362372 || pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN )
363- || !settings -> bluetooth_ble_user_enabled );
373+ || !pbsys_bluetooth_is_user_enabled () );
364374
365375 // Now change the state depending on which of the above was triggered.
366376
@@ -379,7 +389,7 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
379389 // The Bluetooth enabled flag can only change while disconnected and
380390 // while no program is running. So here it just serves to skip the
381391 // Bluetooth loop below and go directly to the disable step below it.
382- while (settings -> bluetooth_ble_user_enabled
392+ while (pbsys_bluetooth_is_user_enabled ()
383393 && pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )
384394 && !pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN )) {
385395
0 commit comments