Fix data comes from another pump after activation
This commit is contained in:
parent
6a6af81ef7
commit
850f72924b
|
@ -75,6 +75,10 @@ class ActivatePacket(injector: HasAndroidInjector, private val basalProfile: Byt
|
||||||
val dailyMaxInsulin: Int = round(medtrumPump.desiredDailyMaxInsulin / 0.05).toInt()
|
val dailyMaxInsulin: Int = round(medtrumPump.desiredDailyMaxInsulin / 0.05).toInt()
|
||||||
val currentTDD: Double = tddCalculator.calculateToday()?.totalAmount?.div(0.05) ?: 0.0
|
val currentTDD: Double = tddCalculator.calculateToday()?.totalAmount?.div(0.05) ?: 0.0
|
||||||
|
|
||||||
|
// Update the pump in the database, technically this is not a new pump only new patch, but still TBR's etc need to be cannceled
|
||||||
|
// Do it here, to make sure TBR's are cancelled by AAPS before new information comes in from the pump
|
||||||
|
pumpSync.connectNewPump()
|
||||||
|
|
||||||
return byteArrayOf(opCode) + autoSuspendEnable + autoSuspendTime + patchExpiration + alarmSetting + lowSuspend + predictiveLowSuspend + predictiveLowSuspendRange + hourlyMaxInsulin.toByteArray(
|
return byteArrayOf(opCode) + autoSuspendEnable + autoSuspendTime + patchExpiration + alarmSetting + lowSuspend + predictiveLowSuspend + predictiveLowSuspendRange + hourlyMaxInsulin.toByteArray(
|
||||||
2
|
2
|
||||||
) + dailyMaxInsulin.toByteArray(2) + currentTDD.toInt().toByteArray(2) + 1.toByte() + basalProfile
|
) + dailyMaxInsulin.toByteArray(2) + currentTDD.toInt().toByteArray(2) + 1.toByte() + basalProfile
|
||||||
|
@ -98,8 +102,6 @@ class ActivatePacket(injector: HasAndroidInjector, private val basalProfile: Byt
|
||||||
medtrumPump.currentSequenceNumber = basalSequence // We are activated, set the new seq nr
|
medtrumPump.currentSequenceNumber = basalSequence // We are activated, set the new seq nr
|
||||||
medtrumPump.syncedSequenceNumber = basalSequence // We are activated, reset the synced seq nr ()
|
medtrumPump.syncedSequenceNumber = basalSequence // We are activated, reset the synced seq nr ()
|
||||||
|
|
||||||
// Update the pump in the database, technically this is not a new pump only new patch, but still TBR's etc need to be cannceled
|
|
||||||
pumpSync.connectNewPump()
|
|
||||||
// Sync canula change
|
// Sync canula change
|
||||||
pumpSync.insertTherapyEventIfNewWithTimestamp(
|
pumpSync.insertTherapyEventIfNewWithTimestamp(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
|
|
Loading…
Reference in a new issue