Search in sources :

Example 1 with TransferMode

use of org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode in project smarthome by eclipse.

the class AbstractHomematicGateway method startServers.

/**
 * Starts the Homematic RPC server.
 */
private synchronized void startServers() throws IOException {
    for (TransferMode mode : availableInterfaces.values()) {
        if (!rpcServers.containsKey(mode)) {
            RpcServer rpcServer = mode == TransferMode.XML_RPC ? new XmlRpcServer(this, config) : new BinRpcServer(this, config);
            rpcServers.put(mode, rpcServer);
            rpcServer.start();
        }
    }
    for (HmInterface hmInterface : availableInterfaces.keySet()) {
        getRpcClient(hmInterface).init(hmInterface, hmInterface.toString() + "-" + id);
    }
}
Also used : BinRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer) BinRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer) RpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.RpcServer) XmlRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer) TransferMode(org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode) XmlRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)

Example 2 with TransferMode

use of org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode in project smarthome by eclipse.

the class AbstractHomematicGateway method initialize.

@Override
public void initialize() throws IOException {
    logger.debug("Initializing gateway with id '{}'", id);
    HmGatewayInfo gatewayInfo = config.getGatewayInfo();
    if (gatewayInfo.isHomegear()) {
        // Homegear
        availableInterfaces.put(HmInterface.RF, TransferMode.BIN_RPC);
    } else if (gatewayInfo.isCCU()) {
        // CCU
        if (gatewayInfo.isRfInterface()) {
            availableInterfaces.put(HmInterface.RF, TransferMode.XML_RPC);
        }
        if (gatewayInfo.isWiredInterface()) {
            availableInterfaces.put(HmInterface.WIRED, TransferMode.XML_RPC);
        }
        if (gatewayInfo.isHmipInterface()) {
            availableInterfaces.put(HmInterface.HMIP, TransferMode.XML_RPC);
        }
        if (gatewayInfo.isCuxdInterface()) {
            availableInterfaces.put(HmInterface.CUXD, TransferMode.BIN_RPC);
        }
        if (gatewayInfo.isGroupInterface()) {
            availableInterfaces.put(HmInterface.GROUP, TransferMode.XML_RPC);
        }
    } else {
        // other
        if (gatewayInfo.isRfInterface()) {
            availableInterfaces.put(HmInterface.RF, TransferMode.XML_RPC);
        }
        if (gatewayInfo.isWiredInterface()) {
            availableInterfaces.put(HmInterface.WIRED, TransferMode.XML_RPC);
        }
        if (gatewayInfo.isHmipInterface()) {
            availableInterfaces.put(HmInterface.HMIP, TransferMode.XML_RPC);
        }
    }
    logger.info("{}", config.getGatewayInfo());
    StringBuilder sb = new StringBuilder();
    for (Entry<HmInterface, TransferMode> entry : availableInterfaces.entrySet()) {
        sb.append(entry.getKey()).append(":").append(entry.getValue()).append(", ");
    }
    if (sb.length() > 2) {
        sb.setLength(sb.length() - 2);
    }
    logger.debug("Used Homematic transfer modes: {}", sb.toString());
    startClients();
    startServers();
    if (!config.getGatewayInfo().isHomegear()) {
        // delay the newDevice event handling at startup, reduces some API calls
        long delay = config.getGatewayInfo().isCCU1() ? 10 : 3;
        enableNewDeviceFuture = scheduler.schedule(() -> {
            newDeviceEventsEnabled = true;
        }, delay, TimeUnit.MINUTES);
    } else {
        newDeviceEventsEnabled = true;
    }
}
Also used : HmGatewayInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface) TransferMode(org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode)

Aggregations

TransferMode (org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode)2 HmInterface (org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)2 BinRpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer)1 RpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.RpcServer)1 XmlRpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer)1 HmGatewayInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo)1