update NS values from patched Dexcom app smoothing
This commit is contained in:
parent
7763a96d6a
commit
d93865997c
5 changed files with 36 additions and 11 deletions
|
@ -137,7 +137,7 @@ public class MainApp extends DaggerApplication {
|
||||||
filter.addAction(Intents.ACTION_NEW_TREATMENT);
|
filter.addAction(Intents.ACTION_NEW_TREATMENT);
|
||||||
filter.addAction(Intents.ACTION_CHANGED_TREATMENT);
|
filter.addAction(Intents.ACTION_CHANGED_TREATMENT);
|
||||||
filter.addAction(Intents.ACTION_REMOVED_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_PROFILE);
|
||||||
filter.addAction(Intents.ACTION_NEW_MBG);
|
filter.addAction(Intents.ACTION_NEW_MBG);
|
||||||
filter.addAction(Intents.ACTION_NEW_CAL);
|
filter.addAction(Intents.ACTION_NEW_CAL);
|
||||||
|
|
|
@ -136,8 +136,12 @@ class DexcomPlugin @Inject constructor(
|
||||||
dexcomPlugin.disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)).subscribe({ savedValues ->
|
dexcomPlugin.disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)).subscribe({ savedValues ->
|
||||||
savedValues.forEach {
|
savedValues.forEach {
|
||||||
broadcastToXDrip(it)
|
broadcastToXDrip(it)
|
||||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false))
|
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||||
nsUpload.uploadBg(BgReading(injector, it), sourceSensor.text)
|
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)
|
aapsLogger.error(LTag.BGSOURCE, "Error while saving values from Dexcom App", it)
|
||||||
|
|
|
@ -107,6 +107,7 @@ class NSClientSourcePlugin @Inject constructor(
|
||||||
noise = null,
|
noise = null,
|
||||||
raw = if (sgv.filtered != null) sgv.filtered.toDouble() else sgv.mgdl.toDouble(),
|
raw = if (sgv.filtered != null) sgv.filtered.toDouble() else sgv.mgdl.toDouble(),
|
||||||
trendArrow = GlucoseValue.TrendArrow.fromString(sgv.direction),
|
trendArrow = GlucoseValue.TrendArrow.fromString(sgv.direction),
|
||||||
|
nightscoutId = sgv.id,
|
||||||
sourceSensor = GlucoseValue.SourceSensor.fromString(sgv.device)
|
sourceSensor = GlucoseValue.SourceSensor.fromString(sgv.device)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,6 +417,24 @@ public class NSUpload {
|
||||||
uploadQueue.add(new DbRequest("dbAdd", "entries", data));
|
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() {
|
public void uploadAppStart() {
|
||||||
if (sp.getBoolean(R.string.key_ns_logappstartedevent, true)) {
|
if (sp.getBoolean(R.string.key_ns_logappstartedevent, true)) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
|
|
|
@ -34,13 +34,14 @@ data class GlucoseValue(
|
||||||
|
|
||||||
fun contentEqualsTo(other: GlucoseValue): Boolean =
|
fun contentEqualsTo(other: GlucoseValue): Boolean =
|
||||||
timestamp == other.timestamp &&
|
timestamp == other.timestamp &&
|
||||||
utcOffset == other.utcOffset &&
|
utcOffset == other.utcOffset &&
|
||||||
raw == other.raw &&
|
raw == other.raw &&
|
||||||
value == other.value &&
|
value == other.value &&
|
||||||
trendArrow == other.trendArrow &&
|
trendArrow == other.trendArrow &&
|
||||||
noise == other.noise &&
|
noise == other.noise &&
|
||||||
sourceSensor == other.sourceSensor &&
|
sourceSensor == other.sourceSensor &&
|
||||||
isValid == other.isValid
|
isValid == other.isValid &&
|
||||||
|
interfaceIDs?.nightscoutId == other.interfaceIDs?.nightscoutId
|
||||||
|
|
||||||
fun isRecordDeleted(other: GlucoseValue): Boolean =
|
fun isRecordDeleted(other: GlucoseValue): Boolean =
|
||||||
isValid && !other.isValid
|
isValid && !other.isValid
|
||||||
|
@ -94,7 +95,8 @@ data class GlucoseValue(
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
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