From 986d9fb01c77c3185ab24b82a7339a2bed5fcac4 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 23 Jun 2018 01:28:49 +0200 Subject: [PATCH] Detect source from NSClient BG. --- .../androidaps/plugins/Source/SourceNSClientPlugin.java | 5 ++++- .../androidaps/plugins/Source/SourceXdripPlugin.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java index b082fc95b0..5a54541aa9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java @@ -19,6 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv; +import info.nightscout.utils.JsonHelper; /** * Created by mike on 05.08.2016. @@ -65,7 +66,9 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac for (int i = 0; i < jsonArray.length(); i++) { JSONObject sgvJson = jsonArray.getJSONObject(i); BgReading bgReading = new BgReading(new NSSgv(sgvJson)); - bgReading.filtered = false; + String sourceDescription = JsonHelper.safeGetString(sgvJson, "device"); + bgReading.filtered = sourceDescription != null + && (sourceDescription.equals("G5 Native") || sourceDescription.equals("AndroidAPS-DexcomG5")); bgReading.sourcePlugin = getName(); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); if (isNew) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java index 6349d9050b..6fe5564c91 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java @@ -47,7 +47,8 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME); bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); - bgReading.filtered = Objects.equals(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION), "G5 Native"); + String sourceDescription = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, ""); + bgReading.filtered = sourceDescription.equals("G5 Native") || sourceDescription.equals("AndroidAPS-DexcomG5"); bgReading.sourcePlugin = getName(); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());