KeepAliveReceiver: raise notification when pump couldn't be reached for 25m.

This commit is contained in:
Johannes Mockenhaupt 2017-10-25 18:30:06 +02:00
parent d907a1b6b3
commit e620878d17
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -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() {