почему не могу подключить knx к андроиду используя KNXNetworkLinkIP - PullRequest
0 голосов
/ 12 ноября 2018

Я хочу подключить устройство Android к knx с помощью wifi-модема библиотеки calimero, я использую следующий код внутри doInBackground:

private static final String remoteHost = "192.168.1.10";
private static final String group = "0/0/1";
private static final String remoteip = "192.168.1.10";
private static final int knxServerPort = KNXnetIPConnection.DEFAULT_PORT;

        KNXNetworkLink knxLink = null;
        ProcessCommunicator pc = null;
        try {

            final InetSocketAddress localEP = new InetSocketAddress(InetAddress.getByName(remoteHost), 0);
            final InetSocketAddress remoteEP = new InetSocketAddress(remoteip, knxServerPort);

            knxLink = new KNXNetworkLinkIP(KNXNetworkLinkIP.TUNNELING, localEP, remoteEP, true, TPSettings.TP1);

            pc = new ProcessCommunicatorImpl(knxLink);
            pc.write(new GroupAddress(group), true);
            knxLink.close();
        }
        catch (final KNXException e) {
            System.out.println("Error reading KNX datapoint: " + e.getMessage());
        }
        catch (final InterruptedException e) {
            System.out.println("Interrupted: " + e.getMessage());
            e.printStackTrace();
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        finally {
            // we don't need the process communicator anymore, detach it from the link
            if (pc != null)
                pc.detach();
            // close the KNX link
            if (knxLink != null)
                knxLink.close();
        }

Но я получаю следующую ошибку, и Android не может подключиться к моему модулю IP:

            tuwien.auto.calimero.exception.KNXException: on connect to /192.168.1.10:3671
     at tuwien.auto.calimero.knxnetip.ClientConnection.connect(ClientConnection.java:176)
     at tuwien.auto.calimero.knxnetip.KNXnetIPTunnel.<init>(KNXnetIPTunnel.java:131)
     at tuwien.auto.calimero.link.KNXNetworkLinkIP.<init>(KNXNetworkLinkIP.java:142)
     at com.armantsco.smarthome.MainActivity$myAsync.doInBackground(MainActivity.java:130)
     at com.armantsco.smarthome.MainActivity$myAsync.doInBackground(MainActivity.java:71)
     at android.os.AsyncTask$2.call(AsyncTask.java:288)
     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
     at java.lang.Thread.run(Thread.java:841)
 Caused by: java.net.BindException: bind failed: EADDRNOTAVAIL (Cannot assign requested address)
     at libcore.io.IoBridge.bind(IoBridge.java:89)
     at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:68)
     at java.net.DatagramSocket.bind(DatagramSocket.java:457)
     at java.net.DatagramSocket.<init>(DatagramSocket.java:404)
     at tuwien.auto.calimero.knxnetip.ClientConnection.connect(ClientConnection.java:150)

 Caused by: libcore.io.ErrnoException: bind failed: EADDRNOTAVAIL (Cannot assign requested address)
     at libcore.io.Posix.bind(Native Method)
     at libcore.io.ForwardingOs.bind(ForwardingOs.java:40)
     at libcore.io.IoBridge.bind(IoBridge.java:87)

 eglSurfaceAttrib not implemented 3093 12436
 Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4aa121ec attribute=null, token = android.os.BinderProxy@4a9e5ea4

также я изменяю remoteHost на 192.168.1.1, но результат тот же,

Пожалуйста, помогите мне, что не так?

...