Search in sources :

Example 1 with PowerDescriptorRequest

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

the class ZigBeeNodeServiceDiscoverer method requestPowerDescriptor.

/**
 * Get node power descriptor
 *
 * @return true if the message was processed ok, or if the end device does not support the power descriptor
 * @throws ExecutionException
 * @throws InterruptedException
 */
private boolean requestPowerDescriptor() throws InterruptedException, ExecutionException {
    final PowerDescriptorRequest powerDescriptorRequest = new PowerDescriptorRequest();
    powerDescriptorRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
    powerDescriptorRequest.setNwkAddrOfInterest(node.getNetworkAddress());
    CommandResult response = networkManager.unicast(powerDescriptorRequest, powerDescriptorRequest).get();
    final PowerDescriptorResponse powerDescriptorResponse = (PowerDescriptorResponse) response.getResponse();
    logger.debug("{}: Node SVC Discovery PowerDescriptorResponse returned {}", node.getIeeeAddress(), powerDescriptorResponse);
    if (powerDescriptorResponse == null) {
        return false;
    }
    if (powerDescriptorResponse.getStatus() == ZdoStatus.SUCCESS) {
        node.setPowerDescriptor(powerDescriptorResponse.getPowerDescriptor());
        return true;
    } else if (powerDescriptorResponse.getStatus() == ZdoStatus.NOT_SUPPORTED) {
        return true;
    }
    return false;
}
Also used : PowerDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.PowerDescriptorRequest) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) PowerDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.PowerDescriptorResponse) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Aggregations

CommandResult (com.zsmartsystems.zigbee.CommandResult)1 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 PowerDescriptorRequest (com.zsmartsystems.zigbee.zdo.command.PowerDescriptorRequest)1 PowerDescriptorResponse (com.zsmartsystems.zigbee.zdo.command.PowerDescriptorResponse)1