Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Apr 19, 2024
2 parents 19d19e9 + b5075a2 commit 645e8b4
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

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;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;

import android.content.Intent;
import android.os.Bundle;

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;
Expand All @@ -26,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()) {
Expand Down Expand Up @@ -63,7 +68,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
Expand Down Expand Up @@ -147,7 +152,16 @@ 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 (getBestCollectorHardwareName().equals("G7")) {// If we are using G7 or One+
if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // Only if there is connectivity
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);
}
bundle.putLong(Intents.EXTRA_TIMESTAMP, bgReading.timestamp);

addDisplayInformation(bundle);
Expand Down

0 comments on commit 645e8b4

Please sign in to comment.