Fix message sequence numbers when resyncing nonce
This commit is contained in:
parent
84ce2d1790
commit
1b2c91a6f9
|
@ -164,8 +164,10 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
if (error.getErrorResponseCode() == ErrorResponse.ERROR_RESPONSE_CODE_BAD_NONCE) {
|
||||
podStateManager.resyncNonce(error.getNonceSearchKey(), message.getSentNonce(), message.getSequenceNumber());
|
||||
if (automaticallyResyncNonce) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Resyncing nonce and retrying to send message as automaticallyResyncNonce=true");
|
||||
message.resyncNonce(podStateManager.getCurrentNonce());
|
||||
} else {
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Not resyncing nonce as automaticallyResyncNonce=true");
|
||||
podStateManager.setLastFailedCommunication(DateTime.now());
|
||||
throw new NonceOutOfSyncException();
|
||||
}
|
||||
|
@ -195,6 +197,11 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
packetAddress = addressOverride;
|
||||
}
|
||||
|
||||
if (podStateManager.getMessageNumber() != message.getSequenceNumber()) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Message number in Pod State [{}] does not match message sequence number [{}]. Setting message number in Pod State to {}", podStateManager.getMessageNumber(), message.getSequenceNumber(), message.getSequenceNumber());
|
||||
podStateManager.setMessageNumber(message.getSequenceNumber());
|
||||
}
|
||||
|
||||
podStateManager.increaseMessageNumber();
|
||||
|
||||
boolean firstPacket = true;
|
||||
|
@ -295,9 +302,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
|
||||
MessageBlock messageBlock = messageBlocks.get(0);
|
||||
|
||||
if (messageBlock.getType() != MessageBlockType.ERROR_RESPONSE) {
|
||||
podStateManager.increaseMessageNumber();
|
||||
}
|
||||
|
||||
return messageBlock;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue