Repository navigation
fix(dfu): let a BLE DFU start over after the central disconnects - #85
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Storage and DFU reset APIs lib/sdk11/components/drivers_nrf/pstorage/pstorage.h, lib/sdk11/components/drivers_nrf/pstorage/pstorage_raw.c, lib/sdk11/components/libraries/bootloader_dfu/dfu.h, lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c |
The pstorage interface adds pstorage_discard_pending(), which removes buffered entries while preserving an in-flight entry when applicable. The DFU API adds dfu_reset_session(), which discards pending operations, clears transfer state, and returns eligible sessions to IDLE. |
BLE disconnect reset lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c, changelog.md |
After an external disconnect, the BLE transport resets the DFU and BLE transfer state before restarting advertising. The changelog records the behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant BLEEventHandler
participant session_reset
participant dfu_reset_session
participant pstorage_discard_pending
participant Advertising
BLEEventHandler->>session_reset: external disconnect
session_reset->>dfu_reset_session: reset DFU session
dfu_reset_session->>pstorage_discard_pending: discard pending operations
session_reset->>BLEEventHandler: clear BLE transfer state
BLEEventHandler->>Advertising: restart advertising
Suggested reviewers: oltaco
Merge Risk: 
Minimal · up to 2a3e6
-
The reviewed disconnect path supports starting a fresh BLE DFU transfer, with no identified issue requiring a fix before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit saw the link go down,
Then watched the transfer start anew.
The buffers cleared, the state reset,
The beacon called the board back through.
One hop, one fresh beginning.
Comment @coderabbitai help to get the list of available commands.
Checklist
tools/build_all.py(or CI's board matrix) passesDescription of Change
A BLE central that disconnects mid-transfer left the DFU state machine where it stopped, so the reconnecting central's START_DFU was answered with status 2 (INVALID_STATE) until the board was reset. A phone could not retry a dropped update. The bootloader now returns the session to idle when the central disconnects (not on the activate teardown): it clears the session and transport state and drops stores still waiting on a lazy erase, and the next START erases and starts over.
Tested with gcc 12.3 images on the RAK4631 (S140 6.1.1) and the Wio Tracker L1 (S140 7.3.0), 244 B packets with PRN 10 and the 20 B legacy client: a drop at about 30 s followed by a retry completes and boots the new app 28 of 28, 25 of them with the retry started 12 to 15 ms after the drop. Master refuses the same retry with status 2. A normal BLE OTA, a UF2 install and a serial DFU are unaffected.
Summary by CodeRabbit
New Features
Bug Fixes