How to transfer files via bluetooth on Linux

Written by
Date: 2007-11-08 10:36:30 00:00

Today I have bought a cheap Msi Star Key Bluetooth USB DongleUSB Bluetooth dongle, and start working to download my pictures from my cellular to my Linux PC.

It is actually not difficult and here is how.

Install the software

apt-get install obexftp bluetooth

Connect your cellular to your PC

Connect the Dongle to your PC it should be recognized immediately, Now on your cellular scan for new devices, once you have found your PC try to connect to it, both your cellular and your PC will ask for a password, choose any (4 digits) but the same on both.

With this there is a trusted relationship between the cellular and the PC.

Scan for your cellular address

hcitool scan

you should have something like this.

Scanning ...
    00:16:20:60:7C:36       K510a

Search for the appropriate channel for file transfers

sdptool browse 00:16:20:60:7C:36

You will see something like this:

Browsing 00:16:20:60:7C:36 ...
Service Description: Sony Ericsson K510
Service RecHandle: 0x10000
Service Class ID List:
  "PnP Information" (0x1200)

Service Name: OBEX SyncML Client
Service RecHandle: 0x10001
Service Class ID List:
  UUID 128: 00000002-0000-1000-8000-0002ee000002
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
  "OBEX" (0x0008)

Service Name: Dial-up Networking
Service RecHandle: 0x10002
Service Class ID List:
  "Dialup Networking" (0x1103)
  "Generic Networking" (0x1201)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100

Service Name: Serial Port
Service RecHandle: 0x10003
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3

Service Name: HF Voice Gateway
Service RecHandle: 0x10004
Service Class ID List:
  "Handfree Audio Gateway" (0x111f)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 4
Profile Descriptor List:
  "Handsfree" (0x111e)
    Version: 0x0101

Service Name: HS Voice Gateway
Service RecHandle: 0x10005
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 5
Profile Descriptor List:
  "Headset" (0x1108)
    Version: 0x0100

Service Name: OBEX Object Push
Service RecHandle: 0x10006
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 6
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10007
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 7
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100

Service Name: OBEX IrMC Sync Server
Service RecHandle: 0x10008
Service Class ID List:
  "IrMC Sync" (0x1104)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 8
  "OBEX" (0x0008)
Profile Descriptor List:
  "IrMC Sync" (0x1104)
    Version: 0x0100

Service Name: NAP service
Service Description: NAP description
Service RecHandle: 0x10009
Service Class ID List:
  "Network Access Point" (0x1116)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 15
  "BNEP" (0x000f)
    Version: 0x0100
    SEQ8: 0 6 dd
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Network Access Point" (0x1116)
    Version: 0x0100

Service Name: Mouse & Keyboard
Service Description: Remote Control
Service Provider: Sony Ericsson
Service RecHandle: 0x1000a
Service Class ID List:
  "Human Interface Device" (0x1124)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 17
  "HIDP" (0x0011)
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Human Interface Device" (0x1124)
    Version: 0x0100

Look for this:

Service Name: OBEX File Transfer

and below you will find the right channel in my case is 7.

Once you have all of this, you can start browsing, getting and putting files from/to your cellular.

Browse your cellular's files

You will now use obexftp command

First get the tree of directories.

obexftp -b 00:16:20:60:7C:36 -c / -l

This command will access the cellular of the given address the “/” (root) directory and will list its contents, something like this:

Browsing 00:16:20:60:7C:36 ...
Channel: 7
Connecting...done
Sending ""... done
Receiving "(null)"...  XML Coder, Mar  9 2006, 03:09:28, (C) 2001 Sony Ericsson Mobile Communications AB

folder-listing version="1.0" folder name="Pictures"
folder name="Sounds"
folder name="Themes"
folder name="Videos"
folder name="Other"
folder-listing
done
Disconnecting...done

Download files

obexftp -b 00:16:20:60:7C:36 -c /Pictures -g picture1.jpg

Upload Files

obexftp -b 00:16:20:60:7C:36 -c /Pictures -p file.jpg