diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-07-11 15:11:28 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-07-11 15:11:28 +1000 |
| commit | a3eb2dd9dc2399ce9c22cd3b07f482f080976440 (patch) | |
| tree | 4a7883755d07b7d9a391d5b6e7858c0ab26e3bdd /src/tangara/audio/audio_fsm.cpp | |
| parent | a9d2335e1d86b3012789a440e7f0e71033393056 (diff) | |
| download | tangara-fw-a3eb2dd9dc2399ce9c22cd3b07f482f080976440.tar.gz | |
WIP improve bluetooth api and settings screen
Diffstat (limited to 'src/tangara/audio/audio_fsm.cpp')
| -rw-r--r-- | src/tangara/audio/audio_fsm.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp index 24f287ac..fbc38f97 100644 --- a/src/tangara/audio/audio_fsm.cpp +++ b/src/tangara/audio/audio_fsm.cpp @@ -222,7 +222,12 @@ void AudioState::react(const system_fsm::BluetoothEvent& ev) { auto simpleEvent = std::get<SimpleEvent>(ev.event); switch (simpleEvent) { case SimpleEvent::kConnectionStateChanged: { - auto dev = sServices->bluetooth().ConnectedDevice(); + auto bt = sServices->bluetooth(); + if (bt.connectionState() != + drivers::Bluetooth::ConnectionState::kConnected) { + return; + } + auto dev = sServices->bluetooth().pairedDevice(); if (!dev) { return; } @@ -341,7 +346,7 @@ auto AudioState::commitVolume() -> void { if (mode == drivers::NvsStorage::Output::kHeadphones) { sServices->nvs().AmpCurrentVolume(vol); } else if (mode == drivers::NvsStorage::Output::kBluetooth) { - auto dev = sServices->bluetooth().ConnectedDevice(); + auto dev = sServices->bluetooth().pairedDevice(); if (!dev) { return; } @@ -372,7 +377,7 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) { sOutput = sI2SOutput; } else { // Ensure Bluetooth gets enabled if it's the default sink. - sServices->bluetooth().Enable(); + sServices->bluetooth().enable(true); sOutput = sBtOutput; } sOutput->mode(IAudioOutput::Modes::kOnPaused); |
