Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Duplicate nonce request #1304

Merged
merged 2 commits into from
Feb 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public class ZWaveSecurityCommandClass extends ZWaveCommandClass {
@XStreamOmitField
private byte lastTheirNonceId = (byte) 0xFF;

// The last nonce GET time
private static final long MINIMUM_NONCE_INTERVAL = 500;
@XStreamOmitField
private long lastNonceRequestReceived;

private static final String AES = "AES";

private static final List<Byte> securityRequired = Arrays.asList(new Byte[] {
Expand Down Expand Up @@ -271,6 +276,12 @@ public void handleSecurityNonceReport(ZWaveCommandClassPayload payload, int endp

@ZWaveResponseHandler(id = CommandClassSecurityV1.SECURITY_NONCE_GET, name = "SECURITY_NONCE_GET")
public void handleSecurityNonceGet(ZWaveCommandClassPayload payload, int endpoint) {
if (ourNonce != null && lastNonceRequestReceived > System.currentTimeMillis() - MINIMUM_NONCE_INTERVAL) {
logger.debug("NODE {}: Ignoring NONCE Request received after {}ms", getNode().getNodeId(),
System.currentTimeMillis() - MINIMUM_NONCE_INTERVAL);
return;
}
lastNonceRequestReceived = System.currentTimeMillis();
ourNonce = new ZWaveNonce();
getController().enqueueNonce(new ZWaveCommandClassTransactionPayloadBuilder(getNode().getNodeId(),
CommandClassSecurityV1.getSecurityNonceReport(ourNonce.getNonceBytes()))
Expand Down