Howto: Using your mobile phone as a bluetooth modem

Octubre 4, 2009 por Jaime

Hello everybody!

It’s been a long time since I don’t write about any computer stuff so here I’m back again showing you how to use your mobile phone as a bluetooth modem under Linux. I needed it a couple of weeks back when I was travelling and wanted to be able to check my e-mail anywhere so I hope it seems usefull for you tu.

First of all a few important facts:

  • I’m using a Nokia N70 but it should work with almost any device
  • I’m using a Spanish SIMYO card
  • I’m running a Debian GNU/Linux SO with some required packages (bluez, bluez-utils, wvdial)

Altough the process should be quite simple (pair your computer with your phone and then use it) I found lot of troubles while pairing that I’ll show how to solve.

First of all you should check if your mobile phone supports acting like a bluetooth modem so do ’sdptool browse’ and look for something like “Dial-up Networking” (obviously have your bluetooth enabled in both PC and phone).


$> sdptool browse
Inquiring ...
Browsing 00:1C:9A:40:CB:BB ...

[...]

Service Name: Dial-Up Networking
Service RecHandle: 0×10017
Service Class ID List:
“Dialup Networking” (0×1103)
Protocol Descriptor List:
“L2CAP” (0×0100)
“RFCOMM” (0×0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0×454e
encoding: 0×6a
base_offset: 0×100
Profile Descriptor List:
“Dialup Networking” (0×1103)
Version: 0×0100
[...]

Okey, now lets pair both devices (here is where I found most of my problems) as none of the pages I found showed how to do it. Pairing means allowing a connection from PC to mobile phone or vicebersa.

Edit your ‘/etc/bluetooth/rfcomm.conf’ to assign a device (MAC) and channel, use which you get in the previous step.


Mirage:/home/kets# cat /etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#

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

# Bluetooth address of the device
device 00:1C:9A:40:CB:BB;

# RFCOMM channel for the connection
channel 3;

# Description of the connection
comment “DUN to use N70 as modem”;
}

Now let’s try to connect using ‘rfcomm connect rfcomm0′ which will prompt a message in your mobile phone to allow or deny the incoming connection and probably a PIN number.


Mirage:/var/lib/bluetooth/00:1F:3A:DB:1E:29# rfcomm connect rfcomm0
Can't connect RFCOMM socket: Connection refused

If you get this ‘Connection refused‘ even if you are allowing it and inserting correctly your PIN (the one specified in /etc/bluetooth/hcid.conf’), it means that you need a key agent. Anyway check your syslog to see if this is what it’s going wrong:


tail -f /var/log/syslog

Sep 20 16:45:58 Mirage bluetoothd[2993]: pin_code_request (sba=00:1F:3A:DB:1E:29, dba=00:1C:9A:40:CB:BB)
Sep 20 16:45:58 Mirage bluetoothd[2993]: No agent available for 0 request

So, this mean that what’s going wrong is that you insert any PIN in you phone and the computer doesn’t recognize it so it denies the connection request. If you have the ‘gnome-bluetooth’ package installed it is said that it should prompt a PIN code to insert the same PIN that you inserted in your phone but, at least for me, it’s not working. The solution? Use bluetooth-agent which sadly doesn’t have any man page so I had to do several tests in order to make it work.

What you have to do before trying to connect using ‘rfcomm’ is telling the bluetooh agent which PIN are you going to use, so run:


Mirage:/# bluetooth-agent 1234

And after that try to connect:


rfcomm connect rfcomm0

(write 1234 in your phone and … :) )

Connected /dev/rfcomm0 to 00:1C:9A:40:CB:BB on channel 3
Press CTRL-C for hangup

There you are!, you’ve finally paired your devices!. Now, the rest of the process is quite easy. Edit ‘/etc/wvdial.conf’ as following:


[Dialer SIMYO]
Modem = /dev/rfcomm0
Baud = 460800
Phone = *99***1#
Username =.
Password =.
Stupid Mode = on
Dial Command = ATDT
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","gprs-service.com"
Modem Type = Analog Modem
New PPPD = yes
ISDN = 0
Ask Password = 0
Compuserve = 0
Force Address =
Idle Seconds = 3000
DialMessage1 =
DialMessage2 =
Auto DNS = 1

You might have to make some changes if you’re using a different network operator like phone number, username, password and the Init3 part where here it says “grps-service.com”. For the first one contact your operator, and for the following check in your mobile phone: tools -> settings -> connection -> access points, and choose the one you’re using to see the correct values.

Now we’re done, just run ‘wvdial SIMYO’, wait until the negotiation finishes and enjoy checking your e-mail or surfing the web:


Mirage:/home/kets# wvdial SIMYO
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","gprs-service.com"
AT+CGDCONT=1,"IP","gprs-service.com"
OK
--> Modem initialized.
--> Idle Seconds = 3000, disabling automatic reconnect.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Fri Sep 25 00:12:36 2009
--> Pid of pppd: 9543
--> Using interface ppp0
--> pppd: ��[0c]
--> pppd: ��[0c]
--> pppd: ��[0c]
--> pppd: ��[0c]
--> local IP address 95.214.14.79
--> pppd: ��[0c]
--> remote IP address 10.6.6.6
--> pppd: ��[0c]
--> primary DNS address 195.230.105.134
--> pppd: ��[0c]
--> secondary DNS address 195.230.105.135
--> pppd: ��[0c]

That was all. Hope it helps :)

Si tuviera twitter…

Septiembre 22, 2009 por Jaime

Sé que tengo que contaros el viaje que he hecho por Galicia… y espero hacerlo en los próximos días…

De todos modos me apetece compartir con vosotros lo que sucede en este momento y a falta de tener una cuenta twitter os comento que ahora mismo:

Me encuentro haciendo la comida de mañana a dos fuegos (en uno se cuecen las judías, en el otro pocho cebolla), mientras tanto me tomo un zumo de tomate, consulto el correo y de fondo tengo a los Scorpios tocando “Will you send me an Angel?”

Simplemente me ha parecido una curiosa situación. ¡Sed felices!

Edito: Esto fue escrito a las 23.55 de la noche…

Me voy de vacaciones

Septiembre 15, 2009 por Jaime

Mañana, a las 8 de la mañana apróximadamente, pongo rumbo al noreste de España. Espero que ocurran cosas increíbiles en la tierra de las Meigas y que me acuerde de contároslas cuando vuelva.

Necesito salir ¡YA!. No es que haya estado de curro hasta arriba entre agosto y septiembre, pero llevo unos diítas que no paro. El lunes 21, si vuelvo con ganas, os cuento como ha ido. :)

Escalando

Septiembre 13, 2009 por Jaime

¡Hola de nuevo!

Como mi amigo Charly me acusaba en la última entrada de que solo hablo últimamente de drogas y alcohol, y que solo me falta hablar de sexo, pero como de eso estoy muy escaso últimamente, os vengo a contar mi úlitma aventura…

Como algunos sabéis soy aficionado a la escalada en interior búlder y siempre había querido iniciarme en la escalada en roca. Ya subí a medidados de verano a Escarilla (lo conté aquí) y me gustó mucho. Así, que el viernes repetí y subí con tres amigos (Sara, Bea y Kua) de nuevo a Escarrilla.

Llegamos el viernes a media tarde y en cuanto llegamos, recogimos la compra que llevábamos y nos fuimos directos a escalar. Estuvimos unas tres horas hasta que la lluvia decidió que era buen momento para que lo dejásemos y nos fuésemos para casa. Por el camino recogimos muchas moras, que luego servirían de ingrediente para un enerégitco batido. Cenamos, nos pusimos una peli, bebimos algunas cervezas y bien entrada la noche decidimos irnos a dormir.

El sábado amanecimos mucho más tarde de lo que esperábamos, así que un desayuno rápido y de nuevo a la montaña. Al principio estábamos todos un poco flojos y perezoso, pero conforme fue avanzando la mañana fuimos cogiéndolo con más ganas. Hubo alguna que otra caída, algo de miedo, muchas risas y yemas de los dedos destrozadas.

Sobre las tres volvimos para casa a comer. Luego un poco de sobremesa, un poco de tele, algún jueguecillo y a las 18 de vuelta para Zaragoza.

4 escaladores

4 escaladores

Cartas de Holanda

Agosto 31, 2009 por Jaime

Bueno, la verdad es que no suceden muchas cosas interesantes en mi vida y de ahí que actualice con poca frecuencia, dentro de poco intentaré volver a subir alguna cosilla relacionado con informática y demás, que tengo esos temas muy olvidados.

De momento, y a lo que viene el título. Es que hoy he recibido una carta desde aquel país. Ya llevaba un tiempo esperando y, empezaba a pensar, que se habrían “perdido” por el camino… ¿El contenido? Pues supongo que ya os imaginaréis: un par de postales preciosas :)

Cartas de Holanda

Cartas de Holanda

¡Gracias Sara!