From e620878d17f308549b637db4c11ad07d601bf6fd Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 25 Oct 2017 18:30:06 +0200 Subject: [PATCH] KeepAliveReceiver: raise notification when pump couldn't be reached for 25m. --- .../androidaps/receivers/KeepAliveReceiver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java index 9dcf0645cc..81211df12f 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java @@ -22,6 +22,8 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class KeepAliveReceiver extends BroadcastReceiver { private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class); @@ -46,7 +48,11 @@ public class KeepAliveReceiver extends BroadcastReceiver { isBasalOutdated = true; SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) { + if (isStatusOutdated && lastConnection.getTime() + 25 * 60 * 1000 < System.currentTimeMillis()) { + MainApp.bus().post(new EventNewNotification( + new Notification(Notification.PUMP_UNREACHABLE, + "Pump connection could not be established for more than 25 minutes", Notification.URGENT))); + } else if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) { Thread t = new Thread(new Runnable() { @Override public void run() {