diff --git a/README.md b/README.md index 3512c1d..697a6af 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The daemon adapts it to a small state machine: Locking goes through `loginctl lock-session` (works with GNOME, KDE, Sway, ...), configurable via `lock_command`. Before locking, the daemon attempts a -short (3s) LE connection to the paired phone: a phone in range accepts it, +short (10s) LE connection to the paired phone: a phone in range accepts it, which cancels the lock — silence in the advertisement stream alone is not proof of absence. @@ -122,7 +122,7 @@ See `config.toml.example`; every knob is documented there. Highlights: identical RSSI values (its property cache suppresses unchanged values), so a stationary phone can go quiet in the event stream while in range. Two countermeasures: the radio escalates duty while updates are stalled (see - Present above), and the lock decision is gated on a 3s LE connect probe. + Present above), and the lock decision is gated on a 10s LE connect probe. `--dry-run` on your hardware remains the arbiter. The AdvertisementMonitor roadmap removes this class of problem. - While the screen is locked the daemon keeps low-duty scanning to notice diff --git a/src/scanner/bluez.rs b/src/scanner/bluez.rs index da87b82..a0661d4 100644 --- a/src/scanner/bluez.rs +++ b/src/scanner/bluez.rs @@ -176,9 +176,10 @@ struct Target { } /// How long to wait for the connect probe before concluding the phone is -/// gone. LE connection setup with the phone in range completes well within -/// this; aborting cancels BlueZ's connection attempt. -const PROBE_TIMEOUT: Duration = Duration::from_secs(3); +/// gone. The controller scans for the phone's advertisements for this whole +/// window, so slow or intermittent advertising still gets caught; aborting +/// cancels BlueZ's connection attempt. +const PROBE_TIMEOUT: Duration = Duration::from_secs(10); /// Attempt a short LE connection to the paired phone. Returns true if the /// device accepted the connection (it is in range); the connection is closed @@ -190,7 +191,7 @@ async fn probe_reachable(conn: &Connection, target: Option<&Target>) -> bool { let proxy = match Proxy::new(conn, BLUEZ, target.path.clone(), DEVICE_IFACE).await { Ok(p) => p, Err(e) => { - debug!("probe: proxy setup failed: {e:#}"); + warn!("probe: proxy setup failed: {e:#}"); return false; } }; @@ -207,11 +208,14 @@ async fn probe_reachable(conn: &Connection, target: Option<&Target>) -> bool { true } Ok(Err(e)) => { - debug!("probe: connect rejected: {e:#}"); + info!("probe: connect rejected: {e:#}"); false } Err(_) => { - debug!("probe: timed out"); + warn!( + "probe: no connection within {}s, treating phone as out of range", + PROBE_TIMEOUT.as_secs() + ); // Cancel the pending connection attempt so BlueZ does not keep // paging for the device in the background. let _ = tokio::time::timeout(