From 1d77e78019f6291fd23063a9abcc2d38a2f039ed Mon Sep 17 00:00:00 2001 From: Navid Date: Sun, 31 Mar 2024 11:46:17 -0400 Subject: [PATCH 1/3] Broadcast correct G7 sensor start time --- .../dexdrip/utilitymodels/BroadcastGlucose.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java index adfbde9819..04b3b7fddd 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java @@ -2,6 +2,7 @@ import static com.eveningoutpost.dexdrip.models.JoH.dateTimeText; import static com.eveningoutpost.dexdrip.models.JoH.msSince; +import static com.eveningoutpost.dexdrip.services.Ob1G5CollectionService.getTransmitterID; import static com.eveningoutpost.dexdrip.utilitymodels.Constants.MINUTE_IN_MS; import static com.eveningoutpost.dexdrip.utilitymodels.Unitized.usingMgDl; @@ -10,6 +11,8 @@ import com.eveningoutpost.dexdrip.BestGlucose; import com.eveningoutpost.dexdrip.BuildConfig; +import com.eveningoutpost.dexdrip.g5model.DexSessionKeeper; +import com.eveningoutpost.dexdrip.g5model.FirmwareCapability; import com.eveningoutpost.dexdrip.models.BgReading; import com.eveningoutpost.dexdrip.models.Calibration; import com.eveningoutpost.dexdrip.models.JoH; @@ -147,7 +150,11 @@ public static void sendLocalBroadcast(final BgReading bgReading) { } bundle.putInt(Intents.EXTRA_SENSOR_BATTERY, BridgeBattery.getBestBridgeBattery()); - bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, sensor.started_at); + if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // If there is connectivity and firmware is known and it is either G7 or One+ + bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, DexSessionKeeper.getStart()); + } else { // If there is no connectivity yet or if we are not using G7 ot One+ + bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, sensor.started_at); + } bundle.putLong(Intents.EXTRA_TIMESTAMP, bgReading.timestamp); addDisplayInformation(bundle); From 3a1d4452225cf54cdfba044bc280fe3f25477cc9 Mon Sep 17 00:00:00 2001 From: Navid Date: Sun, 7 Apr 2024 10:58:17 -0400 Subject: [PATCH 2/3] Verify collection type --- .../dexdrip/utilitymodels/BroadcastGlucose.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java index 04b3b7fddd..6eb15ee8fa 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java @@ -5,6 +5,7 @@ import static com.eveningoutpost.dexdrip.services.Ob1G5CollectionService.getTransmitterID; import static com.eveningoutpost.dexdrip.utilitymodels.Constants.MINUTE_IN_MS; import static com.eveningoutpost.dexdrip.utilitymodels.Unitized.usingMgDl; +import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName; import android.content.Intent; import android.os.Bundle; @@ -66,7 +67,7 @@ public static void sendLocalBroadcast(final BgReading bgReading) { UserError.Log.i("SENSOR QUEUE:", "Broadcast data"); - String collectorName = DexCollectionType.getBestCollectorHardwareName(); + String collectorName = getBestCollectorHardwareName(); if (collectorName.equals("G6 Native") || collectorName.equals("G7")) { if (collectorName.equals("G7")) { collectorName = "G6 Native"; // compatibility for older AAPS @@ -150,9 +151,11 @@ public static void sendLocalBroadcast(final BgReading bgReading) { } bundle.putInt(Intents.EXTRA_SENSOR_BATTERY, BridgeBattery.getBestBridgeBattery()); - if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // If there is connectivity and firmware is known and it is either G7 or One+ - bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, DexSessionKeeper.getStart()); - } else { // If there is no connectivity yet or if we are not using G7 ot One+ + if (getBestCollectorHardwareName().equals("G7")) {// If we are using G7 or One+ + if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // Only if there is connectivity + bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, DexSessionKeeper.getStart()); + } + } else { // If we are not using G7 or One+ bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, sensor.started_at); } bundle.putLong(Intents.EXTRA_TIMESTAMP, bgReading.timestamp); From 110d8619f7b088e556429a3b08252aa2f3b76618 Mon Sep 17 00:00:00 2001 From: Navid Date: Sun, 7 Apr 2024 14:05:41 -0400 Subject: [PATCH 3/3] Verify Dex start time is valid --- .../dexdrip/utilitymodels/BroadcastGlucose.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java index 6eb15ee8fa..975eb64085 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/BroadcastGlucose.java @@ -30,6 +30,7 @@ public class BroadcastGlucose { private static final String TAG = "BroadcastGlucose"; private static long lastTimestamp = 0; + private static long dexStartedAt = 0; public static void sendLocalBroadcast(final BgReading bgReading) { if (SendXdripBroadcast.enabled()) { @@ -153,7 +154,10 @@ public static void sendLocalBroadcast(final BgReading bgReading) { bundle.putInt(Intents.EXTRA_SENSOR_BATTERY, BridgeBattery.getBestBridgeBattery()); if (getBestCollectorHardwareName().equals("G7")) {// If we are using G7 or One+ if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // Only if there is connectivity - bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, DexSessionKeeper.getStart()); + dexStartedAt = DexSessionKeeper.getStart(); // Session start time reported by the Dexcom transmitter + if (dexStartedAt > 0) { // Only if dexStartedAt is valid + bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, dexStartedAt); + } } } else { // If we are not using G7 or One+ bundle.putLong(Intents.EXTRA_SENSOR_STARTED_AT, sensor.started_at);