Tuesday, October 16, 2007

HOWTO mobile phone, Bluetooth and GNOME


I've just successfully installed Bluetooth support and managed to connect my SonyEricsson T630 mobile phone. Since there's a lot of information on the web about Bluetooth under Linux but I couldn't find a Gentoo-specific tutorial I decided to write one. I hope this tutorial is generic enough so that it's useful to people with other hardware, too. Fortunately, Bluetooth virtually works out of the box with Gentoo using stable packages only!

My hardware:

  • i386 system (Athlon)
  • Kernel 2.4.25 (gentoo-sources)
  • Abe UB20 Bluetooth USB dongle
  • SonyEricsson T630
  • GNOME (sorry, haven't tried command line tools or KDE)

What I wanted to do (read: what's covered in this tutorial):

  • Get Linux to recognize my Bluetooth dongle
  • Get Linux to detect my mobile phone
  • Transfer images and sounds to my mobile and back again

What I haven't done yet (and thus isn't covered here):

  • Establish a dial-up connection using Bluetooth and my mobile phone
  • all the other fancy Bluetooth stuff that might be possible (networking and so on)

Okay, let's start, shall we?

Configure kernel for Bluetooth support

Like USB or FireWire you should have the latest kernel drivers for bluetooth. If you're using a previous version your mileage may vary. Also, make sure that USB hotplugging is working as it won't be covered in this tutorial. I assume it's already working for you. Go to /usr/src/linux and make menuconfig to set up Bluetooth. You may compile the features into the kernel but I used modules. Works well and saves you from recompiling the whole kernel. First, go to USB support and make sure that USB Bluetooth support is disabled. (at least for kernel 2.6:) Enable OHCI or UHCI USB support depending on your Hardware (refer to lspci). Then, go to "Bluetooth support" and at least select the following options:

Linux Kernel Configuration: Bluetooth support
 Networking -->
Bluetooth subsystem support -->
L2CAP protocol support
RFCOMM protocol support
[*] RFCOMM TTY support
Bluetooth device drivers --->
HCI USB driver

RFCOMM is not necessary but you may want to enable it, however, if you get the following error message "Can't create device: Operation not permitted" or to prevent it.

Exit, Save your configuration and do make modules modules_install && modules-update.

And don't forget to (if you have compiled bluetooth as a module) modprobe bluetooth.

Emerge the packages

[added by xanda]

If you are using GNOME, you can just do:

USE="bluetooth" emerge -av gnome-bluetooth

as it will pull in all required packages. If you do NOT have GNOME you should install the following packages:

USE="bluetooth" emerge -av bluez-utils openobex obexftp

If you have a broadcom bluetooth device (eg, the Belkin F8T001), you should install bluez-firmware.

Make sure "bluetooth" is in your USE or the openobex wont work

Attach the dongle

There's a lot of Bluetooth hardware available, but as long as it's a USB device, you won't have to do more than connect it to a USB port now. Type dmesg to see if your dongle has been recognized by Linux. It should print something like this:
# dmesg
hub.c: new USB device 00:07.3-1, assigned address 2
usb.c: USB device 2 (vend/prod 0x400/0x807) is not claimed by any active driver.
usbdevfs: USBDEVFS_CONTROL failed dev 2 rqt 128 rq 6 len 18 ret -6
BlueZ Core ver 2.3 Copyright (C) 2000,2001 Qualcomm Inc
Written 2000,2001 by Maxim Krasnyansky
BlueZ HCI USB driver ver 2.4 Copyright (C) 2000,2001 Qualcomm Inc
Written 2000,2001 by Maxim Krasnyansky
usb.c: registered new driver hci_usb
usbdevfs: USBDEVFS_CONTROL failed dev 2 rqt 128 rq 6 len 18 ret -6
usbdevfs: USBDEVFS_CONTROL failed dev 2 rqt 128 rq 6 len 18 ret -6
usbdevfs: USBDEVFS_CONTROL failed dev 2 rqt 128 rq 6 len 9 ret -6
usbdevfs: USBDEVFS_CONTROL failed dev 2 rqt 128 rq 6 len 18 ret -6
Look for the "BlueZ" lines. They're telling you that your dongle has been recognized as a USB HCI device. In my case, the kernel modules have been loaded automatically. This might not be the case for everyone. See this site (link busted) on how to edit your /etc/modules.conf if necessary. Keep in mind though, that editing modules.conf directly is not the Gentoo way. Read the man page of modules-update for more.

Start the Bluetooth device

At the console, type "hciconfig" to see the Bluetooth HCI device that has been installed. There should be a hci0 device but it should be marked "DOWN".
# /etc/init.d/bluetooth start
This will start Gentoo's Bluetooth init script. Now, call hciconfig again.
# hciconfig
hci0: Type: USB
BD Address: 08:00:17:1B:42:96 ACL MTU: 339:4 SCO MTU: 60:9
RX bytes:5603 acl:177 sco:0 events:209 errors:0
TX bytes:40682 acl:270 sco:0 commands:30 errors:0
The device is active now as can be seen by "UP RUNNING" in line 3. if the device appears as DOWN, you simply have to run:
# hciconfig hci0 up

If you want to start Bluetooth at boot time, add the script to the default runlevel:

# rc-update add bluetooth default

Let's detect the phone

The "hcitool" command line tool allows you to scan your environment for bluetooth devices. Make sure that your phone is switched on and Bluetooth is enabled. Then type:
# hcitool dev
hci0 08:00:17:1B:42:96
That was your local device. Nothing special here.
When scanning for your phone, be sure that your phone is in "discoverable" mode. This is usually found in the Bluetooth menu as "Find Me" or similar.
# hcitool inq
Inquiring ...
00:0E:07:37:7C:BD clock offset: 0x7080 class: 0x520204
# hcitool scan
Scanning ...
00:0E:07:37:7C:BD T630
Yay! That's my cell phone! "T630" is the factory's default name. You can change that on your cell phone of course.

Use GNOME to transfer stuff to your mobile

If you've emerged gnome-bluetooth, the fun has just begun. I'm running the yet masked GNOME 2.6. If you're still running 2.4 things are hopefully the same. First, no need to be root anymore. Log into GNOME as a regular user and open a terminal. Type "gnome-bluetooth-admin" (in GNOME 2.8 type gnome-bluetooth-manager) to launch the GUI version of hcitool.
Click "Scan" and after a while your mobile phone should appear. (see this Screenshot (116 kB))
Next, launch Nautilus and browse to "bluetooth:///". Marvel at the icon depicting your cell phone! You might be tempted to double click on it but this won't work. Instead, you need to drag&drop files onto the icon to transfer them to your mobile phone. In case that "bluetooth:///" doesn't work, try right clicking the file you want to send and select "Send via bluetooth ...".
Background images for the T630 are JPEG images with a size of 128x127 pixels. Use the gimp to create an image yourself or go to sites like http://www.mobile-arsenal.com.ua to get all the backgrounds you need. You're not limited to images. For example, ".thm" files are themes and they can be transfered as well. Midi files (.mid) are used as ring tones. Here are two examples to get started:
Shortly after you've dropped a file onto the icon, your mobile phone should pop up a dialog asking you to accept the incoming file. Do this quickly or Nautilus will time out after a few seconds. If you accept the incoming transfer, the file is uploaded to your phone and stored in the appropriate location of your mobile phone's memory. Go to your pictures folder to see the image or go to "Settings" -> "Display" -> "Themes" to select the new theme.

[added by xanda]

Newer version of gnome-bluetooth (0.8 and above) don't have "gnome-bluetooth-admin" or "gnome-bluetooth-manager" and GNOME (2.10 and above) wont recognize "bluetooth:///" when u type it in your Nautilus. What you should do is first, scan available device(s)

# hcitool scan
Scanning ...
00:0E:07:37:7C:BD T630
and now you can use gnome-obex-send to send your file to your mobile phone
gnome-obex-send --dest 00:0E:07:37:7C:BD /home/xanda/your-file.jpg

Use KDE to browse your mobile phone

Alternatively, you may use KDE to connect to your phone. KDE allows you to browse the contents of your mobile phone. If you don't have konqueror installed, do it
emerge konqueror
and then, emerge kdebluetooth
emerge net-wireless/kdebluetooth
Now, start kbluetoothd. Open a console and type
You'll then have a new protocol available in konqueror (bluetooth:///) from where you can browse the contents of your phone. Just open a konqueror window and type bluetooth:/// in the location bar.

6600.com link title

Using your cellphone as remote control for xmms (tested on: Sony Ericsson T630, T610, K700i, K800i, W810)

If you have included RFCOMM protocol support and RFCOMM TTY support into your kernel you are able to configure your cellphone to function as a remote control for xmms. In order to do so, you first need to emerge xmms-btexmms as a plugin.
emerge xmms-btexmms
Now you have to establish the connection between your pc and your cellphone.
You do this by issuing the command rfcomm connect 0 . of course must be replaced by the actual device id of your mobilephone.
rfcomm connect 0 00:0E:07:42:ED:B2
Connected /dev/rfcomm0 to 00:0E:07:42:ED:B2 on channel 1
Press CTRL-C for hangup
In order to find out this device id you have to run hcitool as follows:
hcitool scan
Scanning ...
00:0E:07:42:ED:B2 Momesana

If you did not read the paragraph above yet: read it to find out how to set your PIN. k700i 9988

Now that the connection is established you must start xmms. It must be restarted if it was already running before the connection was made. Every time you reconnect the pc and cellphone you have to also restart xmms in order for it to work properly. Now you have to go to the Options > preferences > General Plugins and configure your BTE Control Plugin. You have to edit the Device Inputline to point to your rfcomm device. On a devfs filesystem it is somewhat like /dev/bluetooth/rfcomm/0. On udev you will find it as /dev/rfcomm0 etc. Feel free to make a symlink to it with a more suitable name such as /dev/phone. This is optional. Remember to then set your device config option in the above mentioned xmms config dialog to /dev/phone.

Now activate the plugin by checking the checkbox at the right bottom of the dialog.

ln -s /dev/rfcomm0 /dev/phone

Now enable your xmms plugin. On a Sony Ericsson cellphone you now can go to connectivity > accessories and select the xmms plugin. To find out about the keys and their function take a look at the config dialog of the plugin under xmms. If you receive an Error like "Can't open RFCOMM device: No such file or directory" as regular user (i.e. not root) and you are using udev, that indicates that your permissions are not correctly set. Since udev creates and deletes device files on demand you have to put the desired permissions in a config file residing under /etc/udev/permission.d. There is probably already a file named "50-udev.permissions". Don't edit this file! Instead create a new file that starts with a lower number, since this will override the settings set in the previously mentioned file. You may for example create a file called "10-udev.permissions" with your favourite editor (I use vi ;) ):

vi /etc/udev/permissions.d/10-udev.permissions

In that file you define the permissions as follows:


For >udev-056:

# vi /etc/udev/rules.d/10-local.rules

KERNEL="rfcomm[0-9]*", NAME="dialout/%k", GROUP="dialout", MODE="0660"

For >udev-070 the line above should read:

KERNEL=="rfcomm[0-9]*", NAME="%k", GROUP="dialout", MODE="0660"

The above configuration assumes that you belong to the dialout group. If you define a group you do not belong to, you will of course continue getting the error message. The first column rfcomm* means that all device files residing under /dev that start with rfcomm followed by a letter or digit are owned by root (second column -- defining the owner of the file) and belong to the group dialout (third column). The collon functions as a separator. With the above setting root and any member of the dialout group can create /dev/rfcomm, thus being able to use btexmms. You may choose another group and of course you can set other permissions. To enable everybody to use btexmms you may for example change the above permission from 0660 to 0666. Good luck and have fun!

Upload files and manage your SMSes / phonebook (tsemgr)

This program installs with a simple emerge command:

emerge tsemgr -av

It should support connections through serial cable / IR / Bluetooth, but so far I only just tested connection through serial cable. If you use a USB cable, set this in the 'config' pane:

  • Device: /dev/ttyUSB0

I used a SE DSS-20 usb cable (well, desktop stand actually, whatever) and a T630 phone. Unfortunately, the upload files functionality doesn't work for me. (it ends in a segmentation fault) Better luck for you! ;-)

Tsemgr works on bluetooth with a T-610. It also has features to create a "bluetooth remote control" by allowing you to launch predefined commands.

The development of tsemgr has stopped.

Bemused (Only on Nokia Symbian S60 and Nokia S40 with Java Phones)

Works on most, if not all Nokia S60 Phones... and J2ME phones (a lot of Nokia S40 phones) with Bemused J2ME

This is a method for controlling xmms using a Nokia cellphone with Bluetooth and Java. It involves the bemused application being installed on the cellphone and a second part bemusedlinuxserver installed on your computer. To do this, download from bemused.sourceforge.net, unzip and then send bemused.sis (or bemused_full.sis) to your cellphone using either the Gnome or KDE transfer methods described above.

On the computer where your music is stored, type :

emerge bemused

You may need to unmask it.

echo "app-mobilephone/bemused" >> /etc/portage/package.keywords
emerge bemused

After bemused is installed on your computer, simply type bemusedlinuxserver in a console to run the server.
It will automatically start xmms. Now run Bemused on your phone and connect to your computer when it asks you to.

Its config file is located at /etc/bemused.conf Its recommended to modify the mp3dir variable to suit your main mp3 folder.

If youre like me, just modify the config file to disable xmms autostart, and add a small script to run bemusedlinuxserver in the autostart folder to start bemused as soon as your desktop loads...

Phones it has been reported to successfully work on :

  • Nokia 3650
  • Nokia 6021
  • Nokia 6230i
  • Nokia 6280
  • Nokia 6680
  • Nokia 6600
  • Nokia 6670
  • Nokia 6630
  • Nokia 6680
  • Nokia 6820
  • Nokia 7610
  • Nokia 7650
  • Nokia E65
  • Nokia N-Gage
  • Nokia N70
  • Nokia N90
  • Sony Ericsson P900
  • Sony Ericsson K610i
  • Sony Ericsson K800i
  • Sony Erricson w550i
  • Sony Erricson w810i
  • Sony Ericsson w850i
  • Sony Ericsson z550i
  • Siemens SX-1
  • Motorola SLVR L7

(please add your phone to this list if it works satisfactorily on your phone)

Freevo Bluetooth Plugin

Freevo is a "Digital video jukebox (PVR, DVR)". Think MythTV/PlutoHome. There is a plugin avalible for Freevo that lets you use your cellphone as a remote. This uses RFCOMM and an AT/T (Hayes) command that sends all keypresses over the line to your computer. Most Symbian OS phones have this feature. Reported to work with Sony Ericsson T610, T65, Motorola E398 and a few Siemens phones. Download the plugin from the Freevo page (Downloads -> Plugins). Complete instructions is included with the plugin! Also, if you got a Nokia Series 60 phone, check out PlutoHome, their cellphone remote is cool.

Sending SMS with your Mobile Phone

First of all, you have to emerge the Gnome Phone Manager

emerge gnome-phone-manager

Start it (as a normal user) and go to "Preferences -> Connection". Choose bluetooth and click on "Choose" to select a mobile phone. Make sure your mobile is in "Discoverable" mode and click on scan. gnome-phone-manager should now find your mobile. Select it and click "OK". You mobile will now ask for a code (PIN) - simply type any code (eg. 1234). Just one second later, gnome-phone-manager will ask you for a code - type in the same one. Now your mobile is connected. Maybe it's a good idea to set "Automatically retry connections". If you connection is not stable (you can see that by looking on the symbol in your notification area), restart gnome-phone-manager (I needed to do so). After reconnecting, you should be able to send SMS, by simply right-clicking on the icon in the notification area and selecting "Send Message".

I tested this with a Motorola RAZR and a Samsung X11. Sending worked, however SMS were only received on the mobile phone (I wouldn't want to receive them on the notebook anyway...).

Please report here, if it worked with your mobile-phone / PC / notebook:


  • Samsung X11
  • HP dv6135nr with Belkin USB Bluetooth dongle
  • Acer Travelmate 8106lmi
  • HP 6910p

Mobile Phones:

  • Motorola RAZR
  • Samsung SGH-T509
  • Samsung SGH-X680
  • Samsung SGH-X820
  • Sony Ericsson T630
  • Sony Ericsson T610
  • Sony Ericsson Z520a
  • Sony Ericsson K750i
  • Nokia 6300

Resources used and thanks to

That's it! Here's another screenshot showing how smoothly everything works: Screenshot (142 kB)
I hope you've found this tutorial useful, even if you don't own a USB dongle and a T630. However, the process should be the same for other modern mobile phones. Just look for the right kind of images and themes suitable for your phone. Here are some links to pages that were useful to me:

No comments: