Tutorials
BLE Logger Reconnect: Resume From the Last Saved Record
Published · Updated
When a phone reconnects, ask it what it saved. A successful notification submission is insufficient evidence that the receiver wrote the record to durable storage.
Resume using a session ID and a contiguous checkpoint

Give each recording session its own identifier and number its records monotonically. Suppose the device sent through 427 but the phone durably stored every record only through 419. Resume at 420. If 423 was written out of order, the checkpoint remains 419 until the earlier gap closes. Upsert records by session and sequence so a repeated 423 does not add a second sample.
Use acknowledgements with a defined application meaning. The ATT indication confirmation describes protocol receipt, while your checkpoint describes committed application data. Persist the checkpoint with the transaction that stores the records, or reconstruct it from stored sequences after restart.
Make missing history visible

On resume, compare the requested sequence with the oldest retained device record. If the phone asks for 420 but retention starts at 430, report the missing interval 420–429. Begin from 430 only after recording the gap. Separate the logging session ID from each connection identifier so reconnecting alone does not reset the sequence.
Build a test that disconnects immediately after send, after receive but before commit, and after commit but before the acknowledgement arrives. Replay the last block and check that the stored sequence set is contiguous where retention allows. Then reboot only the phone, only the logger, and both, verifying that each finds the correct session boundary. Keep a trace of checkpoint requests, durable commits and retained ranges for each case.
The device sent 427 and the phone checkpoint is 419. Where does replay begin?
Request 420 if the session and retention window match. Treat already stored later records as duplicates.
Show the three-step example

Device transmitted: Through record 427. Phone durable checkpoint: Through record 419. Reconnect request: Replay from 420; deduplicate by session.
nRF52840 host documentation · Motion logger project and storage worksheet · FIFO watermark and service-time budget · Find the first rejected write in a queue · LSM6DSOX device documentation
Bring a reconnect trace with session IDs, durable checkpoint, device retention range and any explicit gap event. Prepare an engineering review.
References
Back to Tutorials