Merge pull request #192 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge
Omnipod fixes
This commit is contained in:
commit
706783edab
12 changed files with 103 additions and 70 deletions
|
@ -49,14 +49,14 @@ class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {
|
||||||
|
|
||||||
Intent.ACTION_TIMEZONE_CHANGED == action -> {
|
Intent.ACTION_TIMEZONE_CHANGED == action -> {
|
||||||
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
|
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
|
||||||
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
|
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent.ACTION_TIME_CHANGED == action -> {
|
Intent.ACTION_TIME_CHANGED == action -> {
|
||||||
val currentDst = calculateDST()
|
val currentDst = calculateDST()
|
||||||
if (currentDst == isDST) {
|
if (currentDst == isDST) {
|
||||||
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
|
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
|
||||||
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
|
activePump.timezoneOrDSTChanged(TimeChangeType.TimeChanged)
|
||||||
} else {
|
} else {
|
||||||
if (currentDst) {
|
if (currentDst) {
|
||||||
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
|
aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class Notification {
|
||||||
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
|
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
|
||||||
public static final int OMNIPOD_UNKNOWN_TBR = 68;
|
public static final int OMNIPOD_UNKNOWN_TBR = 68;
|
||||||
public static final int OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69;
|
public static final int OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69;
|
||||||
|
public static final int OMNIPOD_TIME_OUT_OF_SYNC = 70;
|
||||||
|
|
||||||
public static final int IMPORTANCE_HIGH = 2;
|
public static final int IMPORTANCE_HIGH = 2;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.utils;
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
public enum TimeChangeType {
|
public enum TimeChangeType {
|
||||||
TimezoneChange,
|
TimezoneChanged,
|
||||||
DST_Started,
|
DST_Started,
|
||||||
DST_Ended,
|
DST_Ended,
|
||||||
ManualTimeChange
|
TimeChanged
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ import static info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, RileyLinkPumpDevice {
|
public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, RileyLinkPumpDevice {
|
||||||
private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1000L; // 3 minutes
|
private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1_000L; // 3 minutes
|
||||||
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute
|
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1_000L; // 1 minute
|
||||||
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
|
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
|
||||||
public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0;
|
public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0;
|
||||||
|
|
||||||
|
@ -150,12 +150,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
||||||
private boolean busy = false;
|
private boolean busy = false;
|
||||||
private int timeChangeRetries;
|
private int timeChangeRetries;
|
||||||
private long nextPodCheck;
|
private long nextPodWarningCheck;
|
||||||
private long lastConnectionTimeMillis;
|
private long lastConnectionTimeMillis;
|
||||||
private final Handler loopHandler = new Handler(Looper.getMainLooper());
|
private final Handler loopHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
private final Runnable statusChecker;
|
private final Runnable statusChecker;
|
||||||
private boolean isCancelTempBasalRunning;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OmnipodPumpPlugin(
|
public OmnipodPumpPlugin(
|
||||||
|
@ -238,6 +237,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
statusChecker = new Runnable() {
|
statusChecker = new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
|
if (commandQueue.size() == 0) {
|
||||||
if (podStateManager.isPodRunning() && !podStateManager.isSuspended()) {
|
if (podStateManager.isPodRunning() && !podStateManager.isSuspended()) {
|
||||||
aapsOmnipodManager.cancelSuspendedFakeTbrIfExists();
|
aapsOmnipodManager.cancelSuspendedFakeTbrIfExists();
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,8 +255,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
|
||||||
queueAcknowledgeAlertsCommand();
|
queueAcknowledgeAlertsCommand();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
aapsLogger.debug(LTag.PUMP, "Skipping Pod status check because command queue is not empty");
|
||||||
|
}
|
||||||
|
|
||||||
doPodCheck();
|
updatePodWarningNotifications();
|
||||||
|
|
||||||
loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS);
|
loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS);
|
||||||
}
|
}
|
||||||
|
@ -360,10 +363,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCancelledTbr() {
|
private void handleCancelledTbr() {
|
||||||
// Only report TBR cancellations if they haven't been explicitly requested
|
|
||||||
if (isCancelTempBasalRunning) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!podStateManager.isTempBasalRunning() && activePlugin.getActiveTreatments().isTempBasalInProgress() && !aapsOmnipodManager.hasSuspendedFakeTbr()) {
|
if (!podStateManager.isTempBasalRunning() && activePlugin.getActiveTreatments().isTempBasalInProgress() && !aapsOmnipodManager.hasSuspendedFakeTbr()) {
|
||||||
aapsOmnipodManager.reportCancelledTbr();
|
aapsOmnipodManager.reportCancelledTbr();
|
||||||
}
|
}
|
||||||
|
@ -445,19 +444,30 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doPodCheck() {
|
private void updatePodWarningNotifications() {
|
||||||
if (System.currentTimeMillis() > this.nextPodCheck) {
|
if (System.currentTimeMillis() > this.nextPodWarningCheck) {
|
||||||
if (!podStateManager.isPodRunning()) {
|
if (!podStateManager.isPodRunning()) {
|
||||||
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
|
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
} else {
|
} else {
|
||||||
|
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED));
|
||||||
|
|
||||||
if (podStateManager.isSuspended()) {
|
if (podStateManager.isSuspended()) {
|
||||||
Notification notification = new Notification(Notification.OMNIPOD_POD_SUSPENDED, resourceHelper.gs(R.string.omnipod_error_pod_suspended), Notification.NORMAL);
|
Notification notification = new Notification(Notification.OMNIPOD_POD_SUSPENDED, resourceHelper.gs(R.string.omnipod_error_pod_suspended), Notification.NORMAL);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
rxBus.send(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED));
|
||||||
|
|
||||||
|
if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
||||||
|
Notification notification = new Notification(Notification.OMNIPOD_TIME_OUT_OF_SYNC, resourceHelper.gs(R.string.omnipod_error_time_out_of_sync), Notification.NORMAL);
|
||||||
|
rxBus.send(new EventNewNotification(notification));
|
||||||
|
} else {
|
||||||
|
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nextPodCheck = DateTimeUtil.getTimeInFutureFromMinutes(15);
|
this.nextPodWarningCheck = DateTimeUtil.getTimeInFutureFromMinutes(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,12 +705,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
isCancelTempBasalRunning = true;
|
|
||||||
try {
|
|
||||||
return executeCommand(OmnipodCommandType.CANCEL_TEMPORARY_BASAL, aapsOmnipodManager::cancelTemporaryBasal);
|
return executeCommand(OmnipodCommandType.CANCEL_TEMPORARY_BASAL, aapsOmnipodManager::cancelTemporaryBasal);
|
||||||
} finally {
|
|
||||||
isCancelTempBasalRunning = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO improve (i8n and more)
|
// TODO improve (i8n and more)
|
||||||
|
@ -957,12 +962,18 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
aapsLogger.warn(LTag.PUMP, "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + aapsOmnipodManager.isTimeChangeEventEnabled() + "]");
|
aapsLogger.info(LTag.PUMP, "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + aapsOmnipodManager.isTimeChangeEventEnabled() + "]");
|
||||||
|
|
||||||
if (podStateManager.isPodRunning()) {
|
if (timeChangeType == TimeChangeType.TimeChanged) {
|
||||||
aapsLogger.info(LTag.PUMP, "Time, Date and/or TimeZone changed event received and will be consumed by driver.");
|
aapsLogger.info(LTag.PUMP, "Ignoring time change because it is not a DST or TZ change");
|
||||||
hasTimeDateOrTimeZoneChanged = true;
|
return;
|
||||||
|
} else if (!podStateManager.isPodRunning()) {
|
||||||
|
aapsLogger.info(LTag.PUMP, "Ignoring time change because no Pod is active");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aapsLogger.info(LTag.PUMP, "DST and/or TimeZone changed event will be consumed by driver");
|
||||||
|
hasTimeDateOrTimeZoneChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action;
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action;
|
||||||
|
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.BeepConfigCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.CancelDeliveryCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.CancelDeliveryCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
||||||
|
@ -35,23 +39,14 @@ public class CancelDeliveryAction implements OmnipodAction<StatusResponse> {
|
||||||
public StatusResponse execute(OmnipodRileyLinkCommunicationManager communicationService) {
|
public StatusResponse execute(OmnipodRileyLinkCommunicationManager communicationService) {
|
||||||
List<MessageBlock> messageBlocks = new ArrayList<>();
|
List<MessageBlock> messageBlocks = new ArrayList<>();
|
||||||
|
|
||||||
if (acknowledgementBeep && deliveryTypes.size() > 1) {
|
messageBlocks.add(new CancelDeliveryCommand(podStateManager.getCurrentNonce(), BeepType.NO_BEEP, deliveryTypes));
|
||||||
// Workaround for strange beep behaviour when cancelling multiple delivery types
|
|
||||||
List<DeliveryType> deliveryTypeList = new ArrayList<>(deliveryTypes);
|
|
||||||
|
|
||||||
EnumSet<DeliveryType> deliveryTypeWithBeep = EnumSet.of(deliveryTypeList.remove(deliveryTypeList.size() - 1));
|
// Workaround for strange behavior where the Pod beeps for each specified delivery type
|
||||||
EnumSet<DeliveryType> deliveryTypesWithoutBeep = EnumSet.copyOf(deliveryTypeList);
|
if (acknowledgementBeep) {
|
||||||
|
messageBlocks.add(new BeepConfigCommand(BeepConfigType.BEEP, false, Duration.ZERO, false, Duration.ZERO, false, Duration.ZERO));
|
||||||
messageBlocks.add(new CancelDeliveryCommand(podStateManager.getCurrentNonce(), BeepType.NO_BEEP, deliveryTypesWithoutBeep));
|
|
||||||
messageBlocks.add(new CancelDeliveryCommand(podStateManager.getCurrentNonce(), BeepType.BEEP, deliveryTypeWithBeep));
|
|
||||||
} else {
|
|
||||||
messageBlocks.add(new CancelDeliveryCommand(podStateManager.getCurrentNonce(),
|
|
||||||
acknowledgementBeep && deliveryTypes.size() == 1 ? BeepType.BEEP : BeepType.NO_BEEP, deliveryTypes));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusResponse statusResponse = communicationService.exchangeMessages(StatusResponse.class, podStateManager,
|
return communicationService.exchangeMessages(StatusResponse.class, podStateManager,
|
||||||
new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber()));
|
new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber()));
|
||||||
|
|
||||||
return statusResponse;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message;
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
@ -31,7 +32,7 @@ public class OmnipodMessage {
|
||||||
|
|
||||||
public OmnipodMessage(int address, List<MessageBlock> messageBlocks, int sequenceNumber) {
|
public OmnipodMessage(int address, List<MessageBlock> messageBlocks, int sequenceNumber) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.messageBlocks = messageBlocks;
|
this.messageBlocks = new ArrayList<>(messageBlocks);
|
||||||
this.sequenceNumber = sequenceNumber;
|
this.sequenceNumber = sequenceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ public class OmnipodMessage {
|
||||||
throw new CrcMismatchException(calculatedCrc, crc);
|
throw new CrcMismatchException(calculatedCrc, crc);
|
||||||
}
|
}
|
||||||
List<MessageBlock> blocks = decodeBlocks(ByteUtil.substring(data, 6, data.length - 6 - 2));
|
List<MessageBlock> blocks = decodeBlocks(ByteUtil.substring(data, 6, data.length - 6 - 2));
|
||||||
if (blocks == null || blocks.size() == 0) {
|
if (blocks.size() == 0) {
|
||||||
throw new MessageDecodingException("No blocks decoded");
|
throw new MessageDecodingException("No blocks decoded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ public class OmnipodMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageBlock> getMessageBlocks() {
|
public List<MessageBlock> getMessageBlocks() {
|
||||||
return messageBlocks;
|
return new ArrayList<>(messageBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSequenceNumber() {
|
public int getSequenceNumber() {
|
||||||
|
@ -147,12 +148,16 @@ public class OmnipodMessage {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSetTempBasalMessage() {
|
public boolean isGetStatusMessage() {
|
||||||
return messageBlocks.size() >= 2 && messageBlocks.get(0).getType() == MessageBlockType.SET_INSULIN_SCHEDULE && messageBlocks.get(1).getType() == MessageBlockType.TEMP_BASAL_EXTRA;
|
return messageBlocks.size() == 1 && messageBlocks.get(0).getType() == MessageBlockType.GET_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancelTempBasalMessage() {
|
public boolean isSuspendDeliveryMessage() {
|
||||||
return messageBlocks.size() >= 1 && messageBlocks.get(0).getType() == MessageBlockType.CANCEL_DELIVERY && ((CancelDeliveryCommand) messageBlocks.get(0)).getDeliveryTypes().contains(DeliveryType.TEMP_BASAL);
|
return isCancelDeliveryMessage() && EnumSet.allOf(DeliveryType.class).equals(((CancelDeliveryCommand) messageBlocks.get(0)).getDeliveryTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isCancelDeliveryMessage() {
|
||||||
|
return messageBlocks.size() >= 1 && messageBlocks.get(0).getType() == MessageBlockType.CANCEL_DELIVERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,4 +30,7 @@ public class OmnipodConstants {
|
||||||
public static final double POD_SETUP_UNITS = POD_PRIME_BOLUS_UNITS + POD_CANNULA_INSERTION_BOLUS_UNITS;
|
public static final double POD_SETUP_UNITS = POD_PRIME_BOLUS_UNITS + POD_CANNULA_INSERTION_BOLUS_UNITS;
|
||||||
|
|
||||||
public static final int DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD = 20;
|
public static final int DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD = 20;
|
||||||
|
|
||||||
|
// when the time deviates more than the threshold, the user will get warned and will get the option to change the time
|
||||||
|
public static final Duration TIME_DEVIATION_THRESHOLD = Duration.standardMinutes(5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,15 @@ public class OmnipodManager {
|
||||||
private synchronized StatusResponse cancelDelivery(EnumSet<DeliveryType> deliveryTypes, boolean acknowledgementBeep) {
|
private synchronized StatusResponse cancelDelivery(EnumSet<DeliveryType> deliveryTypes, boolean acknowledgementBeep) {
|
||||||
assertReadyForDelivery();
|
assertReadyForDelivery();
|
||||||
|
|
||||||
|
if (!podStateManager.isTempBasalCertain() || !podStateManager.isBasalCertain()) {
|
||||||
|
try {
|
||||||
|
getPodStatus();
|
||||||
|
} catch (OmnipodException ex) {
|
||||||
|
ex.setCertainFailure(true);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (deliveryTypes.contains(DeliveryType.BASAL)) {
|
if (deliveryTypes.contains(DeliveryType.BASAL)) {
|
||||||
podStateManager.setBasalCertain(false);
|
podStateManager.setBasalCertain(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,10 +568,10 @@ public abstract class PodStateManager {
|
||||||
podState.setPodProgressStatus(status.getPodProgressStatus());
|
podState.setPodProgressStatus(status.getPodProgressStatus());
|
||||||
podState.setTimeActive(status.getTimeActive());
|
podState.setTimeActive(status.getTimeActive());
|
||||||
|
|
||||||
boolean isBasalCertain = podState.isBasalCertain() == null || podState.isBasalCertain();
|
boolean wasBasalCertain = podState.isBasalCertain() == null || podState.isBasalCertain();
|
||||||
boolean isTempBasalCertain = podState.isTempBasalCertain() == null || podState.isTempBasalCertain();
|
boolean wasTempBasalCertain = podState.isTempBasalCertain() == null || podState.isTempBasalCertain();
|
||||||
if (!status.getDeliveryStatus().isTbrRunning() && hasTempBasal()) {
|
if (!status.getDeliveryStatus().isTbrRunning() && hasTempBasal()) {
|
||||||
if (isTempBasalCertain) {
|
if (wasTempBasalCertain || requestMessage.isSuspendDeliveryMessage()) {
|
||||||
clearTempBasal(); // Triggers onTbrChanged when appropriate
|
clearTempBasal(); // Triggers onTbrChanged when appropriate
|
||||||
} else {
|
} else {
|
||||||
// Don't trigger onTbrChanged as we will trigger onUncertainTbrRecovered below
|
// Don't trigger onTbrChanged as we will trigger onUncertainTbrRecovered below
|
||||||
|
@ -580,14 +580,17 @@ public abstract class PodStateManager {
|
||||||
podState.setTempBasalDuration(null);
|
podState.setTempBasalDuration(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isTempBasalCertain) {
|
|
||||||
|
if (!wasTempBasalCertain) {
|
||||||
podState.setTempBasalCertain(true);
|
podState.setTempBasalCertain(true);
|
||||||
if (!requestMessage.isSetTempBasalMessage() // We always set TBR to uncertain before sending the set temp basal command, so this is not an actual recovery
|
|
||||||
&& !requestMessage.isCancelTempBasalMessage()) { // Delivery status changed, so we can't recover here
|
// We exclusively use get status messages to recover from uncertain TBRs
|
||||||
|
// DO NOT change this as the recovery mechanism will otherwise interfere with normal delivery commands
|
||||||
|
if (requestMessage.isGetStatusMessage()) {
|
||||||
onUncertainTbrRecovered();
|
onUncertainTbrRecovered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isBasalCertain) {
|
if (!wasBasalCertain) {
|
||||||
podState.setBasalCertain(true);
|
podState.setBasalCertain(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,7 @@ public class AapsOmnipodManager {
|
||||||
|
|
||||||
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||||
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
||||||
|
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||||
|
|
||||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||||
}
|
}
|
||||||
|
@ -584,6 +585,9 @@ public class AapsOmnipodManager {
|
||||||
addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null);
|
addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null);
|
||||||
createSuspendedFakeTbrIfNotExists();
|
createSuspendedFakeTbrIfNotExists();
|
||||||
|
|
||||||
|
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||||
|
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||||
|
|
||||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +623,7 @@ public class AapsOmnipodManager {
|
||||||
|
|
||||||
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||||
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
||||||
|
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||||
|
|
||||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
omnipod_overview_firmware_version.text = resourceHelper.gs(R.string.omnipod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
omnipod_overview_firmware_version.text = resourceHelper.gs(R.string.omnipod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
||||||
|
|
||||||
omnipod_overview_time_on_pod.text = readableZonedTime(podStateManager.time)
|
omnipod_overview_time_on_pod.text = readableZonedTime(podStateManager.time)
|
||||||
omnipod_overview_time_on_pod.setTextColor(if (podStateManager.timeDeviatesMoreThan(Duration.standardMinutes(5))) {
|
omnipod_overview_time_on_pod.setTextColor(if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
||||||
Color.RED
|
Color.RED
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
<string name="omnipod_error_rileylink_address_invalid">RileyLink address invalid.</string>
|
<string name="omnipod_error_rileylink_address_invalid">RileyLink address invalid.</string>
|
||||||
<string name="omnipod_error_operation_not_possible_no_configuration">Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation.</string>
|
<string name="omnipod_error_operation_not_possible_no_configuration">Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation.</string>
|
||||||
<string name="omnipod_error_pod_not_attached">No active Pod</string>
|
<string name="omnipod_error_pod_not_attached">No active Pod</string>
|
||||||
|
<string name="omnipod_error_time_out_of_sync">The time on the Pod is out of sync. Please update the time in the Omnipod tab.</string>
|
||||||
<string name="omnipod_error_unexpected_exception">An unexpected error occurred. Please report! (%1$s: %2$s).</string>
|
<string name="omnipod_error_unexpected_exception">An unexpected error occurred. Please report! (%1$s: %2$s).</string>
|
||||||
<string name="omnipod_error_crc_mismatch">Communication failed: message integrity verification failed</string>
|
<string name="omnipod_error_crc_mismatch">Communication failed: message integrity verification failed</string>
|
||||||
<string name="omnipod_error_invalid_packet_type">Communication failed: received an invalid packet from the Pod</string>
|
<string name="omnipod_error_invalid_packet_type">Communication failed: received an invalid packet from the Pod</string>
|
||||||
|
|
Loading…
Reference in a new issue