G5: accept arrays
This commit is contained in:
parent
7fc9efde40
commit
b73e12b731
2 changed files with 12 additions and 7 deletions
|
@ -216,12 +216,16 @@ public class DataService extends IntentService {
|
||||||
log.debug("Received Dexcom Data", data);
|
log.debug("Received Dexcom Data", data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(data);
|
JSONArray jsonArray = new JSONArray(data);
|
||||||
bgReading.value = json.getInt("m_trend");
|
log.debug("Received Dexcom Data size:" + jsonArray.length());
|
||||||
|
for(int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject json = jsonArray.getJSONObject(i);
|
||||||
|
bgReading.value = json.getInt("m_value");
|
||||||
bgReading.direction = json.getString("m_trend");
|
bgReading.direction = json.getString("m_trend");
|
||||||
bgReading.date = json.getLong("m_time");
|
bgReading.date = json.getLong("m_time");
|
||||||
bgReading.raw = 0;
|
bgReading.raw = 0;
|
||||||
MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
|
MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
|
||||||
|
}
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
if (SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||||
NSUpload.uploadBg(bgReading);
|
NSUpload.uploadBg(bgReading);
|
||||||
|
|
|
@ -354,9 +354,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!old.isEqual(bgReading)) {
|
if (!old.isEqual(bgReading)) {
|
||||||
|
log.debug("BG: Similiar found: " + old.toString());
|
||||||
old.copyFrom(bgReading);
|
old.copyFrom(bgReading);
|
||||||
getDaoBgReadings().update(old);
|
getDaoBgReadings().update(old);
|
||||||
log.debug("BG: Updating record from: " + from + " " + old.toString());
|
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
|
||||||
scheduleBgChange();
|
scheduleBgChange();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue