Fix message sequence numbers when resyncing nonce
This commit is contained in:
parent
84ce2d1790
commit
1b2c91a6f9
1 changed files with 8 additions and 3 deletions
|
@ -164,8 +164,10 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
if (error.getErrorResponseCode() == ErrorResponse.ERROR_RESPONSE_CODE_BAD_NONCE) {
|
if (error.getErrorResponseCode() == ErrorResponse.ERROR_RESPONSE_CODE_BAD_NONCE) {
|
||||||
podStateManager.resyncNonce(error.getNonceSearchKey(), message.getSentNonce(), message.getSequenceNumber());
|
podStateManager.resyncNonce(error.getNonceSearchKey(), message.getSentNonce(), message.getSequenceNumber());
|
||||||
if (automaticallyResyncNonce) {
|
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());
|
message.resyncNonce(podStateManager.getCurrentNonce());
|
||||||
} else {
|
} else {
|
||||||
|
aapsLogger.warn(LTag.PUMPCOMM, "Received ErrorResponse 0x14 (Nonce out of sync). Not resyncing nonce as automaticallyResyncNonce=true");
|
||||||
podStateManager.setLastFailedCommunication(DateTime.now());
|
podStateManager.setLastFailedCommunication(DateTime.now());
|
||||||
throw new NonceOutOfSyncException();
|
throw new NonceOutOfSyncException();
|
||||||
}
|
}
|
||||||
|
@ -195,6 +197,11 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
packetAddress = addressOverride;
|
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();
|
podStateManager.increaseMessageNumber();
|
||||||
|
|
||||||
boolean firstPacket = true;
|
boolean firstPacket = true;
|
||||||
|
@ -295,9 +302,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
|
|
||||||
MessageBlock messageBlock = messageBlocks.get(0);
|
MessageBlock messageBlock = messageBlocks.get(0);
|
||||||
|
|
||||||
if (messageBlock.getType() != MessageBlockType.ERROR_RESPONSE) {
|
|
||||||
podStateManager.increaseMessageNumber();
|
podStateManager.increaseMessageNumber();
|
||||||
}
|
|
||||||
|
|
||||||
return messageBlock;
|
return messageBlock;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue