From be91cac0b30ef6b58de8c5cad8db809660ccc24f Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Fri, 23 Aug 2024 13:11:08 +0200 Subject: [PATCH] pbsys/bluetooth: Do not use bluetooth light indicator. The main status light not blinking is enough of an indicator for now that Bluetooth is off. This way we don't have to introduce new UIs yet that get locked in the upcoming release. When we do create a new UI, we can now use the status flags instead of poking at the lights directly from the sys/bluetooth driver. --- lib/pbio/sys/bluetooth.c | 16 ++-------------- lib/pbio/sys/storage_settings.c | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/pbio/sys/bluetooth.c b/lib/pbio/sys/bluetooth.c index 7797567ee..73045ee0d 100644 --- a/lib/pbio/sys/bluetooth.c +++ b/lib/pbio/sys/bluetooth.c @@ -23,7 +23,6 @@ #include #include -#include "light.h" #include "storage.h" // REVISIT: this can be the negotiated MTU - 3 to allow for better throughput @@ -291,34 +290,23 @@ PROCESS_THREAD(pbsys_bluetooth_process, ev, data) { PROCESS_BEGIN(); - // Ensures Bluetooth preferences are loaded before we read them. - #if PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE - PROCESS_WAIT_EVENT_UNTIL(pbsys_storage_settings_get_settings() != NULL); - #endif // PBSYS_CONFIG_STORAGE && PBSYS_CONFIG_BLUETOOTH_TOGGLE - pbdrv_bluetooth_set_on_event(pbsys_bluetooth_process_poll); pbdrv_bluetooth_set_receive_handler(handle_receive); while (!pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN)) { - // Show inactive status only if user requested Bluetooth as disabled to - // avoid always flashing red in between program runs when disconnected. - if (!pbsys_storage_settings_bluetooth_enabled()) { - pbsys_status_light_bluetooth_set_color(PBIO_COLOR_RED); - } - // make sure the Bluetooth chip is in reset long enough to actually reset etimer_set(&timer, 150); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER && etimer_expired(&timer)); // Wait until Bluetooth enabled requested by user, but stop waiting on shutdown. + // If storage is not yet loaded, this will wait for that too. PROCESS_WAIT_UNTIL(pbsys_storage_settings_bluetooth_enabled() || pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN)); if (pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN)) { break; } - // Enable Bluetooth, and show on Bluetooth light if available. - pbsys_status_light_bluetooth_set_color(PBIO_COLOR_BLUE); + // Enable Bluetooth. pbdrv_bluetooth_power_on(true); PROCESS_WAIT_UNTIL(pbdrv_bluetooth_is_ready()); diff --git a/lib/pbio/sys/storage_settings.c b/lib/pbio/sys/storage_settings.c index 04888d93e..a26039260 100644 --- a/lib/pbio/sys/storage_settings.c +++ b/lib/pbio/sys/storage_settings.c @@ -75,7 +75,7 @@ bool pbsys_storage_settings_bluetooth_enabled(void) { #if PBSYS_CONFIG_BLUETOOTH_TOGGLE pbsys_storage_settings_t *settings = pbsys_storage_settings_get_settings(); if (!settings) { - return true; + return false; } return settings->flags & PBSYS_STORAGE_SETTINGS_FLAGS_BLUETOOTH_ENABLED; #else