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);
}
Aggregations