Skip to content

Commit ae69a1a

Browse files
authored
Merge pull request #4260 from NightscoutFoundation/tzachi-libre2-source-identifier
Libre: add Libre2 source info identifier to processed L2 readings for oop as well.
2 parents a83f2b2 + b9c45a4 commit ae69a1a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/LibreAlarmReceiver.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ private static boolean useGlucoseAsRaw() {
7474

7575
private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, boolean quick) {
7676
final double converted;
77+
String sourceInfo = null;
7778
if (useGlucoseAsRaw()) {
7879
// if treating converted value as raw
7980
if (gd.glucoseLevel > 0) {
8081
if (use_smoothed_data && gd.glucoseLevelSmoothed > 0) {
8182
converted = gd.glucoseLevelSmoothed * 1000;
83+
sourceInfo = LIBRE_SOURCE_INFO;
8284
Log.e(TAG, "Using smoothed value as raw " + converted + " instead of " + gd.glucoseLevel);
8385
} else {
8486
converted = gd.glucoseLevel * 1000;
@@ -90,6 +92,7 @@ private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, bo
9092
if (gd.glucoseLevelRaw > 0) {
9193
if (use_smoothed_data && gd.glucoseLevelRawSmoothed > 0) {
9294
converted = convert_for_dex(gd.glucoseLevelRawSmoothed);
95+
sourceInfo = LIBRE_SOURCE_INFO;
9396
Log.d(TAG, "Using smoothed value " + converted + " instead of " + convert_for_dex(gd.glucoseLevelRaw) + gd);
9497
} else {
9598
converted = convert_for_dex(gd.glucoseLevelRaw);
@@ -107,7 +110,7 @@ private static void createBGfromGD(GlucoseData gd, boolean use_smoothed_data, bo
107110

108111
if (BgReading.getForPreciseTimestamp(gd.realDate, DexCollectionType.getCurrentDeduplicationPeriod(), false) == null) {
109112
Log.d(TAG, "Creating bgreading at: " + JoH.dateTimeText(gd.realDate));
110-
BgReading.create(converted, converted, xdrip.getAppContext(), gd.realDate, quick); // quick lite insert
113+
BgReading.create(converted, converted, xdrip.getAppContext(), gd.realDate, quick, sourceInfo); // quick lite insert
111114
} else {
112115
if (d)
113116
Log.d(TAG, "Ignoring duplicate timestamp for: " + JoH.dateTimeText(gd.realDate));

app/src/main/java/com/eveningoutpost/dexdrip/models/BgReading.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ public static BgReading create(double raw_data, double filtered_data, Context co
484484
}
485485

486486
public static BgReading create(double raw_data, double filtered_data, Context context, Long timestamp, boolean quick) {
487+
return create(raw_data, filtered_data, context, timestamp, quick, null);
488+
}
489+
490+
public static BgReading create(double raw_data, double filtered_data, Context context, Long timestamp, boolean quick, String source_info) {
487491
if (context == null) context = xdrip.getAppContext();
488492
BgReading bgReading = new BgReading();
489493
final Sensor sensor = Sensor.currentSensor();
@@ -509,13 +513,15 @@ public static BgReading create(double raw_data, double filtered_data, Context co
509513
bgReading.calibration_flag = false;
510514

511515
bgReading.calculateAgeAdjustedRawValue();
516+
bgReading.source_info = source_info;
512517

513518
bgReading.save();
514519
bgReading.perform_calculations();
515520
BgSendQueue.sendToPhone(context);
516521
} else {
517522
Log.d(TAG, "Calibrations, so doing everything: " + calibration.uuid);
518523
bgReading = createFromRawNoSave(sensor, calibration, raw_data, filtered_data, timestamp);
524+
bgReading.source_info = source_info;
519525

520526
bgReading.save();
521527

0 commit comments

Comments
 (0)