Thursday, March 19, 2009

Bluetooth, GPRS mobile phone with Debian GNU/Linux

Setup walkthrough/guide for Bluetooth on Debian GNU/Linux, make your laptop/desktop communicate with your mobile phone, and use the latter as a modem to connect to the Internet.

In this article, Sony Ericsson K750i is being used as an example, which should however be applicable to most of the current available mobile phones in market.

Here it is focused on the Bluetooth connection only, you can easily replace it with an IRDA connection, or use the USB cable provided with your phone , although it is tried for any of these alternatives with Sony Ericsson K750i mobile phone.

I believe that the reader is already used to PPP connections using pppd, and all the examples will be based on Orange mobile phone provider.

Setting up Bluetooth on Debian GNU/Linux (Lenny/Etch/Sid)

The bluez project goal is to make an implementation of the Bluetooth wireless standards specifications for GNU/Linux. On Debian, you need to install the bluetooth meta-package, which will automatically the required dependencies/packages.

When inserting a Bluetooth USB-adapter, you should check these entries in the logs:


usb 1-2: new full speed USB device using uhci_hcd and address 2
usb 1-2: configuration #1 chosen from 1 choice
Bluetooth: HCI USB driver ver 2.9
usbcore: registered new interface driver hci_usb

If you are a GNOME user and need to install the bluez-gnome package, you should be able to see the bluetooth icon in the notification area. A right click on this icon will give you access to the options (visibility, connectivity etc.).

Communicationg with a mobile phone over a bluetooth connection

You should now be able to communicate with the phone.

Run hcitool scan and check that your phone name appears in the device list:

$ hcitool scan
Scanning ...
00:1B:59:2F:5E:E1 K750i

With nautilus-sendto, you can send files from your laptop to the mobile phone:
nautilus-sendto.png
Make sure the phone is visible to other devices.

To send a file from the phone to the computer, you need to install the deprecated gnome-bluetooth package, avialble from repository.

gnome-bluetooth.png

After starting gnome bluetooth, and making the computer visible (edit the preferences from the bluetooth applet), you will be able to transfer files from your mobile phone to the laptop.

Using the modem

Setting up rfcomm device

Edit /etc/bluetooth/rfcomm.conf as follows ( use your favorite editor, I use Emacs) :

rfcomm0 {
bind yes;
device 00:1B:59:2F:5E:E1;
channel 1;
comment "Example Bluetooth device";
}

Where:

  • the device is what you can see thanks to hcitool
  • the channel is the number referring asthe “Dial-up Networking” service when running sdptool browse

After restarting the bluetooth service, you will have a new /dev/rfcomm0 device which you will use a the modem device in the pppd configuration files.

GSM connection

A GSM connection will allow 9,600 bps, but can be usefull if you are out of the GPRS network.
Simply create a new connection with the newly created device as modem device. I would suggest you use the pppconfig to create the ISP connection.

GPRS connection

Thanks to GPRS, you can reach the speed of 56 Kbps. For information only, Edge allows 247 Kbps and UMTS 384 Kbps.

Before trying to connect from your laptop, please be sure you are able to connect to GPRS from your mobile phone.
If you haven’t yet configured your mobile phone, most of the providers have the settings available publicly on their website.

Note that Orange requires a free option to be activated (this is automatically done if you are a new subscriber). Also pay attention to your SIM card which should be GPRS aware .

Here is the configuration file I use to connect to Orange:

hide-password
noauth
connect "/usr/sbin/chat -f /etc/chatscripts/orange-gprs"
/dev/rfcomm0
57600
defaultroute
user "orange"

ipparam orange-gprs
idle 300

# most of the phones don't answer to LCP echo requests
lcp-echo-failure 0
lcp-echo-interval 0

usepeerdns
noproxyarp
noccp
novj
nobsdcomp
novjccomp
nopcomp
noaccomp

# pppd must not propose any IP address to the peer!
noipdefault

# Accept peers idea of our local address
ipcp-accept-local

# Ignore carrier detect signal from the modem
local

Here is the chat script:

# ispauth chat
# abortstring
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIALTONE' ABORT 'NO ANSWER' ABORT DELAYED
# modeminit
'' ATZ
OK-AT-OK 'ATD*99***1#'
# ispconnect
CONNECT \c

The phone number is very important. The last digit must be the external ID of the GPRS profile setup in your mobile phone. This seems to be closely tied to Orange, but if you can’t connect, contact your provider to get a valid dialing sequence.

You can test the connection running pon orange-gprs. Debugging can be improved by adding a nodetach option in the configuration file. Also add a line debug debug debug to increase the verbosity.

No comments: