Search in sources :

Example 1 with IndividualAddress

use of tuwien.auto.calimero.IndividualAddress in project openhab1-addons by openhab.

the class KNXConnection method connectByIp.

private static KNXNetworkLink connectByIp(int ipConnectionType, String localIp, String ip, int port) throws KNXException, UnknownHostException, InterruptedException {
    InetSocketAddress localEndPoint = null;
    if (StringUtils.isNotBlank(localIp)) {
        localEndPoint = new InetSocketAddress(localIp, 0);
    } else {
        try {
            InetAddress localHost = InetAddress.getLocalHost();
            localEndPoint = new InetSocketAddress(localHost, 0);
        } catch (UnknownHostException uhe) {
            sLogger.warn("Couldn't find an IP address for this host. Please check the .hosts configuration or use the 'localIp' parameter to configure a valid IP address.");
        }
    }
    return new KNXNetworkLinkIP(ipConnectionType, localEndPoint, new InetSocketAddress(ip, port), sUseNAT, new TPSettings(new IndividualAddress(sLocalSourceAddr), true));
}
Also used : UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) TPSettings(tuwien.auto.calimero.link.medium.TPSettings) KNXNetworkLinkIP(tuwien.auto.calimero.link.KNXNetworkLinkIP) IndividualAddress(tuwien.auto.calimero.IndividualAddress) InetAddress(java.net.InetAddress)

Aggregations

InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 IndividualAddress (tuwien.auto.calimero.IndividualAddress)1 KNXNetworkLinkIP (tuwien.auto.calimero.link.KNXNetworkLinkIP)1 TPSettings (tuwien.auto.calimero.link.medium.TPSettings)1