use of com.zsmartsystems.zigbee.zdo.command.ManagementRoutingResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestRoutingTable.
/**
* Get node routing table by making a {@link ManagementRoutingRequest} request
*
* @return list of {@link RoutingTable} if the request was processed ok, null otherwise
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestRoutingTable() throws InterruptedException, ExecutionException {
// Start index for the list is 0
int startIndex = 0;
int totalRoutes = 0;
Set<RoutingTable> routes = new HashSet<RoutingTable>();
do {
final ManagementRoutingRequest routeRequest = new ManagementRoutingRequest();
routeRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
routeRequest.setStartIndex(startIndex);
CommandResult response = networkManager.unicast(routeRequest, routeRequest).get();
final ManagementRoutingResponse routingResponse = response.getResponse();
logger.debug("{}: Node SVC Discovery ManagementRoutingRequest returned {}", node.getIeeeAddress(), response);
if (routingResponse == null) {
return false;
}
if (routingResponse.getStatus() == ZdoStatus.NOT_SUPPORTED) {
supportsManagementRouting = false;
return true;
} else if (routingResponse.getStatus() != ZdoStatus.SUCCESS) {
return false;
}
// Save the routes
routes.addAll(routingResponse.getRoutingTableList());
// Continue with next request
startIndex += routingResponse.getRoutingTableList().size();
totalRoutes = routingResponse.getRoutingTableEntries();
} while (startIndex < totalRoutes);
node.setRoutes(routes);
return true;
}
Aggregations