diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt index 6d5b3cd4b2..ecca2d8712 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt @@ -210,10 +210,7 @@ import kotlin.math.round return result } - override fun lastDataTime(): Long { - return medtrumPump.lastTimeReceivedFromPump - } - + override fun lastDataTime(): Long = medtrumPump.lastConnection override val baseBasalRate: Double get() = medtrumPump.baseBasalRate diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt index c68b801e83..9478419527 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt @@ -140,10 +140,11 @@ class MedtrumPump @Inject constructor( val pumpType: PumpType = PumpType.MEDTRUM_NANO // TODO, type based on pumpSN or pump activation/connection - var lastTimeReceivedFromPump = 0L // Time in seconds! - var suspendTime = 0L // Time in seconds! - var patchStartTime = 0L // Time in seconds! - var patchAge = 0L // Time in seconds! + var lastConnection = 0L // Time in ms! + var lastTimeReceivedFromPump = 0L // Time in ms! // TODO: Consider removing as is not used? + var suspendTime = 0L // Time in ms! + var patchStartTime = 0L // Time in ms! + var patchAge = 0L // Time in seconds?! // TODO: Not used var batteryVoltage_A = 0.0 diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt index 7b231ac4b8..b3bf3c3308 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/comm/packets/NotificationPacket.kt @@ -87,7 +87,7 @@ class NotificationPacket(val injector: HasAndroidInjector) { if (fieldMask and MASK_SUSPEND != 0) { aapsLogger.debug(LTag.PUMPCOMM, "Suspend notification received") - medtrumPump.suspendTime = data.copyOfRange(offset, offset + 4).toLong() + medtrumPump.suspendTime = MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(data.copyOfRange(offset, offset + 4).toLong()) aapsLogger.debug(LTag.PUMPCOMM, "Suspend time: ${medtrumPump.suspendTime}") offset += 4 } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt index 4df7931204..7ed869956b 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt @@ -171,6 +171,7 @@ class MedtrumService : DaggerService(), BLECommCallback { aapsLogger.error(LTag.PUMPCOMM, "Failed to sync records") return } + if (result) medtrumPump.lastConnection = System.currentTimeMillis() } fun setBolus(insulin: Double, t: EventOverviewBolusProgress.Treatment): Boolean {