fix(connections): improve BLE scan reliability and UI lifecycle#5329
Merged
jamesarich merged 2 commits intomainfrom May 2, 2026
Merged
fix(connections): improve BLE scan reliability and UI lifecycle#5329jamesarich merged 2 commits intomainfrom
jamesarich merged 2 commits intomainfrom
Conversation
On macOS, CoreBluetooth caches peripheral identifiers, which can cause scans filtered by address to time out. This change switches to scanning by service UUID and filtering the results manually to ensure reliable discovery on Desktop. It also refines the UI scan logic to prevent state changes from interrupting active scans. - Scan by service UUID and filter results by address in `BleRadioTransport` to fix Desktop timeouts - Decouple scan auto-start from cleanup in `ConnectionsScreen` using `LaunchedEffect` and `DisposableEffect(Unit)` - Prevent scan restarts when `bleAutoScan` state is updated from disk or DataStore - Ensure `stopBleScan()` is called only when the screen is actually disposed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make BLE discovery more reliable across platforms—especially Desktop/CoreBluetooth—while refining the Connections screen’s scan lifecycle so persisted auto-scan state does not unnecessarily interrupt active scans.
Changes:
- Updated BLE transport discovery to scan by Meshtastic service UUID and then match the selected device in-app.
- Split BLE scan auto-start from cleanup in
ConnectionsScreenusingLaunchedEffectplus a disposal-only cleanup effect. - Kept scan shutdown tied to screen disposal instead of preference-state recomposition.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/ConnectionsScreen.kt |
Refactors BLE auto-scan lifecycle handling in the shared Connections UI. |
core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/BleRadioTransport.kt |
Changes BLE device discovery to service-UUID scanning with manual address matching. |
…ion test Pass both serviceUuid and address to BleScanner.scan() so Android uses efficient OS-level address filtering while CoreBluetooth (macOS) can fall back to service UUID discovery when cached identifiers prevent address-only rescans. Add regression test to lock in this behavior.
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.
On macOS, CoreBluetooth caches peripheral identifiers, which can cause scans filtered by address to time out. This change switches to scanning by service UUID and filtering the results manually to ensure reliable discovery on Desktop. It also refines the UI scan logic to prevent state changes from interrupting active scans.
BleRadioTransportto fix Desktop timeoutsConnectionsScreenusingLaunchedEffectandDisposableEffect(Unit)bleAutoScanstate is updated from disk or DataStorestopBleScan()is called only when the screen is actually disposed