Search in sources :

Example 1 with ActiveEndpointsRequest

use of com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsRequest 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;
}
Also used : ActiveEndpointsRequest(com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsRequest) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) ActiveEndpointsResponse(com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsResponse) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Aggregations

CommandResult (com.zsmartsystems.zigbee.CommandResult)1 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)1 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 ActiveEndpointsRequest (com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsRequest)1 ActiveEndpointsResponse (com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsResponse)1 ArrayList (java.util.ArrayList)1