Skip to content

Stop a bolus at a fault and keep reporting what it left undelivered - #30

Merged
ps2 merged 3 commits into
mainfrom
freeze-bolus-at-fault
Nov 4, 2026
Merged

ps2 merged 3 commits into
mainfrom
freeze-bolus-at-fault

Conversation

@ps2

@ps2 ps2 commented Nov 4, 2026

Copy link
Copy Markdown

A faulted pod's bolus remaining was counted down to the time the status was read, not the time of the fault. So:

  • A fault read after the bolus's scheduled end reported 0 U not delivered, and the app recorded the whole bolus.
  • A fault read earlier reported what would have been left at the read, not at the fault: a 4 U bolus faulted at about 0.5 U and read 35 s later reported 1.95 U not delivered.

A real pod stops delivering at the fault and reports the same remainder however late it is read. That is what loopandlearn/OmnipodKit#211 handles, and why it couldn't be tested here.

SetFault now saves the bolus remaining at the fault, takes it back off the delivered total (and returns it to the reservoir), and ends the bolus. A faulted pod reports the saved amount from then on. A second fault code doesn't take it again, and clearing the fault (0) forgets it.

The 80-hour 0x1C fault, raised when a status is read, still sets only the fault code.

New tests in pkg/pod/state_test.go: a fault 20 s into an 80-pulse bolus reports 70 pulses remaining and reduces delivered by 70; a fault with no bolus running reports none. go test ./... passes.

ps2 added 3 commits November 4, 2026 16:16
A faulted pod's bolus remaining was counted down to the time the status
was read, so a fault read after the bolus's scheduled end reported
nothing undelivered, and one read earlier reported less than was left at
the fault. A real pod stops delivering at the fault.

SetFault now saves the bolus remaining at the fault, takes it back off
the delivered total, and ends the bolus. A faulted pod reports the saved
amount; clearing the fault forgets it.
@ps2
ps2 merged commit 544103a into main Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant