Posts tagged ubuntu

Using Android to control Lego Mindstorms

This is a short post on the more entertaining side of Android showing a project that the Enea team in Linköping, Sweden, prepared for an expo. It is a one minute video from the demonstration.

It is two LEGO Mindstorms robots controlled by one HTC Hero Android phone. The Hero is running an Android application written by Enea Linköping that send motor commands to the LEGO brick. LEGO has been kind enough to put a Bluetooth chip in the Mindstorms NXT controller. By using the built in demonstrational Bluetooth commands the NXT brick provides there is no need for an application to be downloaded into the NXT brick.
There was however one obstacle in the limited Bluetooth support in Android OS version 1.5 (not supporting the Bluetooth serial port profile, SPP). Instead we used the wifi capabilities on the phone to send information to an Ubuntu Linux Laptop with a TCP/IP to Bluetooth tunnel (just a raw tunnel, no logic or programming). HTC has been rumored to be releasing Android OS version 2.1 (with Bluetooth) later in february and we hope to be able to put forth a new version that skip the WiFi laptop step.

Video below:

Android Bluetooth in Eclair


If you noticed the source code in Eclair branch, you will find few differences in Bluetooth function. There are three new git repositories for bluetooth. “bluez”, “glib” and “hcidump”, all of them are located in /external/bluetooth folder, not /external/bluez anymore.

bluez
android source: git://android.git.kernel.org/platform/external/bluetooth/bluez.git
Eclair is using bluez version 4.47 and the big difference would be bluez API. Since it has a lot of changes between bluez3 (android 1.6) and bluez4 (Android 2.0), we can tell from the documents in doc folder. Or we can use dbus-send to get the detailed information.

# dbus-send --system --type=method_call --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdaptermethod return sender=:1.2 -> dest=:1.3   object path "/org/bluez/932/hci0"

# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/932/hci0 org.freedesktop.DBus.Introspectable.Introspect


Also, bluetooth service name is changed in Eclair. It’s “bluetoothd” now. Check init.rc in /system/core/rootdir.

service bluetoothd /system/bin/bluetoothd -d -n    socket bluetooth stream 660 bluetooth bluetooth    socket dbus_bluetooth stream 660 bluetooth bluetooth    # init.rc does not yet support applying capabilities, so run as root and    # let bluetoothd drop uid to bluetooth with the right linux capabilities    group bluetooth net_bt_admin misc    disabled

glib

android source: git://android.git.kernel.org/platform/external/bluetooth/glib.git
When we build bluez library, it would build glib as a static library.
GLib provides the core application building blocks for libraries and applications written in C. It provides the core object system used in GNOME, the main loop implementation, and a large set of utility functions for strings and common data structures. If you are interested in how bluez use glib, you can trace bluez source code.
new Bluetooth API
http://developer.android.com/guide/topics/wireless/bluetooth.html
About Bluetooth, Android website has a very good document. It lists the functions and example code.
Bluetooth    * Turn on/off Bluetooth    * Device and service discovery    * Connect to a remote device using RFCOMM and send/receive data    * Advertise RFCOMM services and listen for incoming RFCOMM connection

Bluetooth Chat application
What I am curious? It’s related to using RFCOMM and send/receive data. In the beginning, I am not quite understand and I thought it’s OBEX. After running Bluetooth Chat application, I know what it means now. I installed 0xlab experimental eclair image in Beagle board and installed Bluetooth chat example from Android. I also run a python script in my ubuntu machine and it’s from pybluez. Then, I can chat between Beagle board and my laptop via Bluetooth. When we start to run Bluetooth Chat application, it would create a RFCOMM socket and set it to listen mode. We can retrieve the information from sdptool. Then other BT devices can connect to Android using RFCOMM protocol and set channel to the same one.
# sdptool browse localBrowsing FF:FF:FF:00:00:00 ...Service Name: BluetoothChatService RecHandle: 0x10005Service Class ID List:  UUID 128: fa87c0d0-afac-11de-8a39-0800200c9a66Protocol Descriptor List:  "L2CAP" (0x0100)  "RFCOMM" (0x0003)    Channel: 30

From Collages

Easily Install Android On A Netbook

Android Theme for Ubuntu Linux

Android Theme for Ubuntu Linux | Ubuntu Themes | Android Themes | GNOME GTK Themes: “Do you love Android devices and cellphones, and you want the same look on your Ubuntu desktop? You can have your Ubuntu Linux desktop look like Android OS, with matching icons, background and wallpapers.”

My vim for android devlopement environment

I haven’t blogged for a long time, and I would have liked to be able to blog about my Gnome soc project, but unfortunately, I have other priorities. As part of my studies, I had to do some development for the android platform, and since the last summer, I can’t use other development environment than Vim, I decided to find a way of using it for my android project.

So here is the description of my Vim environment for android applications development. I use vim 7.2, the version distributed with Ubuntu 9.10, the Vjde plugin, terminator as a terminal (which by the way is a great terminal emulator!!) and then last android JDK in order to develop application for android2.0 (eclaire).

First I installed the SDK (there are a few bugs on the emulator installation due to this bug and an this ssl problem. I fallowed this guide to set the sdk. Then, I installed the Vjde plug-in which is a Vim plug-in to get a Java development environment in Vi, this plugin permit to add intelligent completion for methods calls as well as for imports (You only need to unzip this in you ~/.vim directory). Afterward, you create your your android project (this page explains well how to do it). And then you need to create an vjde project, in vim:

:Vjdeas filename.prj

This is actually a text file which permit to save variables to you project. Then I set it Vjde to look at android class, methods and package, in vim:

:let g:vjde_lib_path='/path/to/android/sdk/platforms/android-2.0/android.jar:build.classes'

And save it

:Vjdesave

Thanks to it, I can have functions/imports completion available with the CTRL-X+CTRL-U key combination (I need to load the project(:Vjdeload filename.prj) every time I want to work on it, I think there must be a way of doing it automatically but didn’t figure it out yet). It would also be possible to get the documentation integration thanks to the Vjde plugin, but I am used to have it in another window.

Then to try the program on the android emulator, I lunch the emulator, and in a terminal:

ant debug && adb install -r bin/yourAppName-debug.apk

You can then launch it in the android emulator menu (I looked for a way of lunching the program directly from the command line, but didn’t find :( ). To debug the app, you can launch the ddms tool which is part of the android sdk.

I hope this could be useful for some people who want to develop for the android platform and don’t want to use eclipse or netbeans IDE.