Repository navigation
Fix prime check and pump view commands for pod setup lost comms recovery - #231
marionbarker merged 2 commits into
Conversation
Code ReviewI asked Claude to review the code for PR 228, 229 and 231 with the understanding the PR 231 (this PR) replaces 228.
Finding:There is a nit for 231 = passing on for review - I think "purely defensive" means it can't happen 231-A (low): In practice the pod can't reach Comparing dev and next-dev changesI asked Claude to make a patch for me to apply to next-dev New nit for 231 (dev): PR 231 touches the line "Accepted unacknowledged command … |
Test✅ successful Loop main with code from this PR ConfigurationI built a version from main with this PR and tested with the rPi on an SE 2nd gen phone running iOS 18.7.8 I also asked Claude to make a patch compatible with next-dev and applied the patch to the Test DetailsI did not insert the test code to make this fail or test against actual pods since @itsmojo has already done this. |
marionbarker
left a comment
There was a problem hiding this comment.
Approve by Claude code review, diff review (LGTM) and test build against Loop main or with suitable adjustment, next-dev.
|
This fixes the re-prime from IR-J7SKK8AG. I tested it end to end against the pod simulator (LoopKit/pod) in the iOS Simulator using ImpossiBLE, alongside a Repro on With this PR:
A few minor notes, none of them blocking:
Once this merges, I'll close #228 as superseded. |
ps2
left a comment
There was a problem hiding this comment.
Just a few nits, as noted. No blockers.
|
Response to the 4 listed (Claude?) nits that ps@ listed:
Regarding Claude's 231-A (low): setupProgress is not advanced in the "unexpected progress" branch. suggestion to add PR #231's code that includes Regarding Claude's 231-A (low) suggestion to consider throwing for other "terminal states (.activationTimeExceeded, .faultEventOccurred, .inactive)", I'd rather let the existing mechanisms handle these potential cases so that the user would actually be able to see the "Activation time exceeded" or other pod fault error. |
marionbarker
left a comment
There was a problem hiding this comment.
Approve from Claude review, test build and minimal spot-check.
- at the insert cannula stage, tell rPi to crash after processing next command
- the recovery steps are much cleaner with the new code
Description
This PR obsoletes PR #228 and implements all the items listed at the end of this comment as well as other minor fixes and improvements.
prime() now only attempt to do a prime() on the 2nd time through if the read pod status podProgressStatus is pairingCompleted (i.e., it never received the prime bolus command. This is safest and strongest test to determine if it safe to resend the prime bolus command.
The OmniUIScreen enum order was updated to be in local order with .confirmAttachment after .pairAndPrime and before .insertCannula to reduce confusion.
determineInitialStep() has been updated to return .confirmAttachment in addition to .insertCannula and pairAndPrime based on existing state when podCommState == .activating for improved behavior.
The PodLifeState enum has been expanded so that the nextPodLifecycleAction var for the .podActivating case returns a let screen that could be .pairAndPrime, .confirmAttachment or .insertCannula.
The PodLifeState enum has been updated so that the nextPodLifecycleActionDescription var for the .podActivating case is now "Finish Setup" for the podActivating case to match the pump HUD semantics for an interrupted pod setup.
OmniSettingsViewModel updated for the lifeState OmniPumpManager extension for the podCommState.activating case to select a screen value of either .insertCannula, .confirmAttachment, or .pairAndPrime as determineInitialStep() does.
Add new OmniSettingsViewModel.hasPairedNonFaultedPod var for use for the
Play Test Beepsdiagnostic enabling (i.e., this diagnostic can now be used before pod setup is complete).OmniSettingsView updated to use
lifeState.nextPodLifecycleAction(either .pairAndPrime, .confirmAttachment or .insertCannula) along withlifeState.nextPodLifecycleActionDescription(either "Pair Pod" or "Finish Setup") along with hasPairedNonFaultedPod instead of podOk for the PodDiagnosticView to allowPlay Test Beepsto be available in the pod setup is interrupted by a unacknowledged command.OmniSettingsView now uses
viewModel.hasPairedNonFaultedPodinstead ofviewModel.podOkfor the PodDiagnosticView to allow forPlay Test Beepsto be used before pod setup is complete.Many OmniPumpManager tweaks to match documented and tested restrictions for various pod commands that can be invoked from the pump settings view during an interrupted pod setup.
getDetailsStatus(), readPulseLog(), readPulseLogPlus(), readActivationTimeI(), readTriggeredAlerts()
playTestBeeps(), setConfirmationBeeps(), setSilencePod(), updateExpirationReminder(), updateLowReservoirReminder()
Some old print and log statements were removed or cleaned up in PodCommsSession.
The Claude unit test from PR Don't send the prime again once the pod is past priming #228 was included in this PR.
Testing
There was a large # of tests done using the DASH pod sim. Can create the initial failing condition using the
Crash after processing the next commandbutton on the frontend while the prime bolus is progressing or before the Insert Cannula operation is started. On recovery, should now go directly to theAttach Podview (.confirmAttachment screen) view if the prime operation has been started and enough time has passed for it to finish instead to the end of thePair Podview that has already waited for the prime to finish. Can also test the going directly to theAttach Podview without crashing the pod sim by restarting Loop at different times. If done quickly at start of prime, when tapping onFinish Setupin the main view upon Loop restart should display thePair Podview showing the remaining priming operation. If restarted more slowly so thatFinish Setupisn't tapped before the prime bolus should have been able to finish, then Loop should now skip the.pairAndPrimescreen (Pair Podview) and go directly to the.confirmAttachmentscreen (AKA theAttach Podview) from tapping onFinish Setupin the main view.I also tested using some pretty old Eros and DASH pods and was able to reduce my Eros inventory significantly.;-) I only got one Eros pod from a box of 8 that was made in 2020 to actually beep when filled, but I had no problems testing using my 2021 Eros pods and my 2022 DASH pods. Since it can be a pain trying to test lost pod comms at the wrong time with real pods, I used some special debug code for PodCommsSession to trigger lost comms that remain lost until I manually restored them by patching a debug variable in Xcode. This way I could try all the various commands in the pump view after I entered via a fake unacknowledged command error on the program basal command. Here's the example code that simulates the original failure.
Another way to use this which I did not have time to try is this code to trigger the unacknowledged command (
Unable to Reach Pumpview), then put the pod in a faraday bag and then patch the fakeLostResponse back to false to generate keep the Loop waiting on the pod (more naturally simulate an out of range pod issue). After all the commands are exercised in the pod settings view because of the lost comms, you can just remove the pod from the faraday bag and then try the command of your choice that will success and then lead to theComms Recoveredview when any command is done from the pod settings view. If moving the pod into faraday can be done quickly enough, it might be possible to add afakeLostResponse = falseline just before doing the unacknowledgedMessage throw so that no Xcode patching would be needed to control when the comms are allowed to recover when using any command (including theFinish Setup) in the pump settings views.With Eros pods there might be another even easier (but not yet tried) way to do get this faraday bag effect by simply turning off or switching off the RL immediately when the
Unable to Reach Pumpmodal is displayed when the fake unacknowledged command is triggered. This should also allow the debug code to have an additionalfakeLostResponse = falseline just before doing the unacknowledgedMessage throw so that no Xcode patching would be needed to control when the comms are allowed to recover. In this method, the pod comms can be recovered when desired by simply turning on (&/or switching on) the RL and then running any command in theOmnipod Classicsettings view that does some pod communication (e.g., by tapping onFinish Setrup, the speaker icon to play test beeps, executing any but the lastPod Diagnosticcommand, etc) to trigger the comms recovery that would then allow the setup process to then finish.Notes
I found that the insert cannula operation has all the unacknowledged command handling, but there is no such code for either the prime or the insert cannula boluses. Both of these boluses are special one second per pulse boluses and I'd guess would require some additional work to correctly handle using the unacknowledged command facilities, but there already exists a number of tests using the pod progress status and the PodState.setupProgress values. Did not spend any time looking into looking to see if there might be some unacknowledged cases for the special boluses that we might not be able to handle using the current methods or what might be needed to be able to use generic unacknowledged command facilities to handle these boluses.