From 078eec82ebc5c343a57d48f245de1f491a431627 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Fri, 18 Dec 2020 01:43:29 +0100 Subject: [PATCH] Acknowledge getPumpStatus request in Omnipod plugin when explicitly requested with SMS --- .../plugins/pump/combo/ComboPlugin.java | 2 +- .../plugins/pump/insight/LocalInsightPlugin.java | 2 +- .../androidaps/plugins/pump/mdi/MDIPlugin.java | 2 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 2 +- .../queue/commands/CommandReadStatus.kt | 4 ++-- .../androidaps/interfaces/PumpInterface.java | 2 +- .../androidaps/danar/AbstractDanaRPlugin.java | 2 +- .../nightscout/androidaps/danars/DanaRSPlugin.kt | 2 +- .../pump/medtronic/MedtronicPumpPlugin.java | 2 +- .../plugins/pump/omnipod/OmnipodPumpPlugin.java | 16 +++++++++++----- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 8b9c39fce9..94761a04c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -338,7 +338,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr * Runs pump initialization if needed and reads the pump state from the main screen. */ @Override - public synchronized void getPumpStatus() { + public synchronized void getPumpStatus(String reason) { getAapsLogger().debug(LTag.PUMP, "getPumpStatus called"); if (!pump.initialized) { initializePump(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index dc58e98d8c..c3e6427931 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -370,7 +370,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { try { tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class); readHistory(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java index 9810aecc38..cf5ee0822c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java @@ -132,7 +132,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface { } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { } @NonNull @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 1d6ab21c4e..480a47b454 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -178,7 +178,7 @@ class VirtualPumpPlugin @Inject constructor( override fun disconnect(reason: String) {} override fun stopConnecting() {} - override fun getPumpStatus() { + override fun getPumpStatus(reason: String?) { lastDataTime = System.currentTimeMillis() } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt index 6c2e4ca83f..052ad8a515 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt @@ -11,7 +11,7 @@ import javax.inject.Inject class CommandReadStatus( injector: HasAndroidInjector, - private val reason: String, + val reason: String, callback: Callback? ) : Command(injector, CommandType.READSTATUS, callback) { @@ -19,7 +19,7 @@ class CommandReadStatus( @Inject lateinit var localAlertUtils: LocalAlertUtils override fun execute() { - activePlugin.activePump.getPumpStatus() + activePlugin.activePump.getPumpStatus(reason) localAlertUtils.notifyPumpStatusRead() aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason") val pump = activePlugin.activePump diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index 6d895506f7..3ea1479666 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -43,7 +43,7 @@ public interface PumpInterface { void stopConnecting(); - void getPumpStatus(); + void getPumpStatus(String reason); // Upload to pump new basal profile @NotNull diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java index 3b9e98cbe8..30b2351602 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java @@ -361,7 +361,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (sExecutionService != null) { sExecutionService.getPumpStatus(); pumpDescription.basalStep = danaPump.getBasalStep(); diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt index 7d4cf7c21c..ea07f45cd3 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt @@ -165,7 +165,7 @@ class DanaRSPlugin @Inject constructor( danaRSService?.stopConnecting() } - override fun getPumpStatus() { + override fun getPumpStatus(reason: String?) { danaRSService?.readPumpStatus() pumpDesc.basalStep = danaPump.basalStep pumpDesc.bolusStep = danaPump.bolusStep diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index d491ebd1bc..21527df01e 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -421,7 +421,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (firstRun) { initializePump(!isRefresh); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index c19a314755..0ab75333b1 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -537,18 +537,24 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, /** * We don't do periodical status requests because that could drain the Pod's battery - * The only actual status requests we send to the Pod here are on startup (in {@link #initializeAfterRileyLinkConnection() initializeAfterRileyLinkConnection()}) + * The only actual status requests we send to the Pod here are on startup (in {@link #initializeAfterRileyLinkConnection() initializeAfterRileyLinkConnection()}), + * When explicitly requested through SMS commands * And when the basal and/or temp basal status is uncertain * When the user explicitly requested it by clicking the Refresh button on the Omnipod tab (which is executed through {@link #executeCustomCommand(CustomCommand)}) */ @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (firstRun) { initializeAfterRileyLinkConnection(); firstRun = false; - } else if (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain()) { - aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain"); - getPodStatus(); + } else { + if ("SMS".equals(reason)) { + aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request it was requested through an SMS"); + getPodStatus(); + } else if (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain()) { + aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain"); + getPodStatus(); + } } }