diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index b848ea1c77..cff60806d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -67,6 +67,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf private volatile boolean bolusInProgress; private volatile boolean cancelBolus; + private Bolus lastRequestedBolus; public static ComboPlugin getPlugin() { if (plugin == null) @@ -368,6 +369,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf @NonNull private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) { + if (lastRequestedBolus != null + && Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.05 + && lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { + return new PumpEnactResult().success(false).enacted(false) + .comment(MainApp.sResources.getString(R.string.bolus_frequency_exceeded)); + } + lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true); + try { pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing); MainApp.bus().post(new EventComboPumpUpdateGUI()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 87fe4ec7c0..7d1b4a8154 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -799,5 +799,6 @@ Requested operation not supported by pump Bolus delivery failed. A (partial) bolus might have been delivered. Attempting to update history from pump. Please check the Combo page and bolus again as needed. Unsafe usage: extended or multiwave boluses have been delivered within the last 6h. Closed loop mode forcefully disabled. Only normal boluses are supported when running in closed loop mode. + A bolus with the same amount was requested within the last minute. For safety reasons this is disallowed.