Bluetooth On Linux
Got myself a no-name Bluetooth USB dongle recently. I was quite
surprised that with Fedora Core 3, using the included BlueZ Bluetooth
stack, usage is actually quite smooth. Here's a few hints on how to
set things up and use them as proper documentation is still quite
sparse.
Hardware Considerations
Basic BlueZ Configuration
Obex
Mounting Symbian Devices
Outlook
Updates
Hardware Considerations
Frequently asked everywhere - which hardware should I choose if I
want to purchase a Bluetooth transceiver for my PC? Check the BlueZ Hardware List. In
general about 99% of all the no-name USB dongles out there contain the
CSR Chip (as of early 2005). Buy one of these cheapo-thingies and you
should be fine.
Basic BlueZ Configuration
- Make sure you have all the necessary parts of BlueZ
installed. You'll probably want these rpms:
- bluez-pin (PIN helper applciation)
- bluez-utils-cups (A CUPS backend to print to BT printers))
- bluez-hcidump (Debugging on the lower layer))
- bluez-utils (Core cmd-Line Utilities) )
- bluez-libs (Libs for BLuetooth applications))
- bluez-bluefw (Firmware loader for certain hardware)
- gnome-bluetooth (Gnome Integration))
- The kernel modules have to be loaded correctly, add the following
to /etc/modprobe.conf:
# General BlueZ Bluetooth Support:
alias net-pf-31 bluez
alias bt-proto-0 l2cap
alias bt-proto-2 sco
alias bt-proto-3 rfcomm
alias bt-proto-4 bnep
# for Bluetooth UARTs:
alias tty-ldisc-15 hci_uart
- Create a (typically 4-digit, numeric) secret PIN Code for your
system by e.g. putting 1234 into /etc/bluetooth/pin.
- Plug in your Bluetooth transceiver. In /var/log/messages
you should then be able to see the device being detected correctly,
such as:
kernel: Bluetooth: Core ver 2.7
kernel: NET: Registered protocol family 31
kernel: Bluetooth: HCI device and connection manager initialized
kernel: Bluetooth: HCI socket layer initialized
kernel: Bluetooth: HCI USB driver ver 2.7
kernel: usbcore: registered new driver hci_usb
- Start the bluetooth sub-system with /etc/init.d/bluetooth
start, /var/log/messages should yield:
hcid[10158]: Bluetooth HCI daemon
bluetooth: hcid startup succeeded
bluetooth: sdpd startup succeeded
hcid[10158]: HCI dev 0 up
hcid[10158]: Starting security manager 0
kernel: Bluetooth: L2CAP ver 2.6
kernel: Bluetooth: L2CAP socket layer initialized
kernel: Bluetooth: RFCOMM ver 1.3
kernel: Bluetooth: RFCOMM socket layer initialized
kernel: Bluetooth: RFCOMM TTY layer initialized
sdpd[10164]: Bluetooth SDP daemon
- You can now check that your BT device is correctly identified by
the Bluetooth stack with hcitool dev. You should see the
device's Address printed. Next, make sure your other Bluetooth device
is discoverable and try to discover it with hcitool inq. After
some searching, this should show your device and list it's address:
$ hcitool inq
Inquiring ...
00:60:57:8C:41:AA clock
offset: 0x660c class: 0x500204
- Next, try to ping your device by specifiying it's address with l2ping 00:60:57:8C:41:AA
- Finally you should pair your devices. Initiate this from your
remote device and when asked, enter the PIN that you've put into
/etc/bluetooth/pin.
NOTE: Dunno how to initiate pairing from Linux. Someone out there
could give me a pointer on this?
Obex
Obex (Object Exchange) is used to exchange files between 2
devices. This is what you know from IrDA as "beaming" a
file. openobex*.rpm has to be installed for that.
- To send a file from the command-line to another device, issue
obex_push <address> <file> where <address> is
the address of the remote device as found by hictool inq.
- To receive a file from another device via the command-line, you
need to download obexserver.c,
compile it, register the correct SDP service (for Nokia this is RfCOMM
channel 10) with sdptool add --channel=10 OPUSH and run your
compiled obexserver.
- To send a file from within Nautilus in GNOME to another device,
run Applications->System Tools->File Sharing. Then just
right-click on a file and Send via Bluetooth....
-
To receive a file from another device within GNOME, just make sure
that Applications->System Tools->File Sharing is running. Then
transmit the file from your other device and a pop-up should open
asking you what to do with the received file.
Mounting Symbian Devices
This is a beautiful little application for your Symbian device
(SonyEricsson, Nokia, Siemens, Samsung phones, Psion PDAs, among
others). It allows you to mount your device's file system directly
under Linux. That way you can e.g. directly access the memory card of
your phone and copy applications/data to it. To get this running:
-
Download p3nfs. Install the
correct nfsapp.sis to your Symbian device.
-
Bind RfCOMM channel 11 (which is used by nfsapp on your Symbian
device) by adding the following to /etc/bluetooth/rfcomm.conf (make
sure rfcomm0 is not defined yet, optionally use another rfcomm), then
restart the bluetooth daemons :
rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of _YOUR_ device, EDIT THIS!
device 00:60:57:8C:41:AA;
# RFCOMM channel for the connection
channel 11;
# Description of the connection
comment "My Symbian p3nfs connection";
}
-
Create a mount-point for your device, say /mnt/MyPhone
-
Start nfsapp on the Symbian device and switch to the Bluetooth
connection (with the joystick or jog-dial for smartphones).
-
On the Linux host, start the application with p3nfsd -series60 -dir
/mnt/MyPhone -tty /dev/rfcomm0 (note the parameters, see the man
page). Your device is now accesible in /mnt/MyPhone.
-
To stop the connection, do a ls /mnt/MyPhone/exit.
Outlook
Some things I'm planning to get set up and documented (I'd really
appreciate comments, pointers, hints,... on these topics):
-
GPRS dial-up with a mobile phone
-
SyncML a mobile phone's phone-book with Evolution
-
Audio connection to headsets.
Updates
Here's the ChangeLog of this page:
$Log: bluetooth.shtml,v $
Revision 1.3 2005/03/12 17:06:09 hajo
Added sections OBEX, Mounting Symbian Devices, Outlook
Revision 1.2 2005/03/12 16:11:42 hajo
Added Hardware & BlueZ Config
Revision 1.1 2005/03/12 13:53:04 hajo
Initial release