Biz & IT —

Using a Bluetooth phone with Linux

This short guide explains how to use Bluetooth to pair a mobile phone with a …

My old mobile phone, which was held together with duct tape for the last few months of its sad existence, has finally been replaced with something more modern. I wanted to pick up a programmable, Linux-based phone like the RAZR2V8 or the FIC Neo1973, but I'm unfortunately a Verizon customer, which means that my options are currently very, very limited—at least until Verizon follows through with its open network plans. I ended up grabbing a vx8550, which is Verizon's rebranded (and, of course, crippled) LG Chocolate. This is the first phone I have ever owned that actually has Bluetooth support, so I spent some time yesterday learning how to use Bluetooth on Linux. This is a short overview of what I discovered.

My desktop computer doesn't have built-in Bluetooth support, so I used a cheap USB Bluetooth adapter. I started by installing GNOME's Bluetooth tools. On Ubuntu, that is the gnome-bluetooth package. I also installed the gnome-vfs-obexftp package, which makes it possible to use GNOME's file manager to transfer files between your computer and a Bluetooth-enabled phone that supports the Object Exchange (OBEX) protocol.

After installing those packages, I plugged in my USB Bluetooth adapter, which caused a Bluetooth icon to appear in my Notification Area. I opened the Bluetooth Preferences dialog by right-clicking the icon and selecting Preferences. In order to pair the phone with the computer, I had to put the computer into discoverable mode. You can do that by changing the Mode of Operation setting to Visible and connectable for other devices. Then, on the handset, I navigated to the device's Bluetooth menu and selected the option to search for accessible Bluetooth devices. It found my desktop computer and asked me for a passcode. You can pick anything for the passcode, you just have to remember what you picked. At this point, the GNOME Bluetooth system on the desktop computer will pop up a notification informing you that a device is attempting to connect. To finish pairing the devices, click the notification bubble and type in the passcode. After pairing the phone with the computer, I opened up the Bluetooth Preferences dialog again and saw an entry in the Bonded Devices section for my mobile phone. I clicked the phone and then clicked the Set Trusted button.

Once the pairing is complete, it becomes possible to access files on the phone directly through Nautilus, the GNOME file manager. You can open any Nautilus window and type obex:// into the path bar to get a list of paired phones. Double-click the phone you want to access, and you should see a regular directory listing. You can now transfer files between your computer and your phone simply by dragging and dropping files. With this method, I was able to access the sounds, pictures, and videos stored on my phone.

Using Bitpim

Although the built-in support for OBEX file transfers in Nautilus is very easy to use, it doesn't provide full access to the device's file system and it doesn't provide a mechanism for accessing the phone's address book or calendar features. One can use the open-source Bitpim program to get more extensive access to the contents of the phone. In order to use Bitpim, you will either have to connect the phone to the computer with a USB cable or use Bluetooth RFCOMM serial emulation. For this tutorial, I will look at how to use Bluetooth with Bitpim.

Before you can use Bitpim with Bluetooth, you have to set up the Bluetooth serial service. In order to do this, you will have to set up the proper RFCOMM binding. Before you can do that, you have to get the MAC address of the phone and the channel used by the BT DIAG service. The easiest way to get the MAC address is through the Nautilus OBEX feature. If you use Nautilus to browse the contents of your phone, the MAC address will appear in the path bar and you can just copy and paste in subsequent steps where it is needed. Now that you have the MAC address, you need to get the BT DIAG channel. I do that from the command line with the sdptool. I also filter the output through the awk command so that I can get just the relevant information. Use this command to get the channel value, but pass it the MAC address of your own phone:

sdptool browse 00:1c:62:41:6c:89 | awk '/BT DIAG/,/^$/ {print $0 | "grep Channel"}'

That should show the channel number used by the BT DIAG service. For me, that number is 16. Now you need to use that number and the MAC address to to create an RFCOMM binding by editing the /etc/bluetooth/rfcomm.conf file. Add the following section, but use your MAC and channel values:

rfcomm0 {
bind yes;
device 00:1c:62:41:6c:89;
channel 16;
comment "Needed for Bitpim"
}

Now you have to restart your system's Bluetooth service so that the changes will take effect. On Ubuntu and other Debian-based systems you can do that with the following command:

sudo /etc/init.d/bluetooth restart

To enable serial services, open the Bluetooth Preferences dialog and check the Serial checkbox on the Services tab. That's all you have to do to set up the RFCOMM binding. The next step is configuring Bitpim.

Bitpim is available from the Ubuntu package repository, but if you are using a distribution that doesn't package it, you can grab some unofficial packages or a tarball directly from the Bitpim web site.

Bitpim is a pretty typical niche open-source application. It's extremely powerful and modular, but it's also hideously ugly and a little bit unstable. Warning: when you use Bitpim, keep in mind that it can be a bit fragile at times, and there is a very small chance that you could brick your phone if something goes terribly wrong.

After you launch Bitpim, select Settings from the Edit menu to open the preferences dialog. Select your phone in the Phone Type combobox or with the Phone Wizard. Next, click the Browse button next to the Com Port setting option to launch the Comm Port list dialog. Select the Bluetooth rfcomm0 option and click the OK button. If you don't see the Bluetooth option, it means that you did something wrong when you were setting up the rfcomm binding.

Now you can use the Get Phone Data item from the Data menu to retrieve the contents of your phone. This will give you access to the address book, memos, task items, SMS messages, calendars, and other items. You can also gain full access to your phone's file system by selecting Filesystem from the view menu and clicking the Filesystem item in the left-hand pane.

Keep in mind that not all phones are supported by Bitpim. My vx8550, for instance, is not supported at all yet. By using the vx8700 option, I was able to gain file system access, but I can't get any of the other things directly yet. Support for additional features for individual phones gets added in new versions, so if your phone is relatively new and isn't supported very well by Bitpim yet, keep an eye out for new releases.

MP3 ringtones

The vast majority of phones available from Verizon are severely crippled. Verizon will generally attempt to block access to any feature that doesn't provide them with a direct revenue stream. Despite the fact that the vx8550 is designed to be a portable music player, it doesn't permit users to set songs from their music library as ringtones. Fortunately, Bitpim makes it very easy to work around Verizon's avarice.

Using the file system interface in Bitpim, I was able to find the directory where ringtones are stored and add new ones myself. The exact location of this directory probably differs from one phone to another, but on my vx8550, it is /brew/mod/10899/ringtones. To add an MP3 ringtone to the phone, use Bitpim to copy it into that directory. When you turn the phone off and then back on, the files you add to that directory will be accessible from your ringtones menu. For MP3 ringtones, I recommend using a program like Audacity to snip down the MP3s so that they are about 30 seconds long or less before transferring them to the phone.

Videos

Like many modern phones, my new vx8550 has a built-in camera that can be used to make short videos. I used the camera to make a video which I then transferred to my computer via OBEX. Quick analysis of the video showed that it was MPEG-4 with AAC audio in a 3g2 container. It occurred to me that I could probably re-encode some video files into that format to make them playable on the phone. As an experiment, I took an Xvid file and encoded the first 120 seconds of it to create a new file that uses the same resolution and format as the video file created by the phone's camera. Then, I copied the new file over to the phone via OBEX. The pictures was very grainy, but it did actually work. I did the encoding with ffmpeg at the command line:

/usr/local/bin/ffmpeg -i input.avi -s 240x192 -r 11.988 -b 192 -ab 56 -t 120 -vcodec mpeg4 -acodec aac ~/output.3g2

Obviously these values might not work with other phones, but you can use the same method to figure out what bitrate, resolution, and formats to use for your own phone. The package of ffmpeg included with Ubuntu doesn't support certain file formats right out of the box for legal reasons. You may need to recompile ffmpeg with libmp3lame and other libraries enabled in order to reencode video.

Other tricks

I would have liked to experiment with phone software development, but Verizon unfortunately doesn't include Java on any of its handsets and only offers BREW for third-party development. As a platform, BREW appears to be extremely hostile to enthusiast development. For those of you who aren't trapped in Verizon hell, there are some pretty cool things you can do with Java apps. For instance, you can use a Bluetooth phone as a remote control for Amarok.

A lot of really good additional information can be dredged up in various places on the Internet, particularly the Howard mobile enthusiast forums. Some of the information in this tutorial isn't applicable to KDE users. Documentation for KDE's Bluetooth features is available from the KDE web site.

Channel Ars Technica