use of com.zsmartsystems.zigbee.zdo.command.IeeeAddressRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestAssociatedNodes.
/**
* Get Node Network address and the list of associated devices
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestAssociatedNodes() throws InterruptedException, ExecutionException {
Integer startIndex = 0;
int totalAssociatedDevices = 0;
Set<Integer> associatedDevices = new HashSet<Integer>();
do {
// Request extended response, to get associated list
final IeeeAddressRequest ieeeAddressRequest = new IeeeAddressRequest();
ieeeAddressRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
ieeeAddressRequest.setRequestType(1);
ieeeAddressRequest.setStartIndex(startIndex);
ieeeAddressRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.unicast(ieeeAddressRequest, ieeeAddressRequest).get();
final IeeeAddressResponse ieeeAddressResponse = response.getResponse();
logger.debug("{}: Node SVC Discovery IeeeAddressResponse returned {}", node.getIeeeAddress(), ieeeAddressResponse);
if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS) {
associatedDevices.addAll(ieeeAddressResponse.getNwkAddrAssocDevList());
startIndex += ieeeAddressResponse.getNwkAddrAssocDevList().size();
totalAssociatedDevices = ieeeAddressResponse.getNwkAddrAssocDevList().size();
}
} while (startIndex < totalAssociatedDevices);
node.setAssociatedDevices(associatedDevices);
return true;
}
use of com.zsmartsystems.zigbee.zdo.command.IeeeAddressRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkDiscoverer method getIeeeAddress.
/**
* Get Node IEEE address
*
* @param networkAddress the network address of the node
* @return true if the message was processed ok
*/
private boolean getIeeeAddress(final int networkAddress) {
try {
Integer startIndex = 0;
int totalAssociatedDevices = 0;
Set<Integer> associatedDevices = new HashSet<Integer>();
IeeeAddress ieeeAddress = null;
do {
// Request extended response, start index for associated list is 0
final IeeeAddressRequest ieeeAddressRequest = new IeeeAddressRequest();
ieeeAddressRequest.setDestinationAddress(new ZigBeeEndpointAddress(networkAddress));
ieeeAddressRequest.setRequestType(1);
ieeeAddressRequest.setStartIndex(startIndex);
ieeeAddressRequest.setNwkAddrOfInterest(networkAddress);
CommandResult response = networkManager.unicast(ieeeAddressRequest, ieeeAddressRequest).get();
if (response.isError()) {
return false;
}
final IeeeAddressResponse ieeeAddressResponse = response.getResponse();
logger.debug("{}: NWK Discovery IeeeAddressRequest returned {}", networkAddress, ieeeAddressResponse);
if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS) {
ieeeAddress = ieeeAddressResponse.getIeeeAddrRemoteDev();
if (startIndex.equals(ieeeAddressResponse.getStartIndex())) {
associatedDevices.addAll(ieeeAddressResponse.getNwkAddrAssocDevList());
startIndex += ieeeAddressResponse.getNwkAddrAssocDevList().size();
totalAssociatedDevices = ieeeAddressResponse.getNwkAddrAssocDevList().size();
}
}
} while (startIndex < totalAssociatedDevices);
addNode(ieeeAddress, networkAddress);
// Start discovery for any associated nodes
for (final int deviceNetworkAddress : associatedDevices) {
startNodeDiscovery(deviceNetworkAddress);
}
} catch (InterruptedException | ExecutionException e) {
logger.debug("NWK Discovery Error in checkIeeeAddressResponse ", e);
}
return true;
}
Aggregations