What is OBEX?#
OBEX (abbreviation of OBject EXchange, also termed IrOBEX) is a communications protocol that facilitates the exchange of binary objects between devices. It is maintained by the Infrared Data Association but has also been adopted by the Bluetooth Special Interest Group and the SyncML wing of the Open Mobile Alliance (OMA). OBEX is very similar in design and function to HTTP. It’s a client-server type. One device is a server and it waits for any connections. The other device is a client and it requests to send a file to the server.
How to use OBEX via bluetooth in Android?
There are some popular open source projects and they have implemented OBEX protocol. I choose openobex, obexpushd, obexftp applications, and I made some changes to allow them to run in Android. Therefore, I put these source code here.
openobex ##
The original source code is from here and I am using version 1.5. This project is to make an open source implementation of the Object Exchange (OBEX) protocol. OBEX is a session protocol and can best be described as a binary HTTP protocol. OBEX is optimised for ad-hoc wireless links and can be used to exchange all kind of objects like files, pictures, calendar entries (vCal) and business cards (vCard).
obexpushd ##
The original source code is from here and I am using version 0.7. Obexpushd can be used to receive files with OBEX protocol over Bluetooth, IrDA (infrared) or network connection.
obexftp ##
The original source is from here and I am using version 0.23.
The main goal of this project is to make mobile devices that feature the OBEX protocol and that adhere to the OBEX FTP standard accessible using an open source implementation.
build ##
Download the source code from gitorious and put them into /mydroid/external directory. Another detailed document about building is here.
eg. openobex
- cd ~/mydroid/external/openobex
- . ~/mydroid/build/envsetup.sh
- mm
install ##
use adb + usb cable to push a binary file to Android Dev phone
% adb push ~/mydroid/target/product/dream/system/xbin/obexpushd /system/xbin/obexpushd
Examples
Run an OBEX data server in Android, use adb shell to Android Dev phone terminal
su(use root account)
cd /sdcard(change dir to sdcard and launch obex data server here)
obexpushd(it will store incoming files to /sdcard dir and run in backgournd)
or
obexpushd -n -d(it will store incoming file to /sdcard dir and not run in backgound, display debug message)
When it launchs an OBEX data server in Android, it would broadcast “OBEX Object Push” service from SDP server. If you use other BT devices to search OBEX service, it can discover Android Dev phone. Once you make a paired connection, you can send files to Android Dev phone via bluetooth. It will automatically store files to sdcard.
Make Android Dev phone as a client, use ‘adb shell’ to Android Dev phone terminal
This is an example, I send a mp3 file from Android phone to a NOKIA N73 mobile phone.
su (use root account)
hcitool scan (scan all near by bluetooth device)
Scanning …
00:18:C5:42:18:78 Erin-Nokia N73
sdptool search FTP (search near by BT device with FTP service)
cd /sdcard
obexftp -b 00:18:C5:42:18:78 -B 11 —list (list folder information)
obexftp -b 00:18:C5:42:18:78 -B 11 -cE: -p 01.Breakaway.mp3 (send a MP3 song to NOKIA phone)
obex_test -b 00:18:C5:42:18:78 11 (send obex text file to NOKIA phone)
Using Bluetooth RFCOMM transport
OBEX Interactive test client/server.
> c (create connection)
Made some progress…
Server request finished!
server_done() Command (00) has now finished
Timeout waiting for data. Aborting
> p (push a file)
PUT file (local, remote)> /sdcard/obex
test (write a subject name)
name=/sdcard/obex, size=3423
Going to send 3423 bytes
Made some progress…
Made some progress…
Made some progress…
Made some progress…
Server request finished!
server_done() Command (02) has now finished
Timeout waiting for data. Aborting
> q (leave it)

