From 850f72924b475bd7a8d42805f24cb32a198335a2 Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Mon, 17 Jul 2023 20:34:27 +0200 Subject: [PATCH] Fix data comes from another pump after activation --- .../nightscout/pump/medtrum/comm/packets/ActivatePacket.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacket.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacket.kt index 972d36b6a9..377f9240df 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacket.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/ActivatePacket.kt @@ -75,6 +75,10 @@ class ActivatePacket(injector: HasAndroidInjector, private val basalProfile: Byt val dailyMaxInsulin: Int = round(medtrumPump.desiredDailyMaxInsulin / 0.05).toInt() 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( 2 ) + 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.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 pumpSync.insertTherapyEventIfNewWithTimestamp( timestamp = System.currentTimeMillis(),