1 I've been setting up a USB-bluetooth adapter so I can transfer files
2 between my phone and computer. You'll need kernel support (in
3 `menuconfig` look in `Networking ---> Bluetooth subsystem support`).
5 With a proper kernel, after plugging in your adapter you should see
13 l2cap 27398 16 bnep,rfcomm
15 bluetooth 42079 9 sco,bnep,rfcomm,l2cap,btusb
18 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
19 Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
20 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
21 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
22 Bus 003 Device 010: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
23 Bus 003 Device 011: ID 0a5c:4502 Broadcom Corp. Keyboard (Boot Interface Subclass)
24 Bus 003 Device 012: ID 0a5c:4503 Broadcom Corp. Mouse (Boot Interface Subclass)
25 Bus 003 Device 013: ID 0a5c:2154 Broadcom Corp.
27 Once you've got the kernel working, you should install [BlueZ][], the
28 userspace Bluetooth stack. On Gentoo, you'll want to enable the
29 `test-programs` USE flag (which brings in additional stuff like
30 `simple-agent`). Then run
32 $ sudo emerge -av net-wireless/bluez
34 This brings in a bunch of tools, among them `hcitool` and `hciconfig`.
35 Check that BlueZ finds your adapter with:
39 hci0 00:01:02:03:04:05
41 Put your phone in "discovery mode", and then detect it from the
46 00:0A:0B:0C:0D:0E Grayhat
48 Verify communication with:
50 $ sudo l2ping 00:0A:0B:0C:0D:0E
51 Ping: 00:0A:0B:0C:0D:0E from 00:01:02:03:04:05 (data size 20) ...
52 20 bytes from 00:0A:0B:0C:0D:0E id 200 time 69.85ms
53 20 bytes from 00:0A:0B:0C:0D:0E id 201 time 9.97ms
54 20 bytes from 00:0A:0B:0C:0D:0E id 202 time 56.86ms
55 20 bytes from 00:0A:0B:0C:0D:0E id 203 time 39.92ms
56 4 sent, 4 received, 0% loss
62 Make computer discoverable with:
64 $ sudo hciconfig hci0 piscan
66 which adds ISCAN to hciconfig's output.
68 To setup pairing, you should setup a pair pin by editing
70 $ cat /var/lib/bluetooth/00:01:02:03:04:05/pincodes
71 00:0A:0B:0C:0D:0E 12345
72 AA:AA:AA:AA:AA:AA 67890
73 $ /etc/init.d/bluetooth restart
75 where `00:01:02:03:04:05` is the address for your adapter (from
76 `hcitool dev`) and the file contains `addr pin` lines. You can get the
77 addresses of the pair devices with `hcitool scan` (discussed above).
78 After you edit the `pincodes` file, you'll have to restart the
81 $ sudo /etc/init.d/bluetooth restart
83 If you want to use `simple-agent` instead of mucking about in
84 `/var/lib/bluetooth`, usage looks something like
88 RequestPinCode (/org/bluez/16306/hci0/dev_00_0A_0B_0C_0D_0E)
91 where you start `simple-agent` and then initiate pairing from the
92 phone. After entering a pin on the phone, you will be prompted to
93 re-enter the pin by `simple-agent`.
95 Gentoo may need to be told that the cell phone is allowed to connect,
96 so create/edit `/var/lib/bluetooth/00:01:02:03:04:05/trusts`
98 $ cat /var/lib/bluetooth/00:01:02:03:04:05/trusts
99 00:0A:0B:0C:0D:0E [all]
101 which allows the phone to use any Bluetooth service provided by your
102 computer. It's possible that you can accomplish the same result with
105 $ sudo bluez-test-device trusted 00:0A:0B:0C:0D:0E yes
107 but I haven't been able to figure out the right syntax yet.
110 Pushing files from the phone
111 ============================
113 There are a number of OBEX push servers you can run on your box. My
114 favorite so far is [ObexPushD][], which is easy to use, GPLv2
115 licensed, and Git versioned. Can't beat that. I've added an ebuild
116 (`app-mobilephone/obexpushd`) to my [[Gentoo overlay]] for easier
120 Pushing files to the phone
121 ==========================
123 Check for an OBEX Push service on the phone:
125 $ sdptool search --bdaddr 00:0A:0B:0C:0D:0E OPUSH
126 Searching for OPUSH on 00:0A:0B:0C:0D:0E ...
127 Service Name: Object Exchange
128 Service RecHandle: 0x10003
129 Service Class ID List:
130 "OBEX Object Push" (0x1105)
131 Protocol Descriptor List:
136 Profile Descriptor List:
137 "OBEX Object Push" (0x1105)
140 Push a file to the phone using `ussp-push` (`net-wireless/ussp-push`)
142 $ ussp-push 00:0A:0B:0C:0D:0E@3 LFILE RFILE
144 which pushes the local `LFILE` to the remote `RFILE`.
146 Note that phone's can be finicky about what they accept. For example,
147 my Casio C721 is running BREW 3.x (see my [[Java ME]] post), and has a
150 * It attempts to detect file type by file extension (so you can't send
151 over a JPG with a `.jpeg` extension). It pops up an "Unsupported
152 Media" warning if you try.
153 * It does not accept music in any of the following formats: (AAC
154 (`.aac`), MP3 (`.mp3`), MP4/AAC (`.mp4`, `.m4a`), WAV (`.wav`).
155 * It does accept JPGs with a `.jpg` extension.
156 * It does accept VCARDs (with a `.vcf` extension), but they must have
157 DOS endlines (e.g. via `unix2dos`).
158 * If you include multiple VCARDs in a single file, it enters all the
159 information under the name from the first VCARD.
160 * If you send a VCARD whos name matches an already existing contact,
161 it leaves the first contact unaltered and creates a new contact
162 storing the VCARD information.
164 Both images and VCARDs should get pushed in without directory names.
165 Once the phone guesses the file type from the extension, it seems to
166 save the information in the appropriate place automatically.
172 Note: my phone doesn't support the Bluetooth's File Transfer Profile
173 (FTP), so I haven't been able to test the following commands.
175 With `sys-fs/obexfs` you can mount a phone with
177 $ sudo mount -t fuse obexautofs /tmp/mnt
179 When you're done, unmount with
181 $ sudo umount /tmp/mnt
183 `obexautofs` scans for available devices, so your device must be
184 visible (discoverable). If that's a pain, you can mount a specific
187 $ sudo mount -t fuse "obexfs#-b00:0A:0B:0C:0D:0E -B3" /tmp/mnt
189 Depending on your kernel, you may need to load the `fuse` module
190 before doing all of that:
198 Use `hcidump` (`net-wireless/bluez-hcidump`) to trace the bluetooth
205 A good deal of this information came from the more detailed [Gentoo
206 Bluetooth Guide][guide] and [Bluetooth Network Aggregation Point
210 [BlueZ]: http://www.bluez.org/
211 [ObexPushD]: http://www.gitorious.org/obexpushd
212 [guide]: http://www.gentoo.org/doc/en/bluetooth-guide.xml
213 [nap]: http://en.gentoo-wiki.com/wiki/Bluetooth_Network_Aggregation_Point