Skip to content

Improve BLE recovery and RSSI stability - #186

Open
Eggwardhan wants to merge 6 commits into
ts1:masterfrom
Eggwardhan:codex/ble-reconnect-recovery
Open

Improve BLE recovery and RSSI stability#186
Eggwardhan wants to merge 6 commits into
ts1:masterfrom
Eggwardhan:codex/ble-reconnect-recovery

Conversation

@Eggwardhan

@Eggwardhan Eggwardhan commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • Add CoreBluetooth disconnect and connection-failure callbacks for the monitored device.
  • Clear stale connection timers and restart scanning after disconnects and Bluetooth power recovery.
  • Smooth RSSI before both presence decisions and require multiple samples before unlocking, reducing single-sample false transitions.
  • Add standalone RSSI tests and a regression check for BLE recovery hooks.

Verification

  • swiftc BLEUnlock/RSSIDecision.swift Tests/RSSIDecisionTests/main.swift -o /tmp/RSSIDecisionTests && /tmp/RSSIDecisionTests
  • tests/test_ble_recovery.sh
  • xcodebuild -project BLEUnlock.xcodeproj -scheme BLEUnlock -configuration Debug -derivedDataPath /tmp/BLEUnlock-DerivedData-pr183 CODE_SIGNING_ALLOWED=NO build

The existing local BLEUnlock/Info.plist version change was intentionally not included.

7onnie and others added 5 commits June 18, 2026 22:48
…ike false positives

The presence/unlock transition previously used a single raw RSSI reading, so one
spurious strong sample (multipath reflection, advertising burst) could unlock the Mac
from far away. Compute the moving average first and gate the transition on it plus a
minimum sample count; drop the buffer-clearing that destabilised the lock decision.
Refs ts1#153.
@Eggwardhan Eggwardhan changed the title Recover monitored BLE device after disconnect Improve BLE recovery and RSSI stability Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants