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 You can also initiate pairing from your computer with
97 $ simple-agent hci0 00:0A:0B:0C:0D:0E
99 Gentoo may need to be told that the cell phone is allowed to connect,
100 so create/edit `/var/lib/bluetooth/00:01:02:03:04:05/trusts`
102 $ cat /var/lib/bluetooth/00:01:02:03:04:05/trusts
103 00:0A:0B:0C:0D:0E [all]
105 which allows the phone to use any Bluetooth service provided by your
106 computer. It's possible that you can accomplish the same result with
109 $ sudo bluez-test-device trusted 00:0A:0B:0C:0D:0E yes
111 but I haven't been able to figure out the right syntax yet.
114 Pushing files from the phone
115 ============================
117 There are a number of OBEX push servers you can run on your box. My
118 favorite so far is [ObexPushD][], which is easy to use, GPLv2
119 licensed, and Git versioned. Can't beat that. I've added an ebuild
120 (`app-mobilephone/obexpushd`) to my [[Gentoo overlay]] for easier
124 Pushing files to the phone
125 ==========================
127 Check for an OBEX Push service on the phone:
129 $ sdptool search --bdaddr 00:0A:0B:0C:0D:0E OPUSH
130 Searching for OPUSH on 00:0A:0B:0C:0D:0E ...
131 Service Name: Object Exchange
132 Service RecHandle: 0x10003
133 Service Class ID List:
134 "OBEX Object Push" (0x1105)
135 Protocol Descriptor List:
140 Profile Descriptor List:
141 "OBEX Object Push" (0x1105)
144 Push a file to the phone using `ussp-push` (`net-wireless/ussp-push`)
146 $ ussp-push 00:0A:0B:0C:0D:0E@3 LFILE RFILE
148 which pushes the local `LFILE` to the remote `RFILE`.
150 Note that phone's can be finicky about what they accept. For example,
151 my Casio C721 is running BREW 3.x (see my [[Java ME]] post), and has a
154 * It attempts to detect file type by file extension (so you can't send
155 over a JPG with a `.jpeg` extension). It pops up an "Unsupported
156 Media" warning if you try.
157 * It does not accept music in any of the following formats: (AAC
158 (`.aac`), MP3 (`.mp3`), MP4/AAC (`.mp4`, `.m4a`), WAV (`.wav`).
159 * It does accept JPGs with a `.jpg` extension.
160 * It does accept VCARDs (with a `.vcf` extension), but they must have
161 DOS endlines (e.g. via `unix2dos`).
162 * If you include multiple VCARDs in a single file, it enters all the
163 information under the name from the first VCARD.
164 * If you send a VCARD whos name matches an already existing contact,
165 it leaves the first contact unaltered and creates a new contact
166 storing the VCARD information.
168 Both images and VCARDs should get pushed in without directory names.
169 Once the phone guesses the file type from the extension, it seems to
170 save the information in the appropriate place automatically.
176 Note: my phone doesn't support the Bluetooth's File Transfer Profile
177 (FTP), so I haven't been able to test the following commands.
179 With `sys-fs/obexfs` you can mount a phone with
181 $ sudo mount -t fuse obexautofs /tmp/mnt
183 When you're done, unmount with
185 $ sudo umount /tmp/mnt
187 `obexautofs` scans for available devices, so your device must be
188 visible (discoverable). If that's a pain, you can mount a specific
191 $ sudo mount -t fuse "obexfs#-b00:0A:0B:0C:0D:0E -B3" /tmp/mnt
193 Depending on your kernel, you may need to load the `fuse` module
194 before doing all of that:
202 Use `hcidump` (`net-wireless/bluez-hcidump`) to trace the bluetooth
209 A good deal of this information came from the more detailed [Gentoo
210 Bluetooth Guide][guide] and [Bluetooth Network Aggregation Point
214 [BlueZ]: http://www.bluez.org/
215 [ObexPushD]: http://www.gitorious.org/obexpushd
216 [guide]: http://www.gentoo.org/doc/en/bluetooth-guide.xml
217 [nap]: http://en.gentoo-wiki.com/wiki/Bluetooth_Network_Aggregation_Point