DSL Tips and Tricks :: How to transfer files to/from DSL via Bluetooth



This is part 3 of the DSL Bluetooth how-to. In order to proceed from here, you will need to have Bluetooth up and running on your DSL machine and be able to "pair" with a Bluetooth mobile phone as described in part 1 - see post " How to start Bluetooth & Pair with a remote device"

In order to transfer files to/from your mobile phone over a Bluetooth connection, you need to first discover which channel(s) your phone uses for this. Apparently the channel number changes from manufacturer to manufacturer and even from model to model. The service discovery protocol daemon does not always appear to start automatically, so you may need to start this before checking for the file transfer channels - note that the output has been edited to only show what we are looking for:

# sdpd
# sdptool browse 00:0A:D9:E8:4A:65 [put your phone bt address here]
Browsing 00:0A:D9:E8:4A:65 ...
...
Service Name: OBEX Object Push
Service RecHandle: 0x1000e
Service Class ID List:
 "OBEX Object Push" (0x1105)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
   Channel: 2
 "OBEX" (0x0008)
Profile Descriptor List:
 "OBEX Object Push" (0x1105)
   Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x1000f
Service Class ID List:
 "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
   Channel: 3
 "OBEX" (0x0008)

Now we know file transfer is on channels 2 and/or 3, we can configure bt communications ports in order to transfer files to/from the phone. Note that the devices may not exist in DSL so we will need to create them - this seems to work best when you create them after configuring them:

# rfcomm bind 2 00:0A:D9:E8:4A:65 2 [leading 2=rfcomm2, trailing 2=OBEX Push]
# rfcomm bind 3 00:0A:D9:E8:4A:65 3 [leading 3=rfcomm3, trailing 3=OBEX Transfer]

# mknod -m 666 /dev/rfcomm2 c 216 2
# mknod -m 666 /dev/rfcomm3 c 216 3

Now the ports are created, we need to register the services:

# sdptool add --channel=2 OPUSH
OBEX Object Push service registered
# sdptool add --channel=3 FTRN
OBEX File Transfer service registered

Now we need to load the various OBEX packages from Debian stable:

# apt-get install obexftp
# apt-get install obexserver
# apt-get install openobex-apps

According to Google, there are several ways to transfer files but I could not get all of them to work:

1. Using the obex test application

To send a file from your phone to DSL machine. Note that ff:ff:ff:00:00:00 is used as the address of the DSL machine and the file will be received in /tmp

# obex_test -b ff:ff:ff:00:00:00 2 [only the OBEX push channel (2) will work]
Using Bluetooth RFCOMM transport
OBEX Interactive test client/server.
> s [now enter the "send file over bluetooth" command on your phone]
connect_server()
Server request finished!
server_done() Command (00) has now finished
Made some progress...
Made some progress...
put_server()
put_server() Found name
put_server() Skipped header c3
put_server() Skipped header 42
put_server() Skipped header 44
put_server() Found body
Filename = m_Impossible.mid
Wrote /tmp/m_Impossible.mid (1288 bytes)
Server request finished!
server_done() Command (02) has now finished
We got a disconnect-request
Server reque st finished!
Disconnect done!
> <ctrl-c>

To send a file from your DSL machine to the phone. The file appears in the "beamed" folder on my phone and either the OBEX push or OBEX file transfer channels can be used

# obex_test -b 00:0A:D9:E8:4A:65 3 [enter your phone bt address here]
Using Bluetooth RFCOMM transport
OBEX Interactive test client/server.
> c
Connect OK!
Version: 0x10. Flags: 0x00
> p /tmp/m_Impossible.mid m_Impossible.mid
PUT file (local, remote)> name=/tmp/m_Impossible.mid, size=1288
Going to send 1288 bytes
Made some progress...
PUT successful!
> <ctrl-c> [phone only ackowledges file receipt after this]


2. Using the obexftp application

Note that I could only get this to work in one direction - from the DSL machine to the phone:

# obexftp -b 00:0A:D9:E8:4A:65 --channel 3 -p /home/dsl/acpid.lst [two "dashes" before "channel"]
Browsing 00:0A:D9:E8:4A:65 ...
Channel: 3
No custom transport
Connecting...bt: 1
done
Sending /home/dsl/acpid.lst... failed: /home/dsl/acpid.lst
Disconnecting...done

Despite the error message, the file was successfully received on the phone.

3. Using obexserver

I could not get this to work at all...


That's it - have fun (and now to work on mounting the phone as an obexfs).

A quick update to the how-to now that I compiled the bluetooth extension as bluez-utils.uci:

The obexserver and obex_test applications seem to have been depreciated in openobex-1.1, but obexftp-0.18 works in both directions (get & put) - I just submitted an updated extension with both added.

It no longer seems necessary to specify the bluetooth channel to transfer files, so to send files to a bluetooth device:
Code Sample
$ obexftp -b 00:0A:D9:E8:4A:65 -p /home/dsl/Events
Browsing 00:0A:D9:E8:4A:65 ...
Channel: 3
Connecting...done
Sending "/home/dsl/Events"... done
Disconnecting...done

- and to list the files on a bluetooth device and get one of them:
Code Sample
$ obexftp -b 00:0A:D9:E8:4A:65 -l
Browsing 00:0A:D9:E8:4A:65 ...
Channel: 3
Connecting...done
Receiving "(null)"...\<?xml version="1.0"?><!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd"><folder-listing version="1.0"><file name="m_Impossible.mid" size="1288" modified="20070106T211955" user-perm="R" group-perm="R"/><file name="m_Impossible(1).mid" size="1288" modified="20070111T153833" user-perm="R" group-perm="R"/></folder-listing>done
Disconnecting...done

$ obexftp -b 00:0A:D9:E8:4A:65 -g m_Impossible.mid
Browsing 00:0A:D9:E8:4A:65 ...
Channel: 3
Connecting...done
Receiving "m_Impossible.mid"...done
Disconnecting...done
- the file is saved in the current folder


original here.