Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block incorrect raw timestamp #3123

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading