update NS values from patched Dexcom app smoothing
This commit is contained in:
parent
7763a96d6a
commit
d93865997c
|
@ -137,7 +137,7 @@ public class MainApp extends DaggerApplication {
|
|||
filter.addAction(Intents.ACTION_NEW_TREATMENT);
|
||||
filter.addAction(Intents.ACTION_CHANGED_TREATMENT);
|
||||
filter.addAction(Intents.ACTION_REMOVED_TREATMENT);
|
||||
//filter.addAction(Intents.ACTION_NEW_SGV);
|
||||
filter.addAction(Intents.ACTION_NEW_SGV);
|
||||
filter.addAction(Intents.ACTION_NEW_PROFILE);
|
||||
filter.addAction(Intents.ACTION_NEW_MBG);
|
||||
filter.addAction(Intents.ACTION_NEW_CAL);
|
||||
|
|
|
@ -136,8 +136,12 @@ class DexcomPlugin @Inject constructor(
|
|||
dexcomPlugin.disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)).subscribe({ savedValues ->
|
||||
savedValues.forEach {
|
||||
broadcastToXDrip(it)
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false))
|
||||
nsUpload.uploadBg(BgReading(injector, it), sourceSensor.text)
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
if (it.interfaceIDs.nightscoutId != null)
|
||||
nsUpload.updateBg(BgReading(injector, it), sourceSensor.text)
|
||||
else
|
||||
nsUpload.uploadBg(BgReading(injector, it), sourceSensor.text)
|
||||
}
|
||||
}
|
||||
}, {
|
||||
aapsLogger.error(LTag.BGSOURCE, "Error while saving values from Dexcom App", it)
|
||||
|
|
|
@ -107,6 +107,7 @@ class NSClientSourcePlugin @Inject constructor(
|
|||
noise = null,
|
||||
raw = if (sgv.filtered != null) sgv.filtered.toDouble() else sgv.mgdl.toDouble(),
|
||||
trendArrow = GlucoseValue.TrendArrow.fromString(sgv.direction),
|
||||
nightscoutId = sgv.id,
|
||||
sourceSensor = GlucoseValue.SourceSensor.fromString(sgv.device)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -417,6 +417,24 @@ public class NSUpload {
|
|||
uploadQueue.add(new DbRequest("dbAdd", "entries", data));
|
||||
}
|
||||
|
||||
public void updateBg(BgReading reading, String source) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("device", source);
|
||||
data.put("date", reading.getDate());
|
||||
data.put("dateString", DateUtil.toISOString(reading.getDate()));
|
||||
data.put("sgv", reading.getValue());
|
||||
data.put("direction", reading.getData().getTrendArrow().getText());
|
||||
data.put("type", "sgv");
|
||||
if (reading.getData().getInterfaceIDs_backing() != null)
|
||||
if (reading.getData().getInterfaceIDs_backing().getNightscoutId() != null) {
|
||||
uploadQueue.add(new DbRequest("dbUpdate", "entries", reading.getData().getInterfaceIDs_backing().getNightscoutId(), data));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void uploadAppStart() {
|
||||
if (sp.getBoolean(R.string.key_ns_logappstartedevent, true)) {
|
||||
JSONObject data = new JSONObject();
|
||||
|
|
|
@ -34,13 +34,14 @@ data class GlucoseValue(
|
|||
|
||||
fun contentEqualsTo(other: GlucoseValue): Boolean =
|
||||
timestamp == other.timestamp &&
|
||||
utcOffset == other.utcOffset &&
|
||||
raw == other.raw &&
|
||||
value == other.value &&
|
||||
trendArrow == other.trendArrow &&
|
||||
noise == other.noise &&
|
||||
sourceSensor == other.sourceSensor &&
|
||||
isValid == other.isValid
|
||||
utcOffset == other.utcOffset &&
|
||||
raw == other.raw &&
|
||||
value == other.value &&
|
||||
trendArrow == other.trendArrow &&
|
||||
noise == other.noise &&
|
||||
sourceSensor == other.sourceSensor &&
|
||||
isValid == other.isValid &&
|
||||
interfaceIDs?.nightscoutId == other.interfaceIDs?.nightscoutId
|
||||
|
||||
fun isRecordDeleted(other: GlucoseValue): Boolean =
|
||||
isValid && !other.isValid
|
||||
|
@ -94,7 +95,8 @@ data class GlucoseValue(
|
|||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(source : String?) = values().firstOrNull {it.text == source} ?: UNKNOWN
|
||||
|
||||
fun fromString(source: String?) = values().firstOrNull { it.text == source } ?: UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue