Kotlin/Compose foreground service advertising a connectable legacy
advertisement at ~1 Hz with a counter that rotates in ServiceData every
10s: changed payload values make BlueZ emit PropertiesChanged even when
the RSSI repeats, keeping the daemon's freshness clock fed for a
stationary phone. Running from a foreground service with a battery
optimization exemption defeats the advertising pauses that caused the
false locks. Replaces third-party beacon apps; the daemon needs no
changes. Verified with a real Gradle build (AGP 8.13.2, Kotlin 2.3.21,
compileSdk 36).
Distill the session findings (BlueZ RSSI dedupe, beacon pauses, MSRV
pinning, scan-only decision) so future agents and humans don't have to
rediscover them. AGENTS.md carries the rules, docs/HANDOFF.md the
history and open threads.
Beacon apps pause advertising while the phone sits still, so the 30s
default for missing_after_secs false-locked. Ship 120s plus comments
explaining the beacon pauses and the 10s pre-lock connect probe;
presence_timeout_secs 30 pairs with the duty escalation.
The phone's beacon app pauses advertising for stretches while in range,
which is what the 3s probe could not bridge. Give the controller a 10s
window to find the phone, and log probe outcomes at INFO/WARN so the
journal explains every lock decision.
BlueZ dedupes identical RSSI values, so a stationary phone can go quiet
in the event stream while in range. At the 2% present duty cycle the
~1Hz beacon was caught less often than presence_timeout, causing
Present/Suspect flapping and locks after 60s of silence with the phone
at -60 dBm.
- Present: step up to the Suspect duty once the last sighting ages past
half of presence_timeout, without leaving Present
- Lock path: attempt a 3s LE connect to the phone first; success cancels
the lock and returns to Present, failure locks as before