Medtrum: resetPatchParameters() on deactivation and new SN
This commit is contained in:
parent
40d95c13d9
commit
67805382df
|
@ -115,6 +115,8 @@ class MedtrumPump @Inject constructor(
|
|||
sp.putLong(R.string.key_session_token, value)
|
||||
}
|
||||
|
||||
// Note: This is not always incremented by the pump, so it is not a reliable indicator for activation unless we reset it on deactivation
|
||||
// see resetPatchParameters()
|
||||
private var _patchId = 0L
|
||||
var patchId: Long
|
||||
get() = _patchId
|
||||
|
@ -538,6 +540,12 @@ class MedtrumPump @Inject constructor(
|
|||
return rh.gs(stringId)
|
||||
}
|
||||
|
||||
fun resetPatchParameters() {
|
||||
patchId = 0
|
||||
syncedSequenceNumber = 1
|
||||
currentSequenceNumber = 1
|
||||
}
|
||||
|
||||
fun handleNewPatch(newPatchId: Long, sequenceNumber: Int, newStartTime: Long) {
|
||||
patchId = newPatchId
|
||||
patchStartTime = newStartTime
|
||||
|
|
|
@ -112,6 +112,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Serial number changed, reporting new pump!")
|
||||
medtrumPump.loadUserSettingsFromSP()
|
||||
medtrumPump.deviceType = MedtrumSnUtil().getDeviceTypeFromSerial(medtrumPump.pumpSN)
|
||||
medtrumPump.resetPatchParameters()
|
||||
pumpSync.connectNewPump()
|
||||
medtrumPump.setFakeTBRIfNeeded()
|
||||
}
|
||||
|
@ -534,6 +535,9 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
|||
)
|
||||
medtrumPump.setFakeTBRIfNeeded()
|
||||
medtrumPump.clearAlarmState()
|
||||
|
||||
// Reset sequence numbers, make sure AAPS history can be synced properly on next activation
|
||||
medtrumPump.resetPatchParameters()
|
||||
}
|
||||
|
||||
MedtrumPumpState.IDLE,
|
||||
|
|
Loading…
Reference in a new issue