Acknowledge getPumpStatus request in Omnipod plugin when explicitly requested with SMS

This commit is contained in:
Bart Sopers 2020-12-18 01:43:29 +01:00
parent ae175f3b99
commit 078eec82eb
10 changed files with 21 additions and 15 deletions

View file

@ -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. * Runs pump initialization if needed and reads the pump state from the main screen.
*/ */
@Override @Override
public synchronized void getPumpStatus() { public synchronized void getPumpStatus(String reason) {
getAapsLogger().debug(LTag.PUMP, "getPumpStatus called"); getAapsLogger().debug(LTag.PUMP, "getPumpStatus called");
if (!pump.initialized) { if (!pump.initialized) {
initializePump(); initializePump();

View file

@ -370,7 +370,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
} }
@Override @Override
public void getPumpStatus() { public void getPumpStatus(String reason) {
try { try {
tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class); tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class);
readHistory(); readHistory();

View file

@ -132,7 +132,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface {
} }
@Override @Override
public void getPumpStatus() { public void getPumpStatus(String reason) {
} }
@NonNull @Override @NonNull @Override

View file

@ -178,7 +178,7 @@ class VirtualPumpPlugin @Inject constructor(
override fun disconnect(reason: String) {} override fun disconnect(reason: String) {}
override fun stopConnecting() {} override fun stopConnecting() {}
override fun getPumpStatus() { override fun getPumpStatus(reason: String?) {
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
} }

View file

@ -11,7 +11,7 @@ import javax.inject.Inject
class CommandReadStatus( class CommandReadStatus(
injector: HasAndroidInjector, injector: HasAndroidInjector,
private val reason: String, val reason: String,
callback: Callback? callback: Callback?
) : Command(injector, CommandType.READSTATUS, callback) { ) : Command(injector, CommandType.READSTATUS, callback) {
@ -19,7 +19,7 @@ class CommandReadStatus(
@Inject lateinit var localAlertUtils: LocalAlertUtils @Inject lateinit var localAlertUtils: LocalAlertUtils
override fun execute() { override fun execute() {
activePlugin.activePump.getPumpStatus() activePlugin.activePump.getPumpStatus(reason)
localAlertUtils.notifyPumpStatusRead() localAlertUtils.notifyPumpStatusRead()
aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason") aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason")
val pump = activePlugin.activePump val pump = activePlugin.activePump

View file

@ -43,7 +43,7 @@ public interface PumpInterface {
void stopConnecting(); void stopConnecting();
void getPumpStatus(); void getPumpStatus(String reason);
// Upload to pump new basal profile // Upload to pump new basal profile
@NotNull @NotNull

View file

@ -361,7 +361,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
} }
@Override @Override
public void getPumpStatus() { public void getPumpStatus(String reason) {
if (sExecutionService != null) { if (sExecutionService != null) {
sExecutionService.getPumpStatus(); sExecutionService.getPumpStatus();
pumpDescription.basalStep = danaPump.getBasalStep(); pumpDescription.basalStep = danaPump.getBasalStep();

View file

@ -165,7 +165,7 @@ class DanaRSPlugin @Inject constructor(
danaRSService?.stopConnecting() danaRSService?.stopConnecting()
} }
override fun getPumpStatus() { override fun getPumpStatus(reason: String?) {
danaRSService?.readPumpStatus() danaRSService?.readPumpStatus()
pumpDesc.basalStep = danaPump.basalStep pumpDesc.basalStep = danaPump.basalStep
pumpDesc.bolusStep = danaPump.bolusStep pumpDesc.bolusStep = danaPump.bolusStep

View file

@ -421,7 +421,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override @Override
public void getPumpStatus() { public void getPumpStatus(String reason) {
if (firstRun) { if (firstRun) {
initializePump(!isRefresh); initializePump(!isRefresh);

View file

@ -537,20 +537,26 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
/** /**
* We don't do periodical status requests because that could drain the Pod's battery * 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 * 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)}) * When the user explicitly requested it by clicking the Refresh button on the Omnipod tab (which is executed through {@link #executeCustomCommand(CustomCommand)})
*/ */
@Override @Override
public void getPumpStatus() { public void getPumpStatus(String reason) {
if (firstRun) { if (firstRun) {
initializeAfterRileyLinkConnection(); initializeAfterRileyLinkConnection();
firstRun = false; firstRun = false;
} 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()) { } else if (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain()) {
aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain"); aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain");
getPodStatus(); getPodStatus();
} }
} }
}
private PumpEnactResult getPodStatus() { private PumpEnactResult getPodStatus() {
return executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus); return executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);