diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/models/Calibration.java b/app/src/main/java/com/eveningoutpost/dexdrip/models/Calibration.java index a2fd9e97d2..6b1a38fcf5 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/models/Calibration.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/models/Calibration.java @@ -41,6 +41,7 @@ import static com.eveningoutpost.dexdrip.models.BgReading.isDataSuitableForDoubleCalibration; import static com.eveningoutpost.dexdrip.calibrations.PluggableCalibration.newFingerStickData; +import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getDexCollectionType; class DexParameters extends SlopeParameters { @@ -639,7 +640,7 @@ public static Calibration create(double bg, long timeoffset, Context context, bo } else { Log.d(TAG, "Follower mode or note so not processing calibration deeply"); } - } else { + } else if (SensorSanity.isRawCapable(getDexCollectionType())) { // Only if the sensor can provide raw values final String msg = "Sensor data fails sanity test - Cannot Calibrate! raw:" + bgReading.raw_data; UserError.Log.e(TAG, msg); JoH.static_toast_long(msg); diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/models/SensorSanity.java b/app/src/main/java/com/eveningoutpost/dexdrip/models/SensorSanity.java index 6891c76048..fdeaad16b3 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/models/SensorSanity.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/models/SensorSanity.java @@ -1,5 +1,7 @@ package com.eveningoutpost.dexdrip.models; +import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getDexCollectionType; + import com.eveningoutpost.dexdrip.Home; import com.eveningoutpost.dexdrip.models.UserError.Log; import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore; @@ -25,12 +27,16 @@ public class SensorSanity { private static final String TAG = "SensorSanity"; + public static boolean isRawCapable(DexCollectionType type) { // This is true only if the sensor can provide raw values + return (DexCollectionType.hasDexcomRaw(type) || DexCollectionType.hasLibre(type) || type == DexCollectionType.Medtrum); + } + public static boolean isRawValueSane(double raw_value) { - return isRawValueSane(raw_value, DexCollectionType.getDexCollectionType(), false); + return isRawValueSane(raw_value, getDexCollectionType(), false); } public static boolean isRawValueSane(double raw_value, boolean hard) { - return isRawValueSane(raw_value, DexCollectionType.getDexCollectionType(), hard); + return isRawValueSane(raw_value, getDexCollectionType(), hard); } public static boolean isRawValueSane(double raw_value, DexCollectionType type) { @@ -71,7 +77,7 @@ public static boolean isRawValueSane(double raw_value, DexCollectionType type, b else if (raw_value > DEXCOM_MAX_RAW) state = false; } - if (!state) { + if (!state && isRawCapable(type)) { if (JoH.ratelimit("sanity-failure", 20)) { final String msg = "Sensor Raw Data Sanity Failure: " + raw_value; UserError.Log.e(TAG, msg);