trust and connect to new paired device

This commit is contained in:
Badr
2025-11-09 13:58:23 +01:00
parent 0673743ec3
commit 85ca8f65fa
3 changed files with 38 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ pub enum Event {
Mouse(MouseEvent),
Resize(u16, u16),
Notification(Notification),
NewPairedDevice,
}
#[allow(dead_code)]

View File

@@ -99,6 +99,40 @@ async fn pair(app: &mut App, sender: UnboundedSender<Event>) {
NotificationLevel::Info,
sender.clone(),
);
let _ = sender.send(Event::NewPairedDevice);
match device.set_trusted(true).await {
Ok(_) => {
let _ = Notification::send(
"Device trusted".to_string(),
NotificationLevel::Info,
sender.clone(),
);
}
Err(e) => {
let _ = Notification::send(
e.to_string(),
NotificationLevel::Error,
sender.clone(),
);
}
};
match device.connect().await {
Ok(_) => {
let _ = Notification::send(
"Device connected".to_string(),
NotificationLevel::Info,
sender.clone(),
);
}
Err(e) => {
let _ = Notification::send(
e.to_string(),
NotificationLevel::Error,
sender.clone(),
);
}
};
}
Err(e) => {
let _ = Notification::send(

View File

@@ -52,6 +52,9 @@ async fn main() -> AppResult<()> {
Event::Notification(notification) => {
app.notifications.push(notification);
}
Event::NewPairedDevice => {
app.focused_block = bluetui::app::FocusedBlock::PairedDevices;
}
_ => {}
}
}