Skip to content

Commit

Permalink
Merge pull request #3123 from Navid200/Navid_2023_10_05
Browse files Browse the repository at this point in the history
Block incorrect raw timestamp
  • Loading branch information
jamorham authored Oct 17, 2023
2 parents c6b15c5 + 163b7f6 commit 9e2f910
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -1609,8 +1610,13 @@ 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);
Ob1G5CollectionService.setLast_transmitter_timestamp(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.");
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);
}
if (sensorRx.unfiltered == 0) {
UserError.Log.e(TAG, "Transmitter sent raw sensor value of 0 !! This isn't good. " + JoH.hourMinuteString());
} else {
Expand Down

0 comments on commit 9e2f910

Please sign in to comment.