Question

I'm trying to connect my Glass with Arduino and a Wifi Shield.

At MenuActivity.java I call (and others methods... but this is the call) :

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

And my 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. 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)

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 Imagen

Was it helpful?

Solution

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:

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top