Skip to content

Commit f6bd8e5

Browse files
committed
Libre: add Libre2 source info identifier to processed L2 readings
1 parent f768152 commit f6bd8e5

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class LibreAlarmReceiver extends BroadcastReceiver {
5757
private static final Object lock = new Object();
5858
private static long sensorAge = 0;
5959
private static long timeShiftNearest = -1;
60+
public static final String LIBRE_SOURCE_INFO = "Libre2";
6061

6162
public static void clearSensorStats() {
6263
Pref.setInt("nfc_sensor_age", 0); // reset for nfc sensors
@@ -273,7 +274,7 @@ public static void CalculateFromDataTransferObject(ReadingData readingData, bool
273274
if (use_raw) {
274275
createBGfromGD(gd, use_smoothed_data, false); // not quick for recent
275276
} else {
276-
BgReading.bgReadingInsertFromInt(use_smoothed_data ? gd.glucoseLevelSmoothed : gd.glucoseLevel, gd.realDate, segmentation_timeslice, true);
277+
BgReading.bgReadingInsertFromInt(use_smoothed_data ? gd.glucoseLevelSmoothed : gd.glucoseLevel, gd.realDate, segmentation_timeslice, true, LIBRE_SOURCE_INFO);
277278
}
278279
}
279280
} else {
@@ -306,7 +307,9 @@ public static void insertFromHistory(final List<GlucoseData> mHistory, final boo
306307
} else {
307308
polyyList.add((double) gd.glucoseLevel);
308309
// add in the actual value
309-
BgReading.bgReadingInsertFromInt(gd.glucoseLevel, gd.realDate, timeslice, false);
310+
if (gd.glucoseLevel > 0) {
311+
BgReading.bgReadingInsertFromInt(gd.glucoseLevel, gd.realDate, timeslice, false, LIBRE_SOURCE_INFO);
312+
}
310313
}
311314
}
312315

@@ -332,7 +335,7 @@ public static void insertFromHistory(final List<GlucoseData> mHistory, final boo
332335
// Here we do not use smoothed data, since data is already smoothed for the history
333336
createBGfromGD(new GlucoseData((int) polySplineF.value(ptime), ptime), false, true);
334337
} else {
335-
BgReading.bgReadingInsertFromInt((int) polySplineF.value(ptime), ptime, timeslice, false);
338+
BgReading.bgReadingInsertFromInt((int) polySplineF.value(ptime), ptime, timeslice, false, LIBRE_SOURCE_INFO);
336339
}
337340
}
338341
} catch (org.apache.commons.math3.exception.NonMonotonicSequenceException e) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.eveningoutpost.dexdrip;
22

33
import static com.eveningoutpost.dexdrip.Home.get_engineering_mode;
4+
import static com.eveningoutpost.dexdrip.LibreAlarmReceiver.LIBRE_SOURCE_INFO;
45
import static com.eveningoutpost.dexdrip.models.JoH.emptyString;
56
import static com.eveningoutpost.dexdrip.models.Libre2Sensor.Libre2Sensors;
67

78
import android.content.BroadcastReceiver;
89
import android.content.Context;
910
import android.content.Intent;
10-
import android.content.SharedPreferences;
1111
import android.os.Bundle;
1212
import android.os.PowerManager;
13-
import android.preference.PreferenceManager;
1413
import android.text.format.DateFormat;
1514

1615
import com.eveningoutpost.dexdrip.models.BgReading;
@@ -88,7 +87,7 @@ public void run() {
8887
val glucose = item.getDouble("glucoseValue");
8988
val timestamp = item.getLong("timestamp");
9089
if (d) UserError.Log.d(TAG, "Real time item: " + JoH.dateTimeText(timestamp) + " value: " + Unitized.unitized_string_static(glucose));
91-
BgReading.bgReadingInsertFromInt((int) Math.round(glucose), timestamp, timeslice, false);
90+
BgReading.bgReadingInsertFromInt((int) Math.round(glucose), timestamp, timeslice, false, LIBRE_SOURCE_INFO);
9291
}
9392

9493
} catch (Exception e) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,12 @@ public static BgReading bgReadingInsertFromJson(String json, boolean do_notifica
13311331
return bgr;
13321332
}
13331333

1334-
// TODO this method shares some code with above.. merge
13351334
public static void bgReadingInsertFromInt(int value, long timestamp, long margin, boolean do_notification) {
1335+
bgReadingInsertFromInt(value, timestamp, margin, do_notification, "");
1336+
}
1337+
1338+
// TODO this method shares some code with above.. merge
1339+
public static void bgReadingInsertFromInt(int value, long timestamp, long margin, boolean do_notification, String source_info) {
13361340
// TODO sanity check data!
13371341

13381342
if ((value <= 0) || (timestamp <= 0)) {
@@ -1355,6 +1359,8 @@ public static void bgReadingInsertFromInt(int value, long timestamp, long margin
13551359
bgr.age_adjusted_raw_value = value;
13561360
bgr.filtered_data = value;
13571361

1362+
bgr.source_info = source_info;
1363+
13581364
final Sensor forced_sensor = Sensor.currentSensor();
13591365
if (forced_sensor != null) {
13601366
bgr.sensor = forced_sensor;

0 commit comments

Comments
 (0)