Initial G6 support
This commit is contained in:
parent
d750438cd3
commit
946b2bfd12
8 changed files with 138 additions and 5 deletions
|
@ -470,14 +470,14 @@ public class NSUpload {
|
|||
DbLogger.dbAdd(intent, data.toString());
|
||||
}
|
||||
|
||||
public static void uploadBg(BgReading reading) {
|
||||
public static void uploadBg(BgReading reading, String source) {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("action", "dbAdd");
|
||||
bundle.putString("collection", "entries");
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("device", "AndroidAPS-DexcomG5");
|
||||
data.put("device", source);
|
||||
data.put("date", reading.date);
|
||||
data.put("dateString", DateUtil.toISOString(reading.date));
|
||||
data.put("sgv", reading.value);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
|
|||
bgReading.raw = 0;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading);
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-DexcomG5");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 30.11.2018.
|
||||
*/
|
||||
|
||||
public class SourceDexcomG6Plugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceDexcomG6Plugin plugin = null;
|
||||
|
||||
public static SourceDexcomG6Plugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceDexcomG6Plugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceDexcomG6Plugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.DexcomG6)
|
||||
.shortName(R.string.dexcomG6_shortname)
|
||||
.preferencesId(R.xml.pref_dexcomg5)
|
||||
.description(R.string.description_source_dexcom_g6)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE)) {
|
||||
if (bundle.containsKey("transmitterSystemTime"))
|
||||
log.debug("transmitterSystemTime: " + DateUtil.dateAndTimeFullString(bundle.getLong("transmitterSystemTime")));
|
||||
log.debug("transmitterId: " + bundle.getString("transmitterId"));
|
||||
if (bundle.containsKey("transmitterActivatedOn"))
|
||||
log.debug("transmitterActivatedOn: " + DateUtil.dateAndTimeFullString(bundle.getLong("transmitterActivatedOn")));
|
||||
log.debug("transmitterVersion: " + bundle.getString("transmitterVersion"));
|
||||
log.debug("transmitterSoftwareNumber: " + bundle.getString("transmitterSoftwareNumber"));
|
||||
log.debug("transmitterStorageTimeDays: " + bundle.getInt("transmitterStorageTimeDays"));
|
||||
log.debug("transmitterApiVersion: " + bundle.getInt("transmitterApiVersion"));
|
||||
log.debug("transmitterMaxRuntimeDays: " + bundle.getInt("transmitterMaxRuntimeDays"));
|
||||
log.debug("transmitterMaxStorageTimeDays: " + bundle.getInt("transmitterMaxStorageTimeDays"));
|
||||
log.debug("transmitterCGMProcessorFirmwareVersion: " + bundle.getString("transmitterCGMProcessorFirmwareVersion"));
|
||||
log.debug("transmitterBleRadioFirmwareVersion: " + bundle.getString("transmitterBleRadioFirmwareVersion"));
|
||||
log.debug("transmitterHardwareVersion: " + bundle.getInt("transmitterHardwareVersion"));
|
||||
log.debug("transmitterBleSoftDeviceVersion: " + bundle.getString("transmitterBleSoftDeviceVersion"));
|
||||
log.debug("transmitterNordicAsicHwID: " + bundle.getInt("transmitterNordicAsicHwID"));
|
||||
log.debug("transmitterSessionTimeDays: " + bundle.getInt("transmitterSessionTimeDays"));
|
||||
log.debug("transmitterFeatureFlags: " + bundle.getInt("transmitterFeatureFlags"));
|
||||
|
||||
if (bundle.containsKey("sensorInsertionTime"))
|
||||
log.debug("sensorInsertionTime: " + DateUtil.dateAndTimeFullString(bundle.getLong("sensorInsertionTime")));
|
||||
|
||||
if (bundle.containsKey("sensorCode"))
|
||||
log.debug("sensorCode: " + bundle.getString("sensorCode"));
|
||||
|
||||
if (bundle.containsKey("evgTimestamps")) {
|
||||
long[] timestamps = bundle.getLongArray("evgTimestamps");
|
||||
long[] transmitterTimes = bundle.getLongArray("transmitterTimes");
|
||||
int[] evgs = bundle.getIntArray("evgs");
|
||||
int[] predictiveEVGs = bundle.getIntArray("predictiveEVGs");
|
||||
String[] trendArrows = bundle.getStringArray("trendArrows");
|
||||
|
||||
for (int i = 0; i < transmitterTimes.length; i++) {
|
||||
BgReading bgReading = new BgReading();
|
||||
bgReading.value = evgs[i];
|
||||
bgReading.direction = trendArrows[i];
|
||||
bgReading.date = timestamps[i];
|
||||
bgReading.raw = 0;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG6");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-DexcomG6");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.containsKey("meterValues")) {
|
||||
int[] meterValues = bundle.getIntArray("meterValues");
|
||||
String[] meterEntryTypes = bundle.getStringArray("meterEntryTypes");
|
||||
long[] meterTimestamps = bundle.getLongArray("meterTimestamps");
|
||||
long[] meterTransmitterTimestamps = bundle.getLongArray("meterTransmitterTimestamps");
|
||||
long[] meterRecordedTimestamps = bundle.getLongArray("meterRecordedTimestamps");
|
||||
int[] meterRecordIDs = bundle.getIntArray("meterRecordIDs");
|
||||
|
||||
for (int i = 0; i < meterValues.length; i++) {
|
||||
if (L.isEnabled(L.BGSOURCE)) {
|
||||
log.debug("meterValues: " + meterValues[i] + " meterEntryTypes: " + meterEntryTypes[i] + " meterTimestamps: " + meterTimestamps[i] + " meterTransmitterTimestamps: " +
|
||||
meterTransmitterTimestamps[i] + " meterRecordedTimestamps: " + meterRecordedTimestamps[i] + " meterRecordIDs: " + meterRecordIDs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
|
|||
|
||||
public void detectSource(String source, long timeStamp) {
|
||||
if (timeStamp > lastBGTimeStamp) {
|
||||
if (source.contains("G5 Native") || source.contains("G6 Native") || source.contains("AndroidAPS-DexcomG5"))
|
||||
if (source.contains("G5 Native") || source.contains("G6 Native") || source.contains("AndroidAPS-DexcomG5") || source.contains("AndroidAPS-DexcomG6"))
|
||||
isAdvancedFilteringEnabled = true;
|
||||
else
|
||||
isAdvancedFilteringEnabled = false;
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface
|
|||
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading);
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Poctech");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG6Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
|
@ -68,6 +69,8 @@ public class DataService extends IntentService {
|
|||
SourceGlimpPlugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.DEXCOMG5_BG.equals(action)) {
|
||||
SourceDexcomG5Plugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.DEXCOMG6_BG.equals(action)) {
|
||||
SourceDexcomG6Plugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.POCTECH_BG.equals(action)) {
|
||||
SourcePoctechPlugin.getPlugin().handleNewData(intent);
|
||||
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
||||
|
|
|
@ -49,6 +49,7 @@ public interface Intents {
|
|||
String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
|
||||
|
||||
String DEXCOMG5_BG = "com.dexcom.cgm.DATA";
|
||||
String DEXCOMG6_BG = "com.dexcom.cgm.AndroidAPSEVGCallback.Broadcast";
|
||||
|
||||
String POCTECH_BG = "com.china.poctech.data";
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<string name="description_sensitivity_oref1">Sensitivity is calculated from 8h data in the past and carbs (if not absorbed) are cut after time specified in preferences. Plugin also calculates UAM.</string>
|
||||
<string name="description_sensitivity_weighted_average">Sensitivity is calculated as a weighted average from deviations. Newer deviations have higher weight. Minimal carb absorption is calculated from max carb absorption time from preferences. This algorithm is the fastest in following sensitivity changes.</string>
|
||||
<string name="description_source_dexcom_g5">Receive BG values from the patched Dexcom G5 app.</string>
|
||||
<string name="description_source_dexcom_g6">Receive BG values from the patched Dexcom G6 app.</string>
|
||||
<string name="description_source_glimp">Receive BG values from Glimp.</string>
|
||||
<string name="description_source_mm640g">Receive BG values from the 600SeriesAndroidUploader.</string>
|
||||
<string name="description_source_ns_client">Downloads BG data from Nightscout</string>
|
||||
|
@ -799,6 +800,7 @@
|
|||
<string name="btwatchdog_title">BT Watchdog</string>
|
||||
<string name="btwatchdog_summary">Switches off the phone\'s bluetooth for one second if no connection to the pump is possible. This may help on some phones where the bluetooth stack freezes.</string>
|
||||
<string name="DexcomG5">DexcomG5 App (patched)</string>
|
||||
<string name="DexcomG6">DexcomG6 App (patched)</string>
|
||||
<string name="dexcomg5_nsupload_title">Upload BG data to NS</string>
|
||||
<string name="key_dexcomg5_nsupload" translatable="false">dexcomg5_nsupload</string>
|
||||
<string name="dexcomg5_upload">G5 upload settings</string>
|
||||
|
@ -960,6 +962,7 @@
|
|||
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
|
||||
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
|
||||
<string name="dexcomG5_shortname" translatable="false">G5</string>
|
||||
<string name="dexcomG6_shortname" translatable="false">G6</string>
|
||||
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
|
||||
<string name="wear_predictions_title">Predictions</string>
|
||||
<string name="data_choices">Data Choices</string>
|
||||
|
|
Loading…
Reference in a new issue