fix: improve BLE BATTERY_SAVER discovery reliability#622
Merged
torlando-tech merged 2 commits intomainfrom Mar 8, 2026
Merged
Conversation
- Use MATCH_MODE_AGGRESSIVE instead of MATCH_MODE_STICKY so even short scan windows detect nearby devices - Keep SCAN_MODE_BALANCED for idle scans instead of LOW_POWER (LOW_POWER's ~10% duty cycle leaves too few radio windows) - Tune BATTERY_SAVER: scanDuration 5s→8s (~2 radio windows), adRefresh 180s→90s (better visibility between scans) - Add explanatory comment for non-monotonic scanDurationMs values Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR tunes the Key observations from the review:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant ScanLoop as Scan Loop
participant PS as performScan()
participant DSM as determineScanMode()
participant BLE as BT LE Scanner (HW)
participant HSR as handleScanResult()
ScanLoop->>PS: performScan(minRssi)
PS->>DSM: determineScanMode()
alt newDevicesInLastScan > 3
DSM-->>PS: SCAN_MODE_LOW_LATENCY
else all other cases (was LOW_POWER for idle)
DSM-->>PS: SCAN_MODE_BALANCED
end
PS->>BLE: startScan(filter, MATCH_MODE_AGGRESSIVE)
Note over BLE: Previously MATCH_MODE_STICKY for all profiles
BLE-->>HSR: onScanResult() callbacks
HSR->>HSR: filter by MIN_RSSI, update devices map
Note over PS: delay(scanDurationMs) — BATTERY_SAVER 8s (was 5s)
PS->>BLE: stopScan()
PS-->>ScanLoop: return
ScanLoop->>ScanLoop: delay(currentScanInterval)
Note over ScanLoop: BATTERY_SAVER active=15s, idle=120s
ScanLoop->>ScanLoop: adjustScanInterval()
Last reviewed commit: 19f4219 |
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/client/BleScanner.kt
Show resolved
Hide resolved
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/client/BleScanner.kt
Show resolved
Hide resolved
Both branches returned SCAN_MODE_BALANCED after the LOW_POWER removal, making the IDLE_SCANS_THRESHOLD check redundant dead code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BlePowerSettings.getSettings()documenting whyscanDurationMsis intentionally non-monotonic across profiles (5s, 10s, 8s)Context
After the original BLE shutdown fixes in #609, an audit of all three power profiles found that BATTERY_SAVER had insufficient radio windows per scan for reliable discovery. These changes address that while keeping all profiles well under Android's 5-scans-per-30s throttle limit.
Test plan
🤖 Generated with Claude Code