Sunday 28 March 2010

Connect to Internet using a Sony Ericsson K530i phone in Debian GNU/Linux via Bluetooth

Within this post we are going to explain how to connect to internet using a Sony Ericsson K530i mobile phone via bluetooth, in a Debian Sid system.

CONFIGURING OUR K530i PHONE


First step consists on configuring bluetooth settings in our phone.

Activate bluetooth in the phone:
Settings -> Connectivity -> Bluetooth -> Turn on

Set a name for your phone:
Settings -> Connectivity -> Bluetooth -> Phone name
We select a name for our phone, e.g: my_K530i

Make your phone visible to other bluetooth devices:
Settings -> Connectivity -> Bluetooth -> Visibility -> Show phone


INSTALLING BLUETOOTH SOFTWARE


We are going to install the bluetooth sofware we need:
# aptitude install bluez

Bluez package provides the tools and system deaemons we need to deal with bluetooth devices.

Right now I am using bluez version 4.60-1

BlueZ is the official Linux Bluetooth protocol stack.


CONFIGURING A BLUETOOTH CONNECTION


Now we will set a connection between our computer and the k530i phone.

List all bluetooth devices in our system:
$ hciconfig
hci0: Type: USB
BD Address: 00:1F:3A:79:CB:E0 ACL MTU: 1017:8 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:1059 acl:0 sco:0 events:34 errors:0
TX bytes:369 acl:0 sco:0 commands:28 errors:0

So we have a hci0 device up and running in our system.


We scan for external bluetooth devices:
$ hcitool scan
Scanning ...
00:1E:45:5A:FE:2E my_K530i

Scan command shows our phone name and mac.


We ping the phone to test it is alive:
$ l2ping 00:1E:45:5A:FE:2E


Show all available bluetooth services offered by our phone:
$ sdptool browse 00:1E:45:5A:FE:2E


We are interested in Dial-up Networking service (DUN):
Shows only Dial-up Networking service:
$ sdptool search --bdaddr 00:1E:45:5A:FE:2E DUN

We find which channel DUN service is associated to and will use it in rfcomm.conf settings.


EDITING rfcomm.conf CONFIGURATION FILE


We edit /etc/bluetooth/rfcomm.conf file:
#
# RFCOMM configuration file.
#

rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device
device 00:1E:45:5A:FE:2E;

# RFCOMM channel for the connection
channel 1;   # In my phone DUN device is associated to channel 1.

# Description of the connection
comment "K530i link";
}

MAKE EFFECTIVE OUR CHANGES


# /etc/init.d/bluetooth restart

If everything has gone fine, a /dev/rfcomm0 device will appear.


NOTE: If we would want to manually set up /dev/rfcomm0 device these are the commands you need
(You actually do not need them if you exec: #/etc/init.d/bluetooth restart)

# mknod -m 660 /dev/rfcomm0 c 216 0
# chown root:dialout /dev/rfcomm0
# rfcomm bind 0


PAIRING OUR BLUETOOTH DEVICES


bluetooth-agent program commes within bluez package. It will help us to pair our bluetooth devices. We execute it in a console. e.g:

$ bluetooth-agent 3333
# We set 3333 as the needed code to pair the devices. Select a code that suits you.


DIALING TO OUR 3G PROVIDER


We will use wvdial and pppd programs to configure and establish a ppp connection.
# aptitude install wvdial

Edit ~/.wvdialrc file:


Change this in your .wvdialrc file to suit your phone operator company:
[Dialer Masmovil]
Phone = *99***1#
Username = "masmovil"
Password = "masmovil"
Modem = /dev/rfcomm0
Baud = 460800
Stupid Mode = 1
Init1 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
Init5 =AT+CGDCONT=1,"IP","internetmas";



Execute wvdial to establish the connection:
$ wvdial Masmovil

First time the phone will ask us about "an unknown device trying to connect to the phone". We grant permission.
It will then ask us about accessing the phone services: We answer yes.
It asks for the pin: we enter 3333 (same as the bluetooth agent)

And connection will establish!!


When connected we will be able to see the connection:
$ hcitool con
Connections:
ACL 00:1E:45:5A:FE:2E handle 11 state 1 lm MASTER AUTH ENCRYPT


REFERENCE:


http://web.inter.nl.net/users/hanscees/bluezhowto.html
http://ornellas.apanela.com/dokuwiki/pub:linux_bluetooth_gprs


YOU MAY ALSO BE INTERESTED IN:


Connecting to Internet using a Sony Ericsson K530i mobile phone in Ubuntu (Linux) via USB cable.

0 comentarios: