@@ -311,52 +311,23 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
311311 etimer_set (& timer , 150 );
312312 PROCESS_WAIT_EVENT_UNTIL (ev == PROCESS_EVENT_TIMER && etimer_expired (& timer ));
313313
314- // Wait until Bluetooth enabled requested by user, but stop waiting on shutdown.
315- // If storage is not yet loaded, this will wait for that too.
316- PROCESS_WAIT_UNTIL (pbsys_storage_settings_bluetooth_enabled () || pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST ));
317- if (pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST )) {
318- break ;
319- }
320-
321314 // Enable Bluetooth.
322315 pbdrv_bluetooth_power_on (true);
323316 PROCESS_WAIT_UNTIL (pbdrv_bluetooth_is_ready ());
324317
325- // Start advertising, and show visual indicator on status light.
326- pbdrv_bluetooth_start_advertising ();
327- pbsys_status_set (PBIO_PYBRICKS_STATUS_BLE_ADVERTISING );
328-
329318 // Now we are idle. We need to change the Bluetooth state and
330319 // indicators if a host connects to us, or a user program starts, or we
331320 // shut down, or Bluetooth is disabled by the user.
332321 PROCESS_WAIT_UNTIL (
333322 pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )
334- || pbsys_status_test (PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING )
335- || pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST )
336- || !pbsys_storage_settings_bluetooth_enabled ());
337-
338- // Now change the state depending on which of the above was triggered.
339-
340- // If connected, advertising stops automatically. Otherwise manually
341- // stop advertising (if the user code started using the button or we
342- // are shutting down or or BLE became disabled).
343- if (pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )) {
344- pbsys_status_set (PBIO_PYBRICKS_STATUS_BLE_HOST_CONNECTED );
345- } else {
346- pbdrv_bluetooth_stop_advertising ();
347- pbsys_status_clear (PBIO_PYBRICKS_STATUS_BLE_HOST_CONNECTED ); // REVISIT: also via state...
348- }
349-
350- // In all cases, clear the advertising flag to stop blinking.
351- pbsys_status_clear (PBIO_PYBRICKS_STATUS_BLE_ADVERTISING );
323+ );
352324
353325 PT_INIT (& status_monitor_pt );
354326
355327 // The Bluetooth enabled flag can only change while disconnected and
356328 // while no program is running. So here it just serves to skip the
357329 // Bluetooth loop below and go directly to the disable step below it.
358- while (pbsys_storage_settings_bluetooth_enabled ()
359- && pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )
330+ while (pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_LE )
360331 && !pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST )) {
361332
362333 if (pbdrv_bluetooth_is_connected (PBDRV_BLUETOOTH_CONNECTION_PYBRICKS )) {
@@ -391,9 +362,6 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) {
391362 PROCESS_WAIT_EVENT ();
392363 }
393364
394- pbsys_status_clear (PBIO_PYBRICKS_STATUS_BLE_HOST_CONNECTED );
395- pbsys_status_clear (PBIO_PYBRICKS_STATUS_BLE_ADVERTISING );
396-
397365 reset_all ();
398366 PROCESS_WAIT_WHILE (pbsys_status_test (PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING ));
399367
0 commit comments