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

ZigBeeNetworkManager.refreshnode small fixes #1231

Merged
merged 7 commits into from
Jul 26, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,7 @@ private Future<Boolean> refreshNode(final ZigBeeNode node) {
logger.debug("{}: Node update. NWK Address={}", node.getIeeeAddress(),
String.format("%04X", node.getNetworkAddress()));

final ZigBeeNode currentNode;
currentNode = networkNodes.get(node.getIeeeAddress());
final ZigBeeNode currentNode = networkNodes.get(node.getIeeeAddress());

// Return if we don't know this node
if (currentNode == null) {
Expand All @@ -1767,24 +1766,23 @@ private Future<Boolean> refreshNode(final ZigBeeNode node) {
return null;
}

if (node.getNodeDescriptor() != null && networkNodes.get(node.getIeeeAddress()) != null && Objects
.equals(networkNodes.get(node.getIeeeAddress()).getNodeDescriptor(), node.getNodeDescriptor())) {
if (node.getNodeDescriptor() != null && currentNode.getNodeDescriptor() != null) {
notificationService.execute(new Runnable() {
@Override
public void run() {
transport.setNodeDescriptor(node.getIeeeAddress(), node.getNodeDescriptor());
transport.setNodeDescriptor(currentNode.getIeeeAddress(), currentNode.getNodeDescriptor());
}
});
}

final boolean sendNodeAdded;
if (!nodeDiscoveryComplete.contains(currentNode.getIeeeAddress()) && currentNode.isDiscovered()
|| currentNode.getIeeeAddress().equals(localIeeeAddress)) {
nodeDiscoveryComplete.add(node.getIeeeAddress());
nodeDiscoveryComplete.add(currentNode.getIeeeAddress());
sendNodeAdded = true;
} else if (!currentNode.isDiscovered() && !currentNode.getIeeeAddress().equals(localIeeeAddress)) {
logger.debug("{}: Node {} discovery is not complete - sending nodeUpdated notification to inform listeners",
node.getIeeeAddress(), String.format("%04X", node.getNetworkAddress()));
currentNode.getIeeeAddress(), String.format("%04X", currentNode.getNetworkAddress()));
sendNodeAdded = false;
} else {
sendNodeAdded = false;
Expand Down Expand Up @@ -1818,15 +1816,15 @@ public void run() {
try {
// TODO: Set the timer properly
if (latch.await(2, TimeUnit.SECONDS)) {
logger.trace("{}: Refresh Node notifyListener LATCH Complete", node.getIeeeAddress());
logger.trace("{}: Refresh Node notifyListener LATCH Complete", currentNode.getIeeeAddress());
return true;
} else {
logger.trace("{}: Refresh Node notifyListener LATCH Timeout, remaining = {}", node.getIeeeAddress(),
logger.trace("{}: Refresh Node notifyListener LATCH Timeout, remaining = {}", currentNode.getIeeeAddress(),
latch.getCount());
return false;
}
} catch (InterruptedException e) {
logger.trace("{}: Refresh Node notifyListener LATCH Interrupted, remaining = {}", node.getIeeeAddress(),
logger.trace("{}: Refresh Node notifyListener LATCH Interrupted, remaining = {}", currentNode.getIeeeAddress(),
latch.getCount());
return false;
}
Expand Down