Only update lastDataTime on successful readStatus

This commit is contained in:
jbr7rr 2023-06-04 17:33:33 +02:00
parent 9860c7aac3
commit 6ccfb734d7
4 changed files with 8 additions and 9 deletions

View file

@ -210,10 +210,7 @@ import kotlin.math.round
return result return result
} }
override fun lastDataTime(): Long { override fun lastDataTime(): Long = medtrumPump.lastConnection
return medtrumPump.lastTimeReceivedFromPump
}
override val baseBasalRate: Double override val baseBasalRate: Double
get() = medtrumPump.baseBasalRate get() = medtrumPump.baseBasalRate

View file

@ -140,10 +140,11 @@ class MedtrumPump @Inject constructor(
val pumpType: PumpType = PumpType.MEDTRUM_NANO // TODO, type based on pumpSN or pump activation/connection val pumpType: PumpType = PumpType.MEDTRUM_NANO // TODO, type based on pumpSN or pump activation/connection
var lastTimeReceivedFromPump = 0L // Time in seconds! var lastConnection = 0L // Time in ms!
var suspendTime = 0L // Time in seconds! var lastTimeReceivedFromPump = 0L // Time in ms! // TODO: Consider removing as is not used?
var patchStartTime = 0L // Time in seconds! var suspendTime = 0L // Time in ms!
var patchAge = 0L // Time in seconds! var patchStartTime = 0L // Time in ms!
var patchAge = 0L // Time in seconds?! // TODO: Not used
var batteryVoltage_A = 0.0 var batteryVoltage_A = 0.0

View file

@ -87,7 +87,7 @@ class NotificationPacket(val injector: HasAndroidInjector) {
if (fieldMask and MASK_SUSPEND != 0) { if (fieldMask and MASK_SUSPEND != 0) {
aapsLogger.debug(LTag.PUMPCOMM, "Suspend notification received") 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}") aapsLogger.debug(LTag.PUMPCOMM, "Suspend time: ${medtrumPump.suspendTime}")
offset += 4 offset += 4
} }

View file

@ -171,6 +171,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
aapsLogger.error(LTag.PUMPCOMM, "Failed to sync records") aapsLogger.error(LTag.PUMPCOMM, "Failed to sync records")
return return
} }
if (result) medtrumPump.lastConnection = System.currentTimeMillis()
} }
fun setBolus(insulin: Double, t: EventOverviewBolusProgress.Treatment): Boolean { fun setBolus(insulin: Double, t: EventOverviewBolusProgress.Treatment): Boolean {