Loosen time diff allowance

This commit is contained in:
jbr7rr 2023-07-20 20:06:49 +02:00
parent 3ce566ca7c
commit c0f1fcda0f

View file

@ -768,17 +768,12 @@ class MedtrumService : DaggerService(), BLECommCallback {
// Succes! // Succes!
responseHandled = true responseHandled = true
responseSuccess = true responseSuccess = true
val currTime = dateUtil.nowWithoutMilliseconds() val currTime = dateUtil.now()
if (abs(medtrumPump.lastTimeReceivedFromPump - currTime) <= T.secs(5).msecs()) { // Allow 5 sec deviation 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()) toState(SynchronizeState())
} else { } else {
aapsLogger.debug( aapsLogger.warn(LTag.PUMPCOMM, "GetTimeState.onIndication time difference too big, setting time")
LTag.PUMPCOMM,
"GetTimeState.onIndication need to set time. systemTime: $currTime PumpTime: ${medtrumPump.lastTimeReceivedFromPump} Pump Time to system time: " + timeUtil
.convertPumpTimeToSystemTimeMillis(
medtrumPump.lastTimeReceivedFromPump
)
)
toState(SetTimeState()) toState(SetTimeState())
} }
} else if (mPacket?.failed == true) { } else if (mPacket?.failed == true) {