diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index e37c887b..b1c5c2b8 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -113,7 +113,6 @@ void AudioState::react(const SetVolumeBalance& ev) { } void AudioState::react(const OutputModeChanged& ev) { - // TODO: handle SetInUse ESP_LOGI(kTag, "output mode changed"); auto new_mode = sServices->nvs().OutputMode(); sOutput->SetMode(IAudioOutput::Modes::kOff); diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index abe88460..b3546d55 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -77,19 +77,24 @@ lua::Property UiState::sBatteryPct{0}; lua::Property UiState::sBatteryMv{0}; lua::Property UiState::sBatteryCharging{false}; -lua::Property UiState::sBluetoothEnabled{ - false, [](const lua::LuaValue& val) { - if (!std::holds_alternative(val)) { - return false; - } - if (std::get(val)) { - sServices->bluetooth().Enable(); - sServices->bluetooth().SetDeviceDiscovery(true); - } else { - sServices->bluetooth().Disable(); - } - return true; - }}; +lua::Property UiState::sBluetoothEnabled { + false, [](const lua::LuaValue& val) { + if (!std::holds_alternative(val)) { + return false; + } + if (std::get(val)) { + sServices->bluetooth().Enable(); + sServices->bluetooth().SetDeviceDiscovery(true); + sServices->nvs().OutputMode(drivers::NvsStorage::Output::kBluetooth); + } else { + sServices->bluetooth().Disable(); + sServices->nvs().OutputMode(drivers::NvsStorage::Output::kHeadphones); + } + events::Audio().Dispatch(audio::OutputModeChanged{}); + return true; + } +}; + lua::Property UiState::sBluetoothConnected{false}; lua::Property UiState::sBluetoothPairedDevice{ std::monostate{}, [](const lua::LuaValue& val) {