summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-06 12:38:11 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-06 13:37:20 +1100
commit99c56641e9ee531a0553ff19422009dd667a3add (patch)
tree8cb4dcd954a563b42bee9e991e8ad9bb99a0f3c7 /src/ui
parentab314b82e10aadb674fab223bffa4933a9a65750 (diff)
downloadtangara-fw-99c56641e9ee531a0553ff19422009dd667a3add.tar.gz
fix various of bluetooth issues
connecting and disconnecting is a bit more consistent now!
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_fsm.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index b3546d55..55c8c84b 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -77,30 +77,33 @@ 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<bool>(val)) {
- return false;
- }
- if (std::get<bool>(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::sBluetoothEnabled{
+ false, [](const lua::LuaValue& val) {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ if (std::get<bool>(val)) {
+ sServices->nvs().OutputMode(drivers::NvsStorage::Output::kBluetooth);
+ sServices->bluetooth().Enable();
+ sServices->bluetooth().SetDeviceDiscovery(true);
+ } else {
+ sServices->nvs().OutputMode(drivers::NvsStorage::Output::kHeadphones);
+ sServices->bluetooth().Disable();
+ }
+ events::Audio().Dispatch(audio::OutputModeChanged{});
+ return true;
+ }};
lua::Property UiState::sBluetoothConnected{false};
lua::Property UiState::sBluetoothPairedDevice{
std::monostate{}, [](const lua::LuaValue& val) {
if (std::holds_alternative<drivers::bluetooth::Device>(val)) {
auto dev = std::get<drivers::bluetooth::Device>(val);
- sServices->bluetooth().SetPreferredDevice(dev.address);
+ sServices->bluetooth().SetPreferredDevice(
+ drivers::bluetooth::MacAndName{
+ .mac = dev.address,
+ .name = {dev.name.data(), dev.name.size()},
+ });
}
return false;
}};