To have Bluetooth devices inter-operable, different profiles exist: Hands-free (HFP), Object Push (OPP), File transfer (FTP), Dail-up Networking (DUN), Synchronization (SYNC) and Serial Port (SPP).
Bluetooth is well supported by Linux. Cheap sub miniature and bigger devices as D-Link DBT-122 work well. There is a bluetooth useflag so set it. Configure kernel as shown in the Gentoo Bluetooth guide (https://wiki.gentoo.org/wiki/Bluetooth and emerge net-wireless/bluez to get the stuff that not comes with the kernel. Then plug in the device so the new installed udev rules will handle it.
Start the Bluetooth daemon:
/etc/init.d/bluetooth start
See what the hciconfig finds:
hci0: Type: USB
BD Address: 00:19:5B:10:E7:81 ACL MTU: 1017:8 SCO MTU: 64:0
UP RUNNING PSCAN ISCAN
RX bytes:382 acl:0 sco:0 events:17 errors:0
TX bytes:318 acl:0 sco:0 commands:17 errors:0
The interface must be UP RUNNING. If not hciconfig hci0 up
The BD Address is the MAC address of your host device.
Edit /etc/bluetooth/pin
to give it a personalized id number,
that serves as a password when two bluetooth devices get paired. The run:
/etc/init.d/bluetooth restart
rc-update add bluetooth default
Look for active devices around (there is also a virtual device in the kernel)
hcitool scan
Scanning ...
00:1D:3B:82:1C:9D Nokia 2760
And notice the ID found.
Now do a ping and wait for 3 responses.
l2ping -c3 00:1D:3B:82:1C:9D
For debugging reasons packages can be captured emerge bluez-hcidump and run hcidump
Phones are quite different in what they support so:
sdptool browse 00:1D:3B:82:1C:9D | grep "Service Name" to see what it supports. When no response is received than it still supports something, but it is just unable to respond. Maybe it is a simple device as bluetooth headset.
As other bluetooth devices headsets (or bluetooth to audio converters) need to be paired as well. Therefore they need a pin. Devices as computer pop up windows where you can enter the pin. A headset however has no keypad and no display. Look at its manual where you should find the pin. Often pins as 0000 are used since it is not considered to do much damage with the headset device. However if you connect to somebodies headset device you might listen things that he is not aware. A2DP is the audio protocol that bluetooth uses.
After pairing it must be connected, to have this working the kernel must have the uinput module compiled Device drivers > Input device support > Miscellaneous devices > User level driver support that creates /dev/input/uinput (uinput is its module name when not included into the kernel)
The next step is that alsa needs to be aware about the new sound device. Create ~/asoundrc with
pcm.bluetooth { type bluetooth device 00:02:72:EE:B3:OC }
The restart bluethooth /etc/init.d/bluetooth restart and mplayer -ao alsa:device=bluetooth /usr/share/sounds/alsa/*
To connect devices, the application rfcomm can be used.
A configuration file /etc/bluetooth/rfcomm.conf
can hold the necessary settings so they do not have to insert at command line:
rfcomm0 { # Automatically bind the device at startup # Creates the device node, /dev/rfcomm0 at start up) bind yes; # Bluetooth address of the device you want to connect to device 00:1D:3B:82:1C:9D; }
then type rfcomm connect 0 to make use of the configuration file or type
rfcomm connect 0 00:1D:3B:82:1C:9D 1 to do the settings on the command line to connect to your device using channel 1
rfcomm should show now the device and the file /dev/frcomm0 should be created.
If it fails, verify by ls -l /dev | grep rfcomm if the file already exists. Some desktop bluetooth applications might get a hold of your host bluetooth device. Also a mismatch between the pins might occur, there is a pin under /etc/bluetooth/pin
, gnome desktop has and creates randomly pins and the phone itself has some pin.
Having the connection, different protocol might make use it. Phones highly differ in the protocols they support. There is a high chance that the phone understands some of the many AT commands.
To test it, a terminal as gtkterm can be used. However gtkterm fails if rfcomm0 is the only port, in this case use minicom -s to start minicom and go directly to its settings or plug in a USB RS232 adapter to make gtkterm happy.
If the connection is there type in at and ok
should come back. On Nokia phones type ati3 and Nokia 2760
the model number should come back.
emerge gnome-bluetooth to get common bluetooth support and emerge gnome-phone-manager to exchange messages. To exchange data with your phone emerge gnome-user-share then you should be able to set in System -> Preferences -> Personal File Sharing exchange data via bluetooth.
On Android phones the necessary bluetooth software might not be installed when it comes out of the box.