use of com.zsmartsystems.zigbee.CommandResult in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestNodeDescriptor.
/**
* Get node descriptor
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestNodeDescriptor() throws InterruptedException, ExecutionException {
final NodeDescriptorRequest nodeDescriptorRequest = new NodeDescriptorRequest();
nodeDescriptorRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
nodeDescriptorRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.unicast(nodeDescriptorRequest, nodeDescriptorRequest).get();
final NodeDescriptorResponse nodeDescriptorResponse = (NodeDescriptorResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery NodeDescriptorResponse returned {}", node.getIeeeAddress(), nodeDescriptorResponse);
if (nodeDescriptorResponse == null) {
return false;
}
if (nodeDescriptorResponse.getStatus() == ZdoStatus.SUCCESS) {
node.setNodeDescriptor(nodeDescriptorResponse.getNodeDescriptor());
return true;
}
return false;
}
use of com.zsmartsystems.zigbee.CommandResult 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.CommandResult in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestNetworkAddress.
/**
* Get node descriptor
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestNetworkAddress() throws InterruptedException, ExecutionException {
NetworkAddressRequest networkAddressRequest = new NetworkAddressRequest();
networkAddressRequest.setIeeeAddr(node.getIeeeAddress());
networkAddressRequest.setRequestType(0);
networkAddressRequest.setStartIndex(0);
networkAddressRequest.setDestinationAddress(new ZigBeeEndpointAddress(ZigBeeBroadcastDestination.BROADCAST_ALL_DEVICES.getKey()));
CommandResult response = networkManager.unicast(networkAddressRequest, networkAddressRequest).get();
final NetworkAddressResponse networkAddressResponse = (NetworkAddressResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery NetworkAddressRequest returned {}", node.getNetworkAddress(), networkAddressResponse);
if (networkAddressResponse == null) {
return false;
}
if (networkAddressResponse.getStatus() == ZdoStatus.SUCCESS) {
node.setNetworkAddress(networkAddressResponse.getNwkAddrRemoteDev());
return true;
}
return false;
}
use of com.zsmartsystems.zigbee.CommandResult in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestActiveEndpoints.
/**
* Get the active endpoints for a node
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestActiveEndpoints() throws InterruptedException, ExecutionException {
final ActiveEndpointsRequest activeEndpointsRequest = new ActiveEndpointsRequest();
activeEndpointsRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
activeEndpointsRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.unicast(activeEndpointsRequest, activeEndpointsRequest).get();
final ActiveEndpointsResponse activeEndpointsResponse = (ActiveEndpointsResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery ActiveEndpointsResponse returned {}", node.getIeeeAddress(), response);
if (activeEndpointsResponse == null) {
return false;
}
// Get the simple descriptors for all endpoints
List<ZigBeeEndpoint> endpoints = new ArrayList<ZigBeeEndpoint>();
for (final int endpointId : activeEndpointsResponse.getActiveEpList()) {
ZigBeeEndpoint endpoint = getSimpleDescriptor(endpointId);
if (endpoint == null) {
return false;
}
endpoints.add(endpoint);
}
// All endpoints have been received, so add them to the node
for (ZigBeeEndpoint endpoint : endpoints) {
node.addEndpoint(endpoint);
}
return true;
}
use of com.zsmartsystems.zigbee.CommandResult 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