Repository navigation
feat: add auto-save for SD card every 2s in sync mode - #9954
Merged
Merged
Conversation
Collaborator
Author
mdmohsin7
approved these changes
Jul 18, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
Today the device only advances the SD ring read pointer after the entire sync
finishes (after
NOTIFY_DONE— the app advances only on completion, by design,for data safety). Two consequences:
MB, and a full sync takes hours. Free space on the device stays flat the whole
time and only jumps at the end.
app backgrounded, etc.). Since
read_seqwasn't advanced, on reconnect the appre-reads from the original pointer and the whole sync restarts from the
beginning — potentially re-sending hundreds of MB.
Change
Advance + persist the ring
read_seqincrementally, as data is confirmeddelivered to the phone (counted in the BLE TX-completion callback), checkpointed
every ~2 s and once more on
DONE/ disconnect.ever freed → safe, no over-advance / data loss.
read_seq, so a dropped syncresumes near where it stopped instead of restarting from scratch.
Compatible with the current app: it still reads from
read_seqand still sendsCMD_RING_ADVANCEafterDONE(now a no-op since we've already advanced).Implementation
storage.c— accumulate TX-confirmed bytes;sync_checkpoint_advance()advancesread_seqto the confirmed seq (throttled 2 s, forced on DONE/disconnect) andupdates the cached used/free/unread counters without touching the SD.
sd_card.c/sd_card.h—sd_ring_advance_async(): fire-and-forget ring advanceon the SD worker.