sync alarm. bugfix on pod deactivation

This commit is contained in:
Andrei Vereha 2021-08-02 22:47:36 +02:00
parent a77a0b21fb
commit 770a58abd2
3 changed files with 23 additions and 2 deletions

View file

@ -328,6 +328,15 @@ class OmnipodDashPumpPlugin @Inject constructor(
Notification.URGENT, Notification.URGENT,
R.raw.boluserror R.raw.boluserror
) )
if (!podStateManager.alarmSynced) {
pumpSync.insertAnnouncement(
error = podStateManager.alarmType?.toString() ?: "Unknown pod failure",
pumpId = Random.Default.nextLong(),
pumpType = PumpType.OMNIPOD_DASH,
pumpSerial = serialNumber()
)
podStateManager.alarmSynced = true
}
} }
Completable.complete() Completable.complete()
} }
@ -1068,7 +1077,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun deactivatePod(): PumpEnactResult { private fun deactivatePod(): PumpEnactResult {
val ret = executeProgrammingCommand( val ret = executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
command = omnipodManager.deactivatePod().ignoreElements() command = omnipodManager.deactivatePod().ignoreElements(),
checkNoActiveCommand = false,
).doOnComplete { ).doOnComplete {
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT))
}.toPumpEnactResult() }.toPumpEnactResult()

View file

@ -41,6 +41,7 @@ interface OmnipodDashPodStateManager {
val time: ZonedDateTime? val time: ZonedDateTime?
val timeDrift: java.time.Duration? val timeDrift: java.time.Duration?
val expiry: ZonedDateTime? val expiry: ZonedDateTime?
var alarmSynced: Boolean
val messageSequenceNumber: Short val messageSequenceNumber: Short
val sequenceNumberOfLastProgrammingCommand: Short? val sequenceNumberOfLastProgrammingCommand: Short?

View file

@ -233,6 +233,13 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
return null return null
} }
override var alarmSynced: Boolean
get() = podState.alarmSynced
set(value) {
podState.alarmSynced = value
store()
}
override var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState override var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState
@Synchronized @Synchronized
get() = podState.bluetoothConnectionState get() = podState.bluetoothConnectionState
@ -498,8 +505,10 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
podState.lastStatusResponseReceived = 0 podState.lastStatusResponseReceived = 0
} }
CommandSendingFailure, NoActiveCommand -> CommandSendingFailure, NoActiveCommand -> {
podState.activeCommand = null podState.activeCommand = null
podState.lastStatusResponseReceived = 0
}
} }
} }
@ -660,6 +669,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
var eapAkaSequenceNumber: Long = 1 var eapAkaSequenceNumber: Long = 1
var bolusPulsesRemaining: Short = 0 var bolusPulsesRemaining: Short = 0
var timeZone: String = "" // TimeZone ID (e.g. "Europe/Amsterdam") var timeZone: String = "" // TimeZone ID (e.g. "Europe/Amsterdam")
var alarmSynced: Boolean = false
var bleVersion: SoftwareVersion? = null var bleVersion: SoftwareVersion? = null
var firmwareVersion: SoftwareVersion? = null var firmwareVersion: SoftwareVersion? = null