From c0f1fcda0f6eac0f1778a8e5930d67c87837cf6d Mon Sep 17 00:00:00 2001 From: jbr7rr <> Date: Thu, 20 Jul 2023 20:06:49 +0200 Subject: [PATCH] Loosen time diff allowance --- .../pump/medtrum/services/MedtrumService.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 7f73766b03..d70fcc31f3 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 @@ -768,17 +768,12 @@ class MedtrumService : DaggerService(), BLECommCallback { // Succes! responseHandled = true responseSuccess = true - val currTime = dateUtil.nowWithoutMilliseconds() - if (abs(medtrumPump.lastTimeReceivedFromPump - currTime) <= T.secs(5).msecs()) { // Allow 5 sec deviation + val currTime = dateUtil.now() + aapsLogger.debug(LTag.PUMPCOMM, "GetTimeState.onIndication systemTime: $currTime, pumpTime: ${medtrumPump.lastTimeReceivedFromPump}") + if (abs(medtrumPump.lastTimeReceivedFromPump - currTime) <= T.secs(10).msecs()) { // Allow 10 sec deviation toState(SynchronizeState()) } else { - aapsLogger.debug( - LTag.PUMPCOMM, - "GetTimeState.onIndication need to set time. systemTime: $currTime PumpTime: ${medtrumPump.lastTimeReceivedFromPump} Pump Time to system time: " + timeUtil - .convertPumpTimeToSystemTimeMillis( - medtrumPump.lastTimeReceivedFromPump - ) - ) + aapsLogger.warn(LTag.PUMPCOMM, "GetTimeState.onIndication time difference too big, setting time") toState(SetTimeState()) } } else if (mPacket?.failed == true) {