use of org.openhab.binding.zwave.internal.protocol.ZWaveDeviceClass.Generic in project openhab1-addons by openhab.
the class ZWaveMultiInstanceCommandClass method updateDeviceClass.
/**
* Determines the device class properties of the endpoint.
*
* @param endpoint The endpoint to update.
* @param genericDeviceClass The generic device class of the parent device of the endpoint
* @param specificDeviceClass The specific device class of the parent device of the endpoint
* @param dynamic True when the endpoint is dynamic.
* @return True when successful, false otherwise
*/
private boolean updateDeviceClass(ZWaveEndpoint endpoint, int genericDeviceClass, int specificDeviceClass, boolean dynamic) {
Basic basic = this.getNode().getDeviceClass().getBasicDeviceClass();
Generic generic = Generic.getGeneric(genericDeviceClass);
if (generic == null) {
logger.error(String.format("NODE %d: Endpoint %d has invalid device class. generic = 0x%02x, specific = 0x%02x.", this.getNode().getNodeId(), endpoint, genericDeviceClass, specificDeviceClass));
return false;
}
Specific specific = Specific.getSpecific(generic, specificDeviceClass);
if (specific == null) {
logger.error(String.format("NODE %d: Endpoint %d has invalid device class. generic = 0x%02x, specific = 0x%02x.", this.getNode().getNodeId(), endpoint, genericDeviceClass, specificDeviceClass));
return false;
}
logger.debug("NODE {}: Endpoint Id = {}", this.getNode().getNodeId(), endpoint.getEndpointId());
logger.debug("NODE {}: Endpoints is dynamic = {}", this.getNode().getNodeId(), dynamic ? "true" : false);
logger.debug(String.format("NODE %d: Basic = %s 0x%02x", this.getNode().getNodeId(), basic.getLabel(), basic.getKey()));
logger.debug(String.format("NODE %d: Generic = %s 0x%02x", this.getNode().getNodeId(), generic.getLabel(), generic.getKey()));
logger.debug(String.format("NODE %d: Specific = %s 0x%02x", this.getNode().getNodeId(), specific.getLabel(), specific.getKey()));
ZWaveDeviceClass deviceClass = endpoint.getDeviceClass();
deviceClass.setBasicDeviceClass(basic);
deviceClass.setGenericDeviceClass(generic);
deviceClass.setSpecificDeviceClass(specific);
return true;
}
use of org.openhab.binding.zwave.internal.protocol.ZWaveDeviceClass.Generic in project openhab1-addons by openhab.
the class IdentifyNodeMessageClass method handleResponse.
@Override
public boolean handleResponse(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
logger.trace("Handle Message Get Node ProtocolInfo Response");
// Check that this request is consistent with the response
if (lastSentMessage.getMessageClass() != SerialMessageClass.IdentifyNode) {
logger.warn("Got IdentifyNodeMessage without request, ignoring. Last message was {}.", lastSentMessage.getMessageClass());
return false;
}
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: ProtocolInfo", nodeId);
ZWaveNode node = zController.getNode(nodeId);
boolean listening = (incomingMessage.getMessagePayloadByte(0) & 0x80) != 0 ? true : false;
boolean routing = (incomingMessage.getMessagePayloadByte(0) & 0x40) != 0 ? true : false;
int version = (incomingMessage.getMessagePayloadByte(0) & 0x07) + 1;
boolean frequentlyListening = (incomingMessage.getMessagePayloadByte(1) & 0x60) != 0 ? true : false;
boolean beaming = ((incomingMessage.getMessagePayloadByte(1) & 0x10) != 0);
boolean security = ((incomingMessage.getMessagePayloadByte(1) & 0x01) != 0);
int maxBaudRate = 9600;
if ((incomingMessage.getMessagePayloadByte(0) & 0x38) == 0x10) {
maxBaudRate = 40000;
}
logger.debug("NODE {}: Listening = {}", nodeId, listening);
logger.debug("NODE {}: Routing = {}", nodeId, routing);
logger.debug("NODE {}: Beaming = {}", nodeId, beaming);
logger.debug("NODE {}: Version = {}", nodeId, version);
logger.debug("NODE {}: FLIRS = {}", nodeId, frequentlyListening);
logger.debug("NODE {}: Security = {}", nodeId, security);
logger.debug("NODE {}: Max Baud = {}", nodeId, maxBaudRate);
node.setListening(listening);
node.setRouting(routing);
node.setVersion(version);
node.setFrequentlyListening(frequentlyListening);
node.setSecurity(security);
node.setBeaming(beaming);
node.setMaxBaud(maxBaudRate);
Basic basic = Basic.getBasic(incomingMessage.getMessagePayloadByte(3));
if (basic == null) {
logger.error(String.format("NODE %d: Basic device class 0x%02x not found", nodeId, incomingMessage.getMessagePayloadByte(3)));
return false;
}
logger.debug("NODE {}: Basic = {}", nodeId, basic.getLabel());
Generic generic = Generic.getGeneric(incomingMessage.getMessagePayloadByte(4));
if (generic == null) {
logger.error(String.format("NODE %d: Generic device class 0x%02x not found", nodeId, incomingMessage.getMessagePayloadByte(4)));
return false;
}
logger.debug("NODE {}: Generic = {}", nodeId, generic.getLabel());
Specific specific = Specific.getSpecific(generic, incomingMessage.getMessagePayloadByte(5));
if (specific == null) {
logger.error(String.format("NODE %d: Specific device class 0x%02x not found", nodeId, incomingMessage.getMessagePayloadByte(5)));
return false;
}
logger.debug("NODE {}: Specific = {}", nodeId, specific.getLabel());
ZWaveDeviceClass deviceClass = node.getDeviceClass();
deviceClass.setBasicDeviceClass(basic);
deviceClass.setGenericDeviceClass(generic);
deviceClass.setSpecificDeviceClass(specific);
// Add mandatory command classes as specified by its generic device class.
for (CommandClass commandClass : generic.getMandatoryCommandClasses()) {
ZWaveCommandClass zwaveCommandClass = ZWaveCommandClass.getInstance(commandClass.getKey(), node, zController);
if (zwaveCommandClass != null) {
zController.getNode(nodeId).addCommandClass(zwaveCommandClass);
}
}
// Add mandatory command classes as specified by its specific device class.
for (CommandClass commandClass : specific.getMandatoryCommandClasses()) {
ZWaveCommandClass zwaveCommandClass = ZWaveCommandClass.getInstance(commandClass.getKey(), node, zController);
if (zwaveCommandClass != null) {
node.addCommandClass(zwaveCommandClass);
}
}
checkTransactionComplete(lastSentMessage, incomingMessage);
return true;
}
Aggregations