Skip to content

Commit

Permalink
Merge pull request #37 from loopandlearn/fix/bogus_suspend_msg
Browse files Browse the repository at this point in the history
Update logic to prevent bogus suspend error after comms error
  • Loading branch information
marionbarker authored Jul 27, 2024
2 parents f55c080 + 18233ca commit 03d3a1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions OmniKit/PumpManager/OmnipodPumpManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1870,8 +1870,8 @@ extension OmnipodPumpManager: PumpManager {
state.bolusEngageState = .engaging
})

if let podState = self.state.podState, podState.isSuspended || podState.lastDeliveryStatusReceived?.suspended != false {
self.log.error("enactBolus: returning pod suspended error for bolus")
if let podState = self.state.podState, podState.isSuspended || podState.lastDeliveryStatusReceived?.suspended == true {
self.log.error("Not enacting bolus because podState or last status received indicates pod is suspended")
completion(.deviceState(PodCommsError.podSuspended))
return
}
Expand Down Expand Up @@ -2009,8 +2009,8 @@ extension OmnipodPumpManager: PumpManager {
return
}

if let podState = self.state.podState, podState.isSuspended || podState.lastDeliveryStatusReceived?.suspended != false {
self.log.info("Not enacting temp basal because podState indicates pod is suspended.")
if let podState = self.state.podState, podState.isSuspended || podState.lastDeliveryStatusReceived?.suspended == true {
self.log.info("Not enacting temp basal because podState or last status received indicates pod is suspended")
completion(.deviceState(PodCommsError.podSuspended))
return
}
Expand Down
5 changes: 5 additions & 0 deletions OmniKit/PumpManager/PodCommsSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,11 @@ public class PodCommsSession {
log.default("bolus: pod is still bolusing")
return DeliveryCommandResult.certainFailure(error: .unfinalizedBolus)
}
// If the pod setup is complete, also confirm that the pod is indeed not suspended
if podState.setupProgress == .completed && statusResponse.deliveryStatus.suspended {
log.default("bolus: pod is suspended")
return DeliveryCommandResult.certainFailure(error: .podSuspended)
}
} else {
log.default("bolus: failed to read pod status to verify there is no bolus running")
return DeliveryCommandResult.certainFailure(error: .noResponse)
Expand Down

0 comments on commit 03d3a1d

Please sign in to comment.