Monday, February 1, 2010

New Bluetooth Object Push Profile in Android 2.0 (Eclair)

From Android developer website, they said Android 2.0 provides two new Bluetooth profiles: Object Push Profile (OPP) and Phone Book Access Profile (PBAP). Seeing is believing. Where is the meat? ha, I found they finally released their Bluetooth application source code. Therefore, I tried to verify OPP in Beagle board. :D

As usual, I read Build-from-Scratch wiki page and download code from 0xdroid project with beagle-eclair branch. LIke beagle-donut, I can use USB mouse, keyboard, mount a SD sdcard, use USB networking, and then I turn Bluetooth on. It's very easy to set up the working environment with 0xdroid.

Check Bluetooth application source code and install it in Beagleboard

cd packages/apps
git clone git://android.git.kernel.org/platform/packages/apps/Bluetooth.git
cd Bluetooth
git checkout -b eclair remotes/origin/eclair
git pull
source ../../../build/envsetup.sh
mm
adb install ../../../out/target/product/beagleboard/system/app/Bluetooth.apk


Trace related log
When we saw the log like below, it means it provides OPP service in RFCOMM channel 12 and PBAP service in RFCOMM channel 19.

I/bluedroid( 736): Starting hciattach daemon
I/bluedroid( 736): Starting bluetoothd deamon

I/bluetooth_ScoSocket.cpp( 797): Listening SCO socket...
V/BtOpp Service( 933): Service onCreate

V/BtOpp Service( 933): Starting RfcommListener in 9 seconds
V/BtOpp Service( 933): Service onStartCommand

V/BluetoothPbapService( 933): Pbap Service onCreate
V/BluetoothPbapService( 933): Starting PBAP service
V/BluetoothPbapService( 933): Pbap Service onStartCommand

D/BluetoothService( 736): Registering hfag record
D/BluetoothService( 736): Registering opush record
D/BluetoothService( 736): Registering pbap record

V/BluetoothPbapService( 933): Handler(): got msg=1
V/BluetoothPbapService( 933): Pbap Service startRfcommSocketListener
V/BluetoothPbapService( 933): Pbap Service initSocket
V/BluetoothPbapService( 933): Succeed to create listening socket on channel 19

V/BtOpp Service( 933): start RfcommListener
V/BtOpp Service( 933): RfcommListener started
I/BtOppRfcommListener( 933): Accept thread started on channel 12


Receiving and sending out data via Bluetooth

Currently, it only accepts few media types, like image, video, audio, text/plain and text/html and it should have the extension name. It cannot accept vcard and vcalendar. But we can modify few lines in 'Bluetooth/src/com/android/bluetooth/opp/Constants.java ', then it can store vcard files. One more problem, there is no matched application can view *.vcf file. I guess I can reference with previous beagle-donut code to fix it. All incoming files are stored in /sdcard/bluetooth folder. Also, there is a db file to record all Bluetooth application actions.

# cd /sdcard/bluetooth
# ls
08042009068.jpg
08042009068-1.jpg

# cd /data/data/com.android.bluetooth/databases
# ls
btopp.db
# sqlite3 btopp.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .tables
android_metadata btopp
sqlite> select * from btopp;
1||08042009068.jpg||image/jpeg|1|00:18:C5:42:18:78|1|1|493|394450||946685154325|0
2|content://media/external/images/media/1|08042009068.jpg|/sdcard/bluetooth/08042009068.jpg|image/jpeg|1|00:18:C5:42:18:78|1|1|200|394450|394450|946685200379|1
3||olv.vcf|/sdcard/bluetooth/olv.vcf|text/x-vcard|1|00:18:C5:42:18:78|1|1|200|68|68|946685305125|2
4|file:///sdcard/bluetooth/08042009068.jpg|08042009068.jpg||image/jpeg|0|00:18:C5:42:18:78|1|2|200|394450|394450|946685368037|0
5||btopp_vcard.vcf|/sdcard/bluetooth/btopp_vcard.vcf|text/x-vcard|1|00:22:A5:B8:AD:65|1|1|496|168||946685701894|0
6||btopp_vcard.vcf|/sdcard/bluetooth/btopp_vcard.vcf|text/x-vcard|1|00:22:A5:B8:AD:65|1|1|200|168|168|946685806848|2
7||08042009068.jpg||image/jpeg|1|00:18:C5:42:18:78|1|4|490|394450||946698435289|0
8||08042009068.jpg||image/jpeg|1|00:18:C5:42:18:78|1|4|490|394450||946698501841|0
9|content://media/external/images/media/1|08042009068.jpg|/sdcard/bluetooth/08042009068.jpg|image/jpeg|1|00:18:C5:42:18:78|1|1|200|394450|394450|946698554454|1
10|content://media/external/images/media/2|08042009068-1.jpg|/sdcard/bluetooth/08042009068-1.jpg|image/jpeg|1|00:18:C5:42:18:78|1|1|200|394450|394450|946698717592|1
11|file:///sdcard/bluetooth/08042009068-1.jpg|08042009068-1.jpg||image/jpeg|0|00:22:A5:B8:AD:65|1|2|495|394450|0|946698901473|0
12|content://media/external/images/media/2|08042009068-1.jpg||image/jpeg|0|00:18:C5:42:18:78|1|2|200|394450|394450|946699019695|0


Screenshots from beagle-eclair

* Turn Bluetooth On
* Pair with Nokia N73 phone
* Receive an image from N73 to Beagle board via BT
* Send an image from Beagle board to N73 via BT

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.