Use uploadError for pump alarms

This commit is contained in:
TebbeUbben 2018-04-08 18:46:29 +02:00
parent 56b2799785
commit b488e30459
3 changed files with 7 additions and 14 deletions

View file

@ -160,18 +160,7 @@ class HistoryIntentAdapter {
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
try {
JSONObject data = new JSONObject();
String enteredBy = SP.getString("careportal_enteredby", "");
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
data.put("created_at", DateUtil.toISOString(date));
data.put("eventType", CareportalEvent.NOTE);
data.put("notes", MainApp.instance().getString(getAlertText(alertType)));
NSUpload.uploadCareportalEntryToNS(data);
} catch (JSONException e) {
e.printStackTrace();
}
NSUpload.uploadError(MainApp.instance().getString(getAlertText(alertType)), date);
}
}

View file

@ -406,6 +406,10 @@ public class NSUpload {
}
public static void uploadError(String error) {
uploadError(error, new Date());
}
public static void uploadError(String error, Date date) {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
@ -413,7 +417,7 @@ public class NSUpload {
JSONObject data = new JSONObject();
try {
data.put("eventType", "Announcement");
data.put("created_at", DateUtil.toISOString(new Date()));
data.put("created_at", DateUtil.toISOString(date));
data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name)));
data.put("notes", error);
data.put("isAnnouncement", true);

View file

@ -990,5 +990,5 @@
<string name="waitingfortimesynchronization">Waiting for time synchronization (%d sec)</string>
<string name="loopdisconnectedfor">Disconnected (%d m)</string>
<string name="automatic_careportal_events">Automatic careportal events</string>
<string name="automatically_upload_insulin_cannula_and_battery_changes_to_nightscout">Automatically upload insulin, cannula and battery changes to Nightscout</string>
<string name="automatically_upload_insulin_cannula_and_battery_changes_to_nightscout">Automatically upload insulin, cannula and battery changes and pump alarms to Nightscout</string>
</resources>