diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java index cf35e954b3..4d9d66663c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsightLocal/LocalInsightPlugin.java @@ -538,6 +538,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con detailedBolusInfo.pumpId = insightBolusID.id; TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true); while (true) { + synchronized ($bolusLock) { + if (bolusID == -1) break; + } OperatingMode operatingMode = connectionService.requestMessage(new GetOperatingModeMessage()).await().getOperatingMode(); if (operatingMode != OperatingMode.STARTED) break; List activeBoluses = connectionService.requestMessage(new GetActiveBolusesMessage()).await().getActiveBoluses(); @@ -592,6 +595,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con CancelBolusMessage cancelBolusMessage = new CancelBolusMessage(); cancelBolusMessage.setBolusID(bolusID); connectionService.requestMessage(cancelBolusMessage).await(); + bolusID = -1; confirmAlert(AlertType.WARNING_38); } catch (AppLayerErrorException e) { log.info("Exception while canceling bolus: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");