Skip to content

refactor(ble): improve connection lifecycle and enhance OTA reliability#4721

Merged
jamesarich merged 3 commits intomainfrom
feat/nordic-updates
Mar 5, 2026
Merged

refactor(ble): improve connection lifecycle and enhance OTA reliability#4721
jamesarich merged 3 commits intomainfrom
feat/nordic-updates

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

  • Update nordic-ble dependency to 2.0.0-alpha16.
  • Refactor BleConnection to introduce a profile helper for streamlined service discovery and characteristic setup.
  • Remove the BleError sealed class in favor of explicit disconnection reasons and boolean permanent failure flags in RadioInterfaceService.
  • Implement MTU-aware fragmentation in BleOtaTransport to improve reliability and prevent buffer overflows during firmware updates.
  • Introduce MeshtasticRadioServiceImpl to encapsulate GATT characteristic logic, supporting both legacy (Notify/Read) and modern (Indicate) packet flows.
  • Add unit tests for BLE OTA service discovery and permission handling in BluetoothRepository.
  • Centralize OTA-related UUIDs in MeshtasticBleConstants.
  • Improve error handling in NordicBleInterface by mapping GATT and Bluetooth exceptions to user-friendly disconnection messages.

- Update `nordic-ble` dependency to `2.0.0-alpha16`.
- Refactor `BleConnection` to introduce a `profile` helper for streamlined service discovery and characteristic setup.
- Remove the `BleError` sealed class in favor of explicit disconnection reasons and boolean permanent failure flags in `RadioInterfaceService`.
- Implement MTU-aware fragmentation in `BleOtaTransport` to improve reliability and prevent buffer overflows during firmware updates.
- Introduce `MeshtasticRadioServiceImpl` to encapsulate GATT characteristic logic, supporting both legacy (Notify/Read) and modern (Indicate) packet flows.
- Add unit tests for BLE OTA service discovery and permission handling in `BluetoothRepository`.
- Centralize OTA-related UUIDs in `MeshtasticBleConstants`.
- Improve error handling in `NordicBleInterface` by mapping GATT and Bluetooth exceptions to user-friendly disconnection messages.

Signed-off-by: James Rich <[email protected]>
@github-actions github-actions bot added the enhancement New feature or request label Mar 5, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (e761e84) to head (95c80d4).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4721   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          3       3           
  Lines        231     231           
  Branches      34      34           
=====================================
  Misses       231     231           

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

…eImpl

- Update the legacy `fromRadio` path to use `channelFlow` and a `MutableSharedFlow` for more robust packet draining.
- Implement a loop to read from the `FROMRADIO` characteristic until an empty packet is received, rather than relying solely on the count from `FROMNUM`.
- Trigger a drain operation automatically after writing to the radio when the sync characteristic is unavailable.
- Suppress `CyclomaticComplexMethod` lint warning for the `streamFirmware` function in `BleOtaTransport`.

Signed-off-by: James Rich <[email protected]>
@jamesarich jamesarich enabled auto-merge March 5, 2026 18:48
@jamesarich jamesarich added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 68b2b6d Mar 5, 2026
6 checks passed
@jamesarich jamesarich deleted the feat/nordic-updates branch March 5, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant