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!
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) {