page.title=Bluetooth pdk.version=1.0 doc.type=porting @jd:body

In this document

Android's Bluetooth stack uses BlueZ as the host stack.

Bluez is GPL licensed, so the Android framework interacts with userspace bluez code through D-BUS IPC to avoid proprietary code.

The qualification notes mentioned below are example qualifications of the particular device in question. Each company has to re-qualify their product with Bluetooth SIG even if no changes are made to the Bluetooth stack.

Headset and Handsfree (v1.5) profiles are implemented in the Android framework and are both tightly coupled with the Phone App. Profiles like OPP and PBAP are based on java obex. These profiles open a rfcomm socket connection into Bluez kernel bypassing the Bluez userspace stack.

Profiles like A2DP, AVRCP, HID, PAN and other bluetooth functionality like pairing and scanning use the Bluez userspace stack.

The diagram below offers a library-oriented view of the Bluetooth stack. Click Bluetooth Process Diagram for a process-oriented view.

Solid elements represent Android blocks and dashed elements represent partner-specific blocks.

Porting

BlueZ is Bluetooth 2.1 compatible and should work with any 2.1 chipset and is backward compatibile with older Bluetooth versions. There are two integration points:

UART Driver

The BlueZ kernel sub-system attaches to your hardware-specific UART driver using the hciattach daemon.

For example, for MSM7201A, this is drivers/serial/msm_serial.c. You may also need to edit command line options to hciattach via init.rc.

Bluetooth Power On / Off

The method for powering on and off your bluetooth chip varies from Android V 1.0 to post 1.0.

Compiling

To compile Android with Bluetooth support enabled, add the following line to BoardConfig.mk.

BOARD_HAVE_BLUETOOTH := true

Troubleshooting

Debugging

To debug your bluetooth implementation, start by reading the logs (adb logcat) and look for ERRROR and WARNING messages regarding Bluetooth. Andoird uses Bluez, which comes with some useful debugging tools. The snippet below provides examples in a suggested order:

hciconfig -a  			# print BT chipset address and features. Useful to check if you can communicate with your BT chipset.
hcidump -XVt  			# print live HCI UART traffic.
hcitool scan  			# scan for local devices. Useful to check if RX/TX works.
l2ping ADDRESS  		# ping another BT device. Useful to check if RX/TX works.
sdptool records ADDRESS # request the SDP records of another BT device.

Deamon Logs

Deamon logs for bluetoothd (STDOUT) and hciattach (STDERR) are sent to /dev/null by default. Edit init.rc and init.PLATFORM.rc to run these daemons under logwrapper, which redirects output to logcat.

hciconfig -a and hcitool

If you compile your own system.img for Android, and hciconfig -a works but hcitool scan doesn't, try installing the firmware for the Bluetooth chipset. This firmware isn't yet available in the open source codebase, but you can adb pull and then adb pushit from a stock T-Mobile G1 (located in /etc/firmware/brf6300.bin).

Tools

BlueZ provides a rich set of command line tools for debugging and interacting with the Bluetooth sub-system, including:

Feature Support

This section provides a change history of Bluetooth features added in each Android release and provides some rough guidance as to future features.

Android 1.0 release

Platform features
Qualifications for HTC G1 product. Each company reusing this software version has to re-qualify with Bluetooth SIG
Example products

 

Android 1.1 release

No Bluetooth changes since 1.0

 

Android 1.5 release (cupcake)

Platform features

Qualifications for HTC Sapphire product. Each company reusing this software version has to re-qualify with Bluetooth SIG

Android 2.0/2.1 release (eclair)

Platform features

Android 2.2 release (Froyo)

Platform features

Android 2.3 release (Gingerbread)

Platform features

Android 3.0 release (Honeycomb)

Platform features

 

Future releases

This section offers a rough guide of which features the team is developing for the next release. This feature list may change without notice. It isn't possible to post scheduling advice to the mailing lists.