Fix probe reliability and restore sane missing_after

Two false locks with the phone present: missing_after=30 sat below the
realistic worst-case event gap (beacon counter rotation every 10s times
2-20% duty sampling, with frozen-RSSI dedupe collapsing catches inside
one window), and the connect probe ran while our own discovery
duty-cycling was active, where attempts stall or abort with
le-connection-abort-by-local.

Probe now stops discovery first and retries (2x6s); sample config and
handoff document the sampling math. Local config additionally raises
rssi_lock to -85, where nearby-phone readings were pinning.
This commit is contained in:
Bastian Mäuser committed 2026-11-06 12:17:47 +01:00
1 parent 38087583cf
commit dcf403200a
4 files changed
+105 -44

No files matched your search

+40
View File
@@ -4,6 +4,46 @@ Dated notes for picking this project back up: what happened, what was
learned, and which threads are still open. AGENTS.md carries the distilled
rules; this file carries the history behind them.
## 2026-11-06 — two more false locks: sampling math and probe contention
**Symptoms.** Two false locks while the user was present: 11:24:24 (RSSI
-64, strong, phone advertising) and 11:57:30 (RSSI -82 after 10 minutes
pinned at -78..-82).
**Root causes.**
1. *`missing_after = 30` sat below the realistic worst-case event gap.*
The beacon rotates its ServiceData counter every 10 s, but the daemon
only *samples* the radio (2-20% duty). When the RSSI is frozen (BlueZ
dedupe), catches within one rotation window dedupe to nothing, so
event gaps of 25-60 s are routine — e.g. 11:56:32 → 11:57:30 (58 s
gap) reached `missing_after` and triggered a probe.
2. *The connect probe ran while our own discovery duty-cycling was
active.* With the phone in range and advertising, the probe still
stalled for its whole window and BlueZ returned
`le-connection-abort-by-local` — controller contention between our
scan windows and the connection attempt. The probe is the last line
of defense and was not reliable under load.
**Fixes shipped.**
- Probe: 2 attempts × 6 s with a 1 s pause, and discovery is stopped
before probing so the connection attempt gets a clean radio.
- `missing_after = 60` with the companion app (30 s is not enough given
the sampling math; third-party beacons still warrant 120 s).
- Local config: `rssi_lock = -85` — nearby-phone readings pinned at
-78..-82 dBm sat exactly on the -80 threshold and made the weak-signal
path flap constantly. Watch desk readings via the sighting reports.
**Lingering observations.**
- Desk RSSI varies hugely day to day (-44..-65 one day, -52..-86 the
next): interference, phone position, TX power. The `rssi_lock`
threshold needs headroom against this variance.
- `le-connection-abort-by-local` at probe time is now expected only when
our 6 s timeout cancels the attempt (zbus drops the call → bluetoothd
aborts); the retry covers the transient case.
## 2026-11-05 — false-lock debugging session
**Symptoms.** The daemon flipped Present⇄Suspect every minute or so and