From 59a1e007ad0f95ece649f1fdf1a23b6a0adffc30 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 18 Feb 2018 00:55:37 +0100 Subject: [PATCH] block if no profile switch is set --- .../nightscout/androidaps/queue/CommandQueue.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index d7d8457a27..a523655ff8 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -287,6 +287,17 @@ public class CommandQueue { return false; } + // Check that there is a valid profileSwitch NOW + if (MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis())==null) { + Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.sResources.getString(R.string.profileswitch_missing), Notification.NORMAL); + MainApp.bus().post(new EventNewNotification(noProfileSwitchNotif)); + if (callback != null) { + PumpEnactResult result = new PumpEnactResult().success(false).enacted(false).comment("Refuse to send profile to pump! No ProfileSwitch!"); + callback.result(result).run(); + } + return false; + } + // Compare with pump limits Profile.BasalValue[] basalValues = profile.getBasalValues(); PumpInterface pump = ConfigBuilderPlugin.getActivePump();