From 0f8442d65c38fbd53ca6f7c529768ccf87761fbd Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 25 Nov 2017 21:15:47 +0100 Subject: [PATCH] Issue a history read when bolusing fails. (cherry picked from commit cafed14) --- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 894f7cce20..64783cae37 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 @@ -432,7 +432,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf .comment(MainApp.instance().getString(R.string.danar_invalidinput)); } else if (detailedBolusInfo.insulin > 0) { // bolus needed, ask pump to deliver it - return deliverBolus(detailedBolusInfo); + PumpEnactResult pumpEnactResult = deliverBolus(detailedBolusInfo); + if (!pumpEnactResult.success) { + log.debug("Bolus delivery failed, refreshing history in background thread"); + new Thread(this::checkPumpHistory).start(); + } + return pumpEnactResult; } else { // no bolus required, carb only treatment MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); @@ -482,7 +487,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf // verify we're update to date and know the most recent bolus if (!Objects.equals(lastKnownBolus, reservoirBolusResult.lastBolus)) { - new Thread(this::checkPumpHistory).start(); + log.error("Bolus delivery failure at stage 3", new Exception()); return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.sResources.getString(R.string.combo_pump_bolus_history_state_mismatch)); }