Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved unacknowledged command recovery #47

Merged

Conversation

itsmojo
Copy link
Contributor

@itsmojo itsmojo commented Dec 27, 2024

Fix for LoopKit/Loop#2275
Use new tryToResolvePendingCommand() function that try to use getStatus() to resolve a
pending unacknowledged command in most PodCommSession functions instead of just
failing if called with a pending unacknowledged command. Reworked logic to prevent
possible incorrect unacknowledged command handling during pod setup & deactivation.

New resolveUnacknowledgedCommand() attempts a GetStatusCommand to resolve any
unacknowledged command or throws .unacknowledgedCommandPending on failure.
Have all PodCommSession funcs call resolveUnacknowledgedCommand() instead
of failing if called with a pending unacknowledged command.
… code

Fix deactivatePod() logic error to correctly handle an unacknowledged command
Simplify logging by not including the calling function's name
@marionbarker
Copy link
Collaborator

Initial Review

The pair of PR, OmniKit #47 and OmniBLE PR 139: Improved unacknowledged command recovery, will be reviewed and tested in tandem.

Summary

For every instance in which the PodCommsError.unacknowledgedCommandPending is thrown in the current code, this PR attempts a recovery by using the new tryToResolvePendingCommand function. If that attempt fails, then the code throws PodCommsError.unacknowledgedCommandPending as before.

If the recovery succeeds, then the app continues without alerting the user. This should provide a smoother user experience.

Code Review

  • By code inspection, this PR makes the code changes to support the statement in the Summary.
  • The OmniBLE and OmniKit PR were compared side-by-side and both make identical changes.

Build Test

  • The app builds using these versions of OmniBLE and OmniKit with no problems.

Testing

Most of the testing will be done with OmniBLE using the rPi simulator. After that testing is completed and reported in the OmniBLE PR, an Eros pod will be tested. These test results will be provided in future comments.

@marionbarker
Copy link
Collaborator

Similarity

The PR changes for OmniBLE PR 139 and OmniKit PR 47 are identical. If one works, they both should work.

Test:

Repeat a subset of Test: Part 2 from OmniBLE PR 139 using an Eros pod.

The fact that this subset behaved the same with a real Eros pod as it did with the rPi DASH simulator indicates this code works for OmniKit.

Test Method

Adjust the test patch used for OmniBLE to work with OmniKit.

This patch uses two private vars fakeUncertainBeforeSendPercent and fakeUncertainAfterSendPercent to trigger comm failures as desired.

Because this test is done with a real pod (not a pod simulator) the test order is modified from the OmniBLE testing.

Test comm errors

Initial configuration:

  • Configure fakeUncertainAfterSendPercent=1.0 and fakeUncertainBeforeSendPercent=0.01

Pair, Prime and Insert with new Pod
Pair to an actual Eror pod.
Go through pod pair, prime and insert with appropriate adjustment of fakeUncertain var as needed so the sequences can complete

  • allow set-up to proceed until cannot get past the errors
  • set the break point
  • each time the code halts at the breakpoint issue expr fakeUncertainAfterSendPercent=0.0 and continue until pod begins to prime
  • at this point just keep continuing at break point until pod fails to insert
  • each time the code halts at the breakpoint issue expr fakeUncertainAfterSendPercent=0.0 and continue until pod begins to insert
  • disable the break point and continue the test.

2-message commands

Test the commands below:

  • configureAlerts
    • first succeeded (pod beeped)
    • second failed (no beep and error message)
    • hit save again and it succeeded (pod beeped)
  • beepConfig
  • bolus
  • cancelDelivery
  • setTempBasal
  • resumeBasal
  • suspendDelivery
  • setBasalSchedule

Do not test the rest of the items from OmniBLE Test: Part 2. These tests are not needed to approve this PR.
For example:

  • acknowledgeAlerts (can't do this with a new Eros pod)

Final Configuration

Build again on the iPhone 7 connected to the Eros pod without the testing patch. Let it run to pod completion.This does not need to complete in order to approve this PR. But may as well let it run.

Copy link
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status

Code review: Approve
Similar to OmniBLE, so limited testing is OK
Test: Part 2: Success

I approve this PR.

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.

2 participants