Search in sources :

Example 6 with ZWaveEndpoint

use of org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint in project openhab1-addons by openhab.

the class ZWaveMultiInstanceCommandClass method handleMultiInstanceEncapResponse.

/**
     * Handles Multi Instance Encapsulation message. Decapsulates
     * an Application Command message and handles it using the right
     * instance.
     *
     * @param serialMessage the serial message to process.
     * @param offset the offset at which to start procesing.
     */
private void handleMultiInstanceEncapResponse(SerialMessage serialMessage, int offset) {
    logger.trace("Process Multi-instance Encapsulation");
    int instance = serialMessage.getMessagePayloadByte(offset);
    int commandClassCode = serialMessage.getMessagePayloadByte(offset + 1);
    CommandClass commandClass = CommandClass.getCommandClass(commandClassCode);
    if (commandClass == null) {
        logger.error(String.format("NODE %d: Unsupported command class 0x%02x", this.getNode().getNodeId(), commandClassCode));
        return;
    }
    logger.debug(String.format("NODE %d: Requested Command Class = %s (0x%02x)", this.getNode().getNodeId(), commandClass.getLabel(), commandClassCode));
    ZWaveCommandClass zwaveCommandClass = null;
    // first get command class from endpoint, if supported
    if (this.getVersion() >= 2) {
        ZWaveEndpoint endpoint = this.endpoints.get(instance);
        if (endpoint != null) {
            zwaveCommandClass = endpoint.getCommandClass(commandClass);
            if (zwaveCommandClass == null) {
                logger.warn(String.format("NODE %d: CommandClass %s (0x%02x) not implemented by endpoint %d, fallback to main node.", this.getNode().getNodeId(), commandClass.getLabel(), commandClassCode, instance));
            }
        }
    }
    if (zwaveCommandClass == null) {
        zwaveCommandClass = this.getNode().getCommandClass(commandClass);
    }
    if (zwaveCommandClass == null) {
        logger.error(String.format("NODE %d: Unsupported command class %s (0x%02x)", this.getNode().getNodeId(), commandClass.getLabel(), commandClassCode));
        return;
    }
    logger.debug("NODE {}: Instance = {}, calling handleApplicationCommandRequest.", this.getNode().getNodeId(), instance);
    zwaveCommandClass.handleApplicationCommandRequest(serialMessage, offset + 2, instance);
}
Also used : ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint) ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)

Aggregations

ZWaveEndpoint (org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)6 ZWaveDbAssociationGroup (org.openhab.binding.zwave.internal.config.ZWaveDbAssociationGroup)1 ZWaveDbCommandClass (org.openhab.binding.zwave.internal.config.ZWaveDbCommandClass)1 ZWaveDbConfigurationParameter (org.openhab.binding.zwave.internal.config.ZWaveDbConfigurationParameter)1 ZWaveProductDatabase (org.openhab.binding.zwave.internal.config.ZWaveProductDatabase)1 SerialMessage (org.openhab.binding.zwave.internal.protocol.SerialMessage)1 ZWaveAssociationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass)1 ZWaveCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClass)1 ZWaveCommandClassDynamicState (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClassDynamicState)1 ZWaveCommandClassInitialization (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClassInitialization)1 ZWaveConfigurationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass)1 ZWaveManufacturerSpecificCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveManufacturerSpecificCommandClass)1 ZWaveMultiInstanceCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveMultiInstanceCommandClass)1 ZWaveNoOperationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveNoOperationCommandClass)1 ZWaveSecurityCommandClassWithInitialization (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveSecurityCommandClassWithInitialization)1 ZWaveVersionCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveVersionCommandClass)1 ZWaveWakeUpCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)1 ZWaveEvent (org.openhab.binding.zwave.internal.protocol.event.ZWaveEvent)1 ZWaveInitializationCompletedEvent (org.openhab.binding.zwave.internal.protocol.event.ZWaveInitializationCompletedEvent)1 GetRoutingInfoMessageClass (org.openhab.binding.zwave.internal.protocol.serialmessage.GetRoutingInfoMessageClass)1