Search in sources :

Example 1 with SimpleDescriptorRequest

use of com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNodeServiceDiscoverer method getSimpleDescriptor.

/**
 * Get the simple descriptor for an endpoint and create the {@link ZigBeeEndpoint}
 *
 * @param endpointId the endpoint id to request
 * @return the newly created {@link ZigBeeEndpoint} for the endpoint, or null on error
 * @throws ExecutionException
 * @throws InterruptedException
 */
private ZigBeeEndpoint getSimpleDescriptor(final int endpointId) throws InterruptedException, ExecutionException {
    final SimpleDescriptorRequest simpleDescriptorRequest = new SimpleDescriptorRequest();
    simpleDescriptorRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
    simpleDescriptorRequest.setNwkAddrOfInterest(node.getNetworkAddress());
    simpleDescriptorRequest.setEndpoint(endpointId);
    CommandResult response = networkManager.unicast(simpleDescriptorRequest, simpleDescriptorRequest).get();
    final SimpleDescriptorResponse simpleDescriptorResponse = (SimpleDescriptorResponse) response.getResponse();
    logger.debug("{}: Node SVC Discovery SimpleDescriptorResponse returned {}", node.getIeeeAddress(), simpleDescriptorResponse);
    if (simpleDescriptorResponse == null) {
        return null;
    }
    if (simpleDescriptorResponse.getStatus() == ZdoStatus.SUCCESS) {
        ZigBeeEndpoint endpoint = new ZigBeeEndpoint(networkManager, node, endpointId);
        SimpleDescriptor simpleDescriptor = simpleDescriptorResponse.getSimpleDescriptor();
        endpoint.setProfileId(simpleDescriptor.getProfileId());
        endpoint.setDeviceId(simpleDescriptor.getDeviceId());
        endpoint.setDeviceVersion(simpleDescriptor.getDeviceVersion());
        endpoint.setInputClusterIds(simpleDescriptor.getInputClusterList());
        endpoint.setOutputClusterIds(simpleDescriptor.getOutputClusterList());
        return endpoint;
    }
    return null;
}
Also used : SimpleDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorResponse) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) SimpleDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorRequest) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult) SimpleDescriptor(com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor)

Aggregations

CommandResult (com.zsmartsystems.zigbee.CommandResult)1 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)1 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 SimpleDescriptorRequest (com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorRequest)1 SimpleDescriptorResponse (com.zsmartsystems.zigbee.zdo.command.SimpleDescriptorResponse)1 SimpleDescriptor (com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor)1