Android - Looky My Phone Position

Android phone with Motion Sensor (and other Sensors)  sends its data to the demo 

 

Not the most proficient, yet simple HTTP REST interface

Posting from Phone ------->  MRL ------> WebGui Display

I was very surprised on the speed - the phone quickly published its data, and the webgui on the http://demo.myrobotlab.org (in Virginia) was very responsive.  Not bad for so little code.  Here is the guts of the code, its simply using the MRL REST interface.

public final void send(String service, String method, Object... params) throws IOException {

        InputStream is = null;
        // Only display the first 500 characters of the retrieved
        // web page content.
        int len = 500;

        try {
            // TODO - try /api/messages for websocket support
            StringBuffer sb = new StringBuffer();
            for (Object o : params) {
                sb.append(String.format("/%s", o.toString()));
            }
            URL url = new URL(String.format("http://demo.myrobotlab.org:8888/api/service/%s/%s%s", service, method, sb.toString()));
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setReadTimeout(10000 /* milliseconds */);
            conn.setConnectTimeout(15000 /* milliseconds */);
            conn.setRequestMethod("GET");
            conn.setDoInput(true);
            // Starts the query
            conn.connect();
            int response = conn.getResponseCode();
            Log.d("DEBUG", "The response is: " + response);
            is = conn.getInputStream();

            // Convert the InputStream into a string
            // String contentAsString = readIt(is, len);
            //return contentAsString;

            // Makes sure that the InputStream is closed after the app is
            // finished using it.
        } catch (Exception e){
            Log.e("ERROR", e.getMessage());
        } finally {
            if (is != null) {
                is.close();
            }
        }

}