From 235b786ac00ae420eab75bc08d6e74e7f4d005f9 Mon Sep 17 00:00:00 2001 From: Navid Date: Mon, 9 Oct 2023 14:46:02 -0400 Subject: [PATCH 1/2] Block incorrect raw timestamp --- .../eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java b/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java index 7d76e2ee35..dc1d06252d 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java @@ -130,6 +130,7 @@ public class Ob1G5StateMachine { private static volatile BgReading lastGlucoseBgReading; private static volatile AuthRequestTxMessage lastAuthPacket; private static volatile boolean backup_loaded = false; + private static final int OLDEST_RAW = 300 * 24 * 60 * 60; // 300 days // Auth Check + Request @SuppressLint("CheckResult") @@ -1609,7 +1610,11 @@ private static void processSensorRxMessage(SensorRxMessage sensorRx) { } UserError.Log.d(TAG, "SUCCESS!! unfiltered: " + sensorRx.unfiltered + " filtered: " + sensorRx.filtered + " timestamp: " + sensorRx.timestamp + " " + JoH.qs((double) sensorRx.timestamp / 86400, 1) + " days :: (" + sensorRx.status + ")"); - DexTimeKeeper.updateAge(getTransmitterID(), sensorRx.timestamp); + if (FirmwareCapability.isTransmitterModified(getTransmitterID()) && sensorRx.timestamp > OLDEST_RAW) { // Raw timestamp reported by a mod TX is incorrect until after sensor start. + UserError.Log.d(TAG, "Will not update age since raw timestamp is incorrect."); + } else { // Update age, based on the raw timestamp, only if the raw timestamp is correct. + DexTimeKeeper.updateAge(getTransmitterID(), sensorRx.timestamp); + } Ob1G5CollectionService.setLast_transmitter_timestamp(sensorRx.timestamp); if (sensorRx.unfiltered == 0) { UserError.Log.e(TAG, "Transmitter sent raw sensor value of 0 !! This isn't good. " + JoH.hourMinuteString()); From 163b7f69be0264f171a480a42a667e14f36ab94c Mon Sep 17 00:00:00 2001 From: Navid Date: Mon, 9 Oct 2023 21:37:39 -0400 Subject: [PATCH 2/2] Don't show 6214 for transmitter days on status page --- .../com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java b/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java index dc1d06252d..fd57491311 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java @@ -1612,10 +1612,11 @@ private static void processSensorRxMessage(SensorRxMessage sensorRx) { UserError.Log.d(TAG, "SUCCESS!! unfiltered: " + sensorRx.unfiltered + " filtered: " + sensorRx.filtered + " timestamp: " + sensorRx.timestamp + " " + JoH.qs((double) sensorRx.timestamp / 86400, 1) + " days :: (" + sensorRx.status + ")"); if (FirmwareCapability.isTransmitterModified(getTransmitterID()) && sensorRx.timestamp > OLDEST_RAW) { // Raw timestamp reported by a mod TX is incorrect until after sensor start. UserError.Log.d(TAG, "Will not update age since raw timestamp is incorrect."); + Ob1G5CollectionService.setLast_transmitter_timestamp(0); } else { // Update age, based on the raw timestamp, only if the raw timestamp is correct. DexTimeKeeper.updateAge(getTransmitterID(), sensorRx.timestamp); + Ob1G5CollectionService.setLast_transmitter_timestamp(sensorRx.timestamp); } - Ob1G5CollectionService.setLast_transmitter_timestamp(sensorRx.timestamp); if (sensorRx.unfiltered == 0) { UserError.Log.e(TAG, "Transmitter sent raw sensor value of 0 !! This isn't good. " + JoH.hourMinuteString()); } else {