Tuesday, 3 June 2008

Downloading files from a cell-phone via Bluetooth

This is a guide for downloading files from a cell-phone to a linux pc from a terminal.
First thing to do is to activate a bluetooth adapter on both pc and a cellphone and make it visible and accessible. The necessery software must be installed too:
apt-get install obexftp bluetooth

First command is for scanning bluetooth enabled devices in range to get their address. Something like this:
tvrtko@tvrtko-laptop:~$ hcitool scan
Scanning ...
00:15:B9:9D:40:39 SGH-ZV10 t

Command for browsing appropriate channel for file transfers:
tvrtko@tvrtko-laptop:~$ sdptool browse 00:15:B9:9D:40:39
Browsing 00:15:B9:9D:40:39 ...
Service Name: QC Voice Gateway
Service RecHandle: 0x10000
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: QC Voice Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Handfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0101

Service Name: FTP
Service RecHandle: 0x10002
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 16
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100

Service Name: OPP
Service RecHandle: 0x10003
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 17
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Service Name: Serial Port
Service RecHandle: 0x10004
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 18
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)

Service Name: Dial-up Networking
Service RecHandle: 0x10005
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 8
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100


Our channel of interest is 16. Bellow Service Class ID List: "OBEX File Transfer" lines.

To browse files on a cellphone use the command to gat folder listing (in my case it is in XML format):
tvrtko@tvrtko-laptop:~$ obexftp -b 00:15:B9:9D:40:39 -c / -l
Browsing 00:15:B9:9D:40:39 ...
Channel: 16
Connecting...done
Sending ""... done
Receiving "(null)"...\

(folder listing here)

Disconnecting...done

And now, to download your newly taken photo you need to type command similar to this:
tvrtko@tvrtko-laptop:~$ obexftp -b 00:15:B9:9D:40:39 -c /Pictures -g Photo-0062.jpg
Browsing 00:15:B9:9D:40:39 ...
Channel: 16
Connecting...done
....
....

For uploading files use this command:
obexftp -b 00:15:B9:9D:40:39 -c /Pictures -p Photo-0063.jpg

NOTICE: Use right addresses, folder and filename specific for your cellphone

No comments: