Search in sources :

Example 1 with ZclCommandType

use of com.zsmartsystems.zigbee.zcl.protocol.ZclCommandType in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManager method receiveZclCommand.

private ZigBeeCommand receiveZclCommand(final ZclFieldDeserializer fieldDeserializer, final ZigBeeApsFrame apsFrame) {
    // Process the ZCL header
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    logger.debug("RX ZCL: {}", zclHeader);
    // Get the command type
    ZclCommandType commandType = null;
    if (zclHeader.getFrameType() == ZclFrameType.ENTIRE_PROFILE_COMMAND) {
        commandType = ZclCommandType.getGeneric(zclHeader.getCommandId());
    } else {
        commandType = ZclCommandType.getCommandType(apsFrame.getCluster(), zclHeader.getCommandId(), zclHeader.getDirection());
    }
    if (commandType == null) {
        logger.debug("No command type found for {}, cluster={}, command={}, direction={}", zclHeader.getFrameType(), apsFrame.getCluster(), zclHeader.getCommandId(), zclHeader.getDirection());
        return null;
    }
    ZclCommand command = commandType.instantiateCommand();
    if (command == null) {
        logger.debug("No command found for {}, cluster={}, command={}", zclHeader.getFrameType(), apsFrame.getCluster(), zclHeader.getCommandId());
        return null;
    }
    command.setCommandDirection(zclHeader.getDirection());
    command.deserialize(fieldDeserializer);
    command.setClusterId(apsFrame.getCluster());
    command.setTransactionId(zclHeader.getSequenceNumber());
    return command;
}
Also used : ZclCommandType(com.zsmartsystems.zigbee.zcl.protocol.ZclCommandType) ZclHeader(com.zsmartsystems.zigbee.zcl.ZclHeader) ZclCommand(com.zsmartsystems.zigbee.zcl.ZclCommand)

Aggregations

ZclCommand (com.zsmartsystems.zigbee.zcl.ZclCommand)1 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)1 ZclCommandType (com.zsmartsystems.zigbee.zcl.protocol.ZclCommandType)1