Android Bluetooth Demo

I couldn’t let user “tri” have all the fun, so in response to his Windows phone app, I wrote an Android Bluetooth demo. (Full disclosure: User tri is my brother - we have a bit of a competition going on :smiley: )

http://youtu.be/pvdnxDOuSSg

The controller app is running on my Samsung Galaxy Note 3 and I wrote it using Android Studio on Mac OS X. I don’t have the nifty RC-style widget tri has, but I added buttons to control most basic Sparki features. Sparki pretty much behaves the same as if I were controlling him out of the box with the IR remote.

Thanks to tri’s sketch and some Google Android Bluetooth examples, I was off to a good start. I did run issues connecting the two devices and found that you need to know Sparki’s Bluetooth module’s UUID in order to communicate with it. I was able to get it while debugging my code and inspecting the BluetoothDevice instances.

private final String UUID = "00001101-0000-1000-8000-00805f9b34fb";

private void connect(BluetoothAdapter adapter) {
    final String NAME = "ArcBotics";
    Set<BluetoothDevice> devices = adapter.getBondedDevices();
    for (BluetoothDevice device : devices) {
        if (NAME.equals(device.getName())) {
            // use "device" below
        }
    }
    if (!found)
        Log.e(TAG, "Could not connect because device " + NAME + " was not found");
}

// ...

BluetoothSocket socket = device.createRfcommSocketToServiceRecord(UUID.fromString(UUID));

Like tri, I also paired my phone to Sparki using the “ArcBotics” device with code “0000”.

Very good GetRoot. This should be more useful to folks seeing that Android is 78% of the phone market share while Windows Phone is only 3.2%. :unamused:

http://www.latinpost.com/articles/7356/20140215/ios-vs-android-windows-phone-market-share-2013-google-smartphones.htm