From 531475e3511e9c722677d3a351b51d4a579876df Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 23 Apr 2024 10:19:25 +1000 Subject: [PATCH] Enable bluetooth after boot, not during boot This avoids some bluetooth-related devices being delivered before BootComplete --- src/audio/audio_fsm.cpp | 2 ++ src/system_fsm/booting.cpp | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index 91ba7df0..ffb462f8 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -442,6 +442,8 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) { drivers::NvsStorage::Output::kHeadphones) { sOutput = sI2SOutput; } else { + // Ensure Bluetooth gets enabled if it's the default sink. + sServices->bluetooth().Enable(); sOutput = sBtOutput; } sOutput->mode(IAudioOutput::Modes::kOnPaused); diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp index a89f35d9..44700cc4 100644 --- a/src/system_fsm/booting.cpp +++ b/src/system_fsm/booting.cpp @@ -109,12 +109,6 @@ auto Booting::entry() -> void { sServices->nvs(), sServices->bg_worker())); sServices->bluetooth().SetEventHandler(bt_event_cb); - if (sServices->nvs().OutputMode() == - drivers::NvsStorage::Output::kBluetooth) { - ESP_LOGI(kTag, "enabling bluetooth"); - sServices->bluetooth().Enable(); - } - BootComplete ev{.services = sServices}; events::Audio().Dispatch(ev); events::Ui().Dispatch(ev);