Skip to content

fix(ble): implement scanning for unbonded devices in common connections ui#4779

Merged
jamesarich merged 2 commits intomainfrom
fix/ble-scan
Mar 13, 2026
Merged

fix(ble): implement scanning for unbonded devices in common connections ui#4779
jamesarich merged 2 commits intomainfrom
fix/ble-scan

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

Fixes devices not showing up on BLE list.

This commit enhances the Bluetooth scanning experience by integrating real-time BLE scanning into the ScannerViewModel and displaying both bonded and newly discovered (unbonded) devices in the connections UI.

Specific changes include:

  • Core BLE: Updated BleScanner interface to support an optional serviceUuid filter.
  • Android Implementation: Updated AndroidBleScanner to utilize the new serviceUuid filter using Nordic's CentralManager.
  • ViewModel Logic:
    • Integrated BleScanner into ScannerViewModel and AndroidScannerViewModel.
    • Added startBleScan() and stopBleScan() methods to manage scanning lifecycle.
    • Combined bonded devices from the repository with scanned devices, filtering out duplicates and sorting by name.
    • Added isBleScanning state to track the scanning status.
  • UI Components:
    • Updated BLEDevices component to trigger scanning on composition and stop on disposal.
    • Added a LinearProgressIndicator to provide visual feedback during active scans.
  • Testing: Refactored BleScannerTest to use AndroidBleScanner and verified the new filtering logic.

…ons UI

This commit enhances the Bluetooth scanning experience by integrating real-time BLE scanning into the `ScannerViewModel` and displaying both bonded and newly discovered (unbonded) devices in the connections UI.

Specific changes include:
- **Core BLE**: Updated `BleScanner` interface to support an optional `serviceUuid` filter.
- **Android Implementation**: Updated `AndroidBleScanner` to utilize the new `serviceUuid` filter using Nordic's `CentralManager`.
- **ViewModel Logic**:
    - Integrated `BleScanner` into `ScannerViewModel` and `AndroidScannerViewModel`.
    - Added `startBleScan()` and `stopBleScan()` methods to manage scanning lifecycle.
    - Combined bonded devices from the repository with scanned devices, filtering out duplicates and sorting by name.
    - Added `isBleScanning` state to track the scanning status.
- **UI Components**:
    - Updated `BLEDevices` component to trigger scanning on composition and stop on disposal.
    - Added a `LinearProgressIndicator` to provide visual feedback during active scans.
- **Testing**: Refactored `BleScannerTest` to use `AndroidBleScanner` and verified the new filtering logic.

Signed-off-by: James Rich <[email protected]>
@github-actions github-actions bot added the bugfix PR tag label Mar 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 30.55556% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 12.19%. Comparing base (5a548d2) to head (65ddf2d).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...meshtastic/feature/connections/ScannerViewModel.kt 19.23% 21 Missing ⚠️
...otlin/org/meshtastic/core/ble/AndroidBleScanner.kt 71.42% 1 Missing and 1 partial ⚠️
...tic/feature/connections/AndroidScannerViewModel.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##            main    #4779      +/-   ##
=========================================
+ Coverage   9.51%   12.19%   +2.68%     
=========================================
  Files        480      531      +51     
  Lines      16372    17746    +1374     
  Branches    2401     2650     +249     
=========================================
+ Hits        1558     2165     +607     
- Misses     14555    15267     +712     
- Partials     259      314      +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: James Rich <[email protected]>
@jamesarich jamesarich added this pull request to the merge queue Mar 13, 2026
Merged via the queue into main with commit 5cc1e94 Mar 13, 2026
6 checks passed
@jamesarich jamesarich deleted the fix/ble-scan branch March 13, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant