简体   繁体   English

Google玻璃和插座

[英]Google glass and sockets

I'm trying to connect my Glass with Arduino and a Wifi Shield. 我正在尝试将我的Glass与Arduino和Wifi Shield连接起来。

At MenuActivity.java I call (and others methods... but this is the call) : 在MenuActivity.java中,我调用了(以及其他方法……但这是调用):

protected void onCreate(Bundle savedInstanceState) 
    {
        new ConnexioArduino().execute();
        super.onCreate(savedInstanceState);
    }

And my ConnexioArduino.java : 还有我的ConnexioArduino.java:

private boolean socketReady;
    private BufferedWriter outA;
    private BufferedReader inA;
    private Socket mySocket;
....
.... 
@Override
    protected Void doInBackground(Void... params) {

        socketReady = true;         
        String Host = "192.168.43.177";
        int Port = 10001; 
        outA = null;
        inA = null;
        mySocket = null;

        try {
            mySocket = new Socket(Host, Port);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        try {
            mySocket.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

So it only does a connexion between Glass-Arduino Wifi Shield through Socket. 因此,它仅通过套接字在Glass-Arduino Wifi Shield之间建立连接。 But when I execute my app it stops and it gives me the following error : (see image on this link, sorry for the URL I don't have the enough reputation) 但是,当我执行我的应用程序时,它停止了,并给了我以下错误:(请参阅此链接上的图像,对于URL我没有足够的声誉感到抱歉)

http://google-glass-api.googlecode.com/issues/attachment?aid=4630000000&name=Captura+de+pantalla+2014-04-09+a+la%28s%29+13.08.12.png&token=CyuXI9n0-00D4I0inCvN122h42g%3A1398618521508&inline=1 http://google-glass-api.googlecode.com/issues/attachment?aid=4630000000&name=Captura+de+pantalla+2014-04-09+a+la%28s%29+13.08.12.png&token=CyuXI9n0- 00D4I0inCvN122h42g%3A1398618521508&inline = 1 图像

Share your manifest, it should have: 分享您的清单,其中应包含:

<uses-permission android:name="android.permission.INTERNET"/>

If not you will get a socket failed:eacces (permission denied) error if you step-debug. 否则,如果您逐步调试,则会收到套接字故障:错误(拒绝权限)错误。

Another possible problem is that your server is not accepting the socket request for any number of reasons. 另一个可能的问题是,由于多种原因,您的服务器不接受套接字请求。

I was able to use your exact code, set up a basic node server on a laptop, and open and close the socket without a crash. 我能够使用您的确切代码,在便携式计算机上设置基本节点服务器,并且可以在不崩溃的情况下打开和关闭套接字。

Socket code on Glass should be just like Android according to this: 根据以下内容,Glass上的套接字代码应类似于Android:

https://code.google.com/p/google-glass-api/issues/detail?id=272 https://code.google.com/p/google-glass-api/issues/detail?id=272

If you continue to have issues log out the value of e in the exceptions you are catching and paste the result into your question. 如果仍然遇到问题,请在捕获的异常中注销e的值,然后将结果粘贴到您的问题中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM