use of com.daveoxley.cbus.CGateConnectException in project openhab-addons by openhab.
the class CBusCGateHandler method connect.
private void connect() {
CGateSession cGateSession = this.cGateSession;
if (cGateSession == null) {
cGateSession = CGateInterface.connect(this.ipAddress, 20023, 20024, 20025, new CBusThreadPool());
cGateSession.registerEventCallback(new EventMonitor());
cGateSession.registerStatusChangeCallback(new StatusChangeMonitor());
this.cGateSession = cGateSession;
}
if (cGateSession.isConnected()) {
logger.debug("CGate session reports online");
updateStatus(ThingStatus.ONLINE);
} else {
try {
cGateSession.connect();
updateStatus();
} catch (CGateConnectException e) {
updateStatus();
logger.debug("Failed to connect to CGate:", e);
try {
cGateSession.close();
} catch (CGateException ignore) {
// We dont really care if an exception is thrown when clossing the connection after a failure
// connecting.
}
}
}
}
Aggregations