Fix handling of Headset dongle disconnecting
This commit is contained in:
@@ -602,8 +602,6 @@ pub trait Device {
|
|||||||
self.execute_headset_specific_functionality()?;
|
self.execute_headset_specific_functionality()?;
|
||||||
|
|
||||||
let mut responded = false;
|
let mut responded = false;
|
||||||
// So we do not immediately break if another response is queued
|
|
||||||
self.get_device_state_mut().connected = Some(true);
|
|
||||||
for packet in packets.into_iter().flatten() {
|
for packet in packets.into_iter().flatten() {
|
||||||
self.prepare_write();
|
self.prepare_write();
|
||||||
debug_println!("Write packet: {packet:?}");
|
debug_println!("Write packet: {packet:?}");
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ fn main() {
|
|||||||
let mut device = loop {
|
let mut device = loop {
|
||||||
match connect_compatible_device() {
|
match connect_compatible_device() {
|
||||||
Ok(d) => break d,
|
Ok(d) => break d,
|
||||||
Err(e) => eprintln!("Connecting failed with error: {e}"),
|
Err(e) => {
|
||||||
|
tray_handler.clear_state();
|
||||||
|
eprintln!("Connecting failed with error: {e}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::thread::sleep(Duration::from_secs(1));
|
std::thread::sleep(Duration::from_secs(1));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ pub struct TrayHandler {
|
|||||||
handle: Handle<StatusTray>,
|
handle: Handle<StatusTray>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const NO_COMPATIBLE_DEVICE: &str = "No compatible device found.\nIs the dongle plugged in?\nIf you are using Linux did you add the Udev rules?";
|
const NO_COMPATIBLE_DEVICE: &str = "No compatible device found.\nIs the dongle plugged in?\nIf you are using Linux did you\nadd the Udev rules?";
|
||||||
|
|
||||||
impl TrayHandler {
|
impl TrayHandler {
|
||||||
pub fn new(tray: StatusTray) -> Self {
|
pub fn new(tray: StatusTray) -> Self {
|
||||||
@@ -32,6 +32,13 @@ impl TrayHandler {
|
|||||||
tray.device_name = name;
|
tray.device_name = name;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_state(&self) {
|
||||||
|
self.handle.update(|tray| {
|
||||||
|
tray.message = NO_COMPATIBLE_DEVICE.to_string();
|
||||||
|
tray.device_name = None;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StatusTray {
|
pub struct StatusTray {
|
||||||
|
|||||||
Reference in New Issue
Block a user