Skip to content

feat(ble): Add support for FromRadioSync characteristic#4584

Closed
jamesarich wants to merge 5 commits intomainfrom
feat/ble-indicate
Closed

feat(ble): Add support for FromRadioSync characteristic#4584
jamesarich wants to merge 5 commits intomainfrom
feat/ble-indicate

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This pull request adds support for a new BLE characteristic, BTM_FROMRADIOSYNC_CHARACTER, to the radio interface, enabling direct packet delivery via notifications. The implementation includes updates to characteristic discovery, notification setup, logging, and test coverage to ensure correct handling of the new characteristic.

Addition of new BLE characteristic support:

  • Introduced BTM_FROMRADIOSYNC_CHARACTER constant in BleConstants and added corresponding member fromRadioSyncCharacteristic in NordicBleInterface to handle the new characteristic. [1] [2] [3]
  • Updated service discovery logic to locate and assign fromRadioSyncCharacteristic during initialization.

Notification handling and logging enhancements:

  • Modified setupNotifications to subscribe to fromRadioSyncCharacteristic and dispatch packets directly upon receiving notifications. Added logging to indicate subscription and packet dispatch events. [1] [2] [3]

Resource management improvements:

  • Ensured fromRadioSyncCharacteristic is properly cleared during interface closure to prevent resource leaks.

Testing:

  • Added a unit test to verify that notifications (indications) on fromRadioSyncCharacteristic correctly deliver packets to the service's handler.

Firmware implementation PR here: meshtastic/firmware#9675

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 7.99%. Comparing base (82eed17) to head (019ea52).
✅ All tests successful. No failed tests found.

❗ There is a different number of reports uploaded between BASE (82eed17) and HEAD (019ea52). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (82eed17) HEAD (019ea52)
2 1
Additional details and impacted files
@@            Coverage Diff            @@
##             main   #4584      +/-   ##
=========================================
- Coverage   15.43%   7.99%   -7.45%     
=========================================
  Files         426     345      -81     
  Lines       14855   10938    -3917     
  Branches     2472    1768     -704     
=========================================
- Hits         2293     874    -1419     
+ Misses      12242    9914    -2328     
+ Partials      320     150     -170     

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

This commit introduces support for the new `FromRadioSync` Bluetooth LE characteristic. This characteristic provides a way for the radio to send packets directly to the app, similar to the existing `FromRadio` characteristic, but using notifications for immediate delivery.

Specific changes include:
- Added the `BTM_FROMRADIOSYNC_CHARACTER` UUID.
- Discovered and subscribed to the `FromRadioSync` characteristic upon connection.
- Handled incoming notifications from this characteristic by dispatching the received data directly as a radio packet.
- Added a new unit test to verify that notifications from the `FromRadioSync` characteristic are correctly received and processed.

Signed-off-by: James Rich <[email protected]>
This commit prevents a redundant subscription to `fromNumCharacteristic` when `fromRadioSyncCharacteristic` is also present. The subscription to `fromNumCharacteristic` is now skipped on devices that support the newer `fromRadioSyncCharacteristic`, avoiding duplicate notifications and potential race conditions.

Signed-off-by: James Rich <[email protected]>
Signed-off-by: James Rich <[email protected]>
Signed-off-by: James Rich <[email protected]>
This commit addresses a race condition in the BLE OTA tests and improves resource handling in the transport layer.

The `BleOtaTransport` now explicitly closes its `responseChannel` upon disconnection. This prevents potential resource leaks and ensures that downstream consumers are properly notified when the transport is closed.

The BLE OTA tests have been made more robust by adding a check to ensure the peripheral is still connected (`otaPeripheral.isConnected`) before attempting to simulate a value update. This prevents tests from hanging or throwing exceptions due to race conditions where a response is simulated after the connection has already been terminated.

Signed-off-by: James Rich <[email protected]>
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