|
@@ -380,15 +380,20 @@ public class PodCommsSession {
|
|
|
podState.finalizedDoses.append(UnfinalizedDose(resumeStartTime: currentDate, scheduledCertainty: .certain, insulinType: podState.insulinType))
|
|
podState.finalizedDoses.append(UnfinalizedDose(resumeStartTime: currentDate, scheduledCertainty: .certain, insulinType: podState.insulinType))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Configures the given pod alert(s) and registers the newly configured alert slot(s).
|
|
|
|
|
+ // When re-configuring all the pod alerts for a silence pod toggle, the optional acknowledgeAll can be
|
|
|
|
|
+ // specified to first acknowledge and clear all possible pending pod alerts and pod alert configurations.
|
|
|
@discardableResult
|
|
@discardableResult
|
|
|
func configureAlerts(_ alerts: [PodAlert], acknowledgeAll: Bool = false, beepBlock: MessageBlock? = nil) throws -> StatusResponse {
|
|
func configureAlerts(_ alerts: [PodAlert], acknowledgeAll: Bool = false, beepBlock: MessageBlock? = nil) throws -> StatusResponse {
|
|
|
let configurations = alerts.map { $0.configuration }
|
|
let configurations = alerts.map { $0.configuration }
|
|
|
let configureAlerts = ConfigureAlertsCommand(nonce: podState.currentNonce, configurations: configurations)
|
|
let configureAlerts = ConfigureAlertsCommand(nonce: podState.currentNonce, configurations: configurations)
|
|
|
- var blocksToSend: [MessageBlock] = [configureAlerts]
|
|
|
|
|
|
|
+ let blocksToSend: [MessageBlock]
|
|
|
if acknowledgeAll {
|
|
if acknowledgeAll {
|
|
|
- // requested to acknowledge any possible pending pod alerts out of an abundnace of caution
|
|
|
|
|
- let acknowledgeAll = AcknowledgeAlertCommand(nonce: podState.currentNonce, alerts: AlertSet(rawValue: ~0))
|
|
|
|
|
- blocksToSend += [acknowledgeAll]
|
|
|
|
|
|
|
+ // Do the acknowledgeAllAlerts command first to clear all previous pod alert configurations.
|
|
|
|
|
+ let acknowledgeAllAlerts = AcknowledgeAlertCommand(nonce: podState.currentNonce, alerts: AlertSet(rawValue: ~0))
|
|
|
|
|
+ blocksToSend = [acknowledgeAllAlerts, configureAlerts]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ blocksToSend = [configureAlerts]
|
|
|
}
|
|
}
|
|
|
let status: StatusResponse = try send(blocksToSend, beepBlock: beepBlock)
|
|
let status: StatusResponse = try send(blocksToSend, beepBlock: beepBlock)
|
|
|
for alert in alerts {
|
|
for alert in alerts {
|