use of org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent in project openhab1-addons by openhab.
the class RemoveFailedNodeMessageClass method handleRequest.
@Override
public boolean handleRequest(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: Got RemoveFailedNode request.", nodeId);
switch(incomingMessage.getMessagePayloadByte(0)) {
case FAILED_NODE_OK:
logger.error("NODE {}: Unable to remove failed node as it is not a failed node!", nodeId);
transactionComplete = true;
break;
case FAILED_NODE_REMOVED:
logger.debug("NODE {}: Successfully removed node from controller database!", nodeId);
zController.notifyEventListeners(new ZWaveNetworkEvent(Type.DeleteNode, nodeId, State.Success));
transactionComplete = true;
break;
case FAILED_NODE_NOT_REMOVED:
logger.error("NODE {}: Unable to remove failed node!", nodeId);
transactionComplete = true;
break;
default:
logger.error("NODE {}: Remove failed node failed with error 0x{}.", nodeId, Integer.toHexString(incomingMessage.getMessagePayloadByte(0)));
transactionComplete = true;
break;
}
return true;
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent in project openhab1-addons by openhab.
the class RequestNodeNeighborUpdateMessageClass method handleRequest.
@Override
public boolean handleRequest(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: Got NodeNeighborUpdate request.", nodeId);
switch(incomingMessage.getMessagePayloadByte(1)) {
case REQUEST_NEIGHBOR_UPDATE_STARTED:
logger.debug("NODE {}: NodeNeighborUpdate STARTED", nodeId);
// We're done
transactionComplete = true;
break;
case REQUEST_NEIGHBOR_UPDATE_DONE:
logger.debug("NODE {}: NodeNeighborUpdate DONE", nodeId);
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.NodeNeighborUpdate, nodeId, ZWaveNetworkEvent.State.Success));
transactionComplete = true;
break;
case REQUEST_NEIGHBOR_UPDATE_FAILED:
logger.error("NODE {}: NodeNeighborUpdate FAILED", nodeId);
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.NodeNeighborUpdate, nodeId, ZWaveNetworkEvent.State.Failure));
transactionComplete = true;
break;
}
return true;
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent in project openhab1-addons by openhab.
the class DeleteReturnRouteMessageClass method handleResponse.
@Override
public boolean handleResponse(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: Got DeleteReturnRoute response.", nodeId);
if (incomingMessage.getMessagePayloadByte(0) != 0x00) {
logger.debug("NODE {}: DeleteReturnRoute command in progress.", nodeId);
} else {
logger.error("NODE {}: DeleteReturnRoute command failed.", nodeId);
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.DeleteReturnRoute, nodeId, ZWaveNetworkEvent.State.Failure));
}
return true;
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent in project openhab1-addons by openhab.
the class DeleteReturnRouteMessageClass method handleRequest.
@Override
public boolean handleRequest(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: Got DeleteReturnRoute request.", nodeId);
if (incomingMessage.getMessagePayloadByte(1) != 0x00) {
logger.error("NODE {}: Delete return routes failed with error 0x{}.", nodeId, Integer.toHexString(incomingMessage.getMessagePayloadByte(1)));
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.DeleteReturnRoute, nodeId, ZWaveNetworkEvent.State.Failure));
} else {
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.DeleteReturnRoute, nodeId, ZWaveNetworkEvent.State.Success));
}
return true;
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent in project openhab1-addons by openhab.
the class GetRoutingInfoMessageClass method handleResponse.
@Override
public boolean handleResponse(ZWaveController zController, SerialMessage lastSentMessage, SerialMessage incomingMessage) {
int nodeId = lastSentMessage.getMessagePayloadByte(0);
logger.debug("NODE {}: Got NodeRoutingInfo request.", nodeId);
// Get the node
ZWaveNode node = zController.getNode(nodeId);
if (node == null) {
logger.error("NODE {}: Routing information for unknown node", nodeId);
incomingMessage.setTransactionCanceled();
return false;
}
node.clearNeighbors();
boolean hasNeighbors = false;
for (int by = 0; by < NODE_BYTES; by++) {
for (int bi = 0; bi < 8; bi++) {
if ((incomingMessage.getMessagePayloadByte(by) & (0x01 << bi)) != 0) {
hasNeighbors = true;
// Add the node to the neighbor list
node.addNeighbor((by << 3) + bi + 1);
}
}
}
if (!hasNeighbors) {
logger.debug("NODE {}: No neighbors reported", nodeId);
} else {
String neighbors = "Neighbor nodes:";
for (Integer neighborNode : node.getNeighbors()) {
neighbors += " " + neighborNode;
}
logger.debug("NODE {}: {}", nodeId, neighbors);
}
zController.notifyEventListeners(new ZWaveNetworkEvent(ZWaveNetworkEvent.Type.NodeRoutingInfo, nodeId, ZWaveNetworkEvent.State.Success));
checkTransactionComplete(lastSentMessage, incomingMessage);
return true;
}
Aggregations