Classify unreachable Bluetooth Moves

This commit is contained in:
Meta Vens 2026-06-17 11:54:28 +01:00
commit 9ea3ba22bd

View file

@ -452,8 +452,13 @@ fn build_bluetooth_move_identity_record(
pickup_detail: Option<String>,
) -> Option<MuninnMoveIdentityRecord> {
let move_id = bluetooth_address_move_id(&device.address)?;
let pickup_unreachable = pickup_detail
.as_deref()
.is_some_and(bluetooth_pickup_detail_is_unreachable);
let state = if device.connected {
"bluetooth-connected"
} else if device.trusted && pickup_unreachable {
"bluetooth-unreachable"
} else if device.trusted {
"bluetooth-waiting"
} else {
@ -664,6 +669,12 @@ fn bluetooth_pickup_detail(
.map(|attempt| attempt.detail.clone())
}
fn bluetooth_pickup_detail_is_unreachable(detail: &str) -> bool {
let normalized = detail.to_ascii_lowercase();
normalized.contains("br-connection-create-socket")
|| normalized.contains("host is down")
}
#[cfg(unix)]
fn active_move_source_has_bluetooth_address(
active: &[ActiveMoveStateSource],
@ -4874,7 +4885,7 @@ Device 00:07:04:A8:00:D0 (public)
)
.unwrap();
assert_eq!(record.state, "bluetooth-waiting");
assert_eq!(record.state, "bluetooth-unreachable");
assert!(record.detail.contains("Last pickup attempt: Failed to connect"));
assert!(record.detail.contains("br-connection-create-socket"));
}