Don't pad messages that contain a DeactivatePodCommand message block and don't use verification for deactivatePod

This commit is contained in:
Bart Sopers 2019-12-24 15:39:49 -05:00
parent aea725e9ad
commit 36a1a13846
4 changed files with 16 additions and 9 deletions

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodPacket;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.DeactivatePodCommand;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.ErrorResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent;
@ -149,7 +150,9 @@ public class OmnipodCommunicationService extends RileyLinkCommunicationManager {
boolean firstPacket = true;
byte[] encodedMessage;
if (message.isNonceResyncable()) {
// this does not work well with the deactivate pod command, we somehow either
// receive an ACK instead of a normal response, or a partial response and a communication timeout
if (message.isNonceResyncable() && !message.containsBlock(DeactivatePodCommand.class)) {
OmnipodMessage paddedMessage = new OmnipodMessage(message);
// If messages are nonce resyncable, we want do distinguish between certain and uncertain failures for verification purposes
// However, some commands (e.g. cancel delivery) are single packet command by nature. When we get a timeout with a single packet,

View file

@ -403,7 +403,7 @@ public class OmnipodManager {
try {
// Always send acknowledgement beeps here. Matches the PDM's behavior
executeAndVerify(() -> communicationService.executeAction(new DeactivatePodAction(podState, true)));
communicationService.executeAction(new DeactivatePodAction(podState, true));
} catch (PodFaultException ex) {
if (isLoggingEnabled()) {
LOG.info("Ignoring PodFaultException in deactivatePod", ex);

View file

@ -115,12 +115,7 @@ public class OmnipodMessage {
}
public boolean isNonceResyncable() {
for (MessageBlock messageBlock : messageBlocks) {
if (messageBlock instanceof NonceResyncableMessageBlock) {
return true;
}
}
return false;
return containsBlock(NonceResyncableMessageBlock.class);
}
public int getSentNonce() {
@ -139,4 +134,13 @@ public class OmnipodMessage {
}
}
}
public boolean containsBlock(Class<? extends MessageBlock> blockType) {
for (MessageBlock messageBlock : messageBlocks) {
if (blockType.isInstance(messageBlock)) {
return true;
}
}
return false;
}
}

View file

@ -316,7 +316,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
try {
delegate.cancelBolus(isBolusBeepsEnabled());
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
} catch(PodFaultException ex) {
} catch (PodFaultException ex) {
showNotificationWithDialog(createPodFaultErrorMessage(ex.getFaultEvent().getFaultEventType()), Notification.URGENT, null);
} catch (Exception ex) {
String comment = handleAndTranslateException(ex);