[Geek] How-to set up a fake chinese Nokia 5230 as a GPRS Modem with Viettel under Ubuntu 10.04

So, a post in English, because it’s technical and has almost nothing to do with my trip… But it has to be written somewhere, so I won’t forget (and I searched to long on the internet without finding any infos about it)…
I thought that my (very) old Nokia phone got stolen in China in Chengdu. Actually, it wasn’t. I just switched it off and I put it in the bottom of my backpack when I woke up because I was not really awake… That’s why I bought a new one in Kunming. In order to be a little bit autonomous for Internet access, I tried to find one that could act as a GPRS Modem and have access to Internet by itself.
I went in a little shop, and I bargained 1 hour long with Chinese people who didn’t spoke a word of French/English/German, to find something like this. Finally I got a fake Nokia 5230 for 35€.
It started around 80€, and I managed to get this price, because they weren’t able to show me a working Internet connection with it. More over, I tested the Bluetooth connexion, with my computer in the “shop”, and it didn’t worked as a GPRS Modem at this time. I said, OK, I don’t want this phone, and the price dropped again. I think the price was OK. If someone has experience with buying fake mobile phones in China, let me know…
So, after that, I got the phone to work with his web browser in the evening without doing anything. I think that the activation of the GPRS access on the SIM card was just taking ages… I have no idea how the girl in the shop activated the GPRS with China Mobile. Now, let’s look about how to use it in Việt Nam

Activating GPRS with a Viettel SIM Card.

I bought a SIM Card from Viettel for 65000 Đongs. After some search on Internet I found some method to activate the GPRS with viettel. Everything is in Vietnamese, so I had to try a lot, but at the end, it worked by sending the following sequence of SMS to 191 :

  1. DK : This should send you some information about the different prices. I didn’t understood really, but I choosed the D25 which should cost 25.000 Đ, for a 125MB limit of transfer. I didn’t knew really what I was doing, So I took something not really expensive. If you want to get 3G, send DK 3
  2. D 25 : this is to choose the price range.
  3. D TENMAY : this is to get the configuration for your phone. They propose to send D PhoneModel (TÊN means Name), like D N5320 for my Nokia 5320. But when I was doing that, It didn’t worked. I guess the config for a 5320 doesn’t work for a fake one :). So the most standart worked for me.

Then It worked from the phone to access Internet with the very shitty browser included. (But I could install a Opera Mini on it, so it’s better now).
To configure it manually, the APN name is “v-internet“, no username, no password.

Make it work as a GPRS Modem

When I plug the phone with the USB cable, I get a menu on the phone proposing me 4 connexion types :

  1. Mass storage (to access the onboard memory (500 kB) and the mini-SD card)
  2. COM Port (that what we’ll use later)
  3. Java Connexion (didn’t tried now)
  4. MTP (Music Transfer Protocol) : does not work for the moment.

When I choose the COM Port connexion, the kernel detects automatically a /dev/ttyACM0 device. It’s drived by the cdc_acm module.

[  986.021994] cdc_acm 3-1:1.1: ttyACM0: USB ACM device
[  986.024912] usbcore: registered new interface driver cdc_acm
[  986.025151] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters

Automatically, the modemmanager detects it and the network-manager proposes to create a Mobile broadband connexion to use it.
Wonderfull, but it didn’t worked. The network-manager directly complains about “disconnected from GSM network”.
After searching a little bit, I installed gnome-ppp and wvdial to try to make it work.
gnome-ppp (and most of the wvdial.conf config files I found on Internet) was configuring the modem with the following AT initialisation command :

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 FCLASS=0

It doesn’t work. By sending it with a gtkterm/minicom to /dev/ttyACM0 you get directly an ERROR reply from the phone.
Finally, I got it work by removing the FCLASS=0 from the init.
So, basically, the following /etc/wvdial.conf works for me :

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2
Init4 = AT+CGDCONT=1,”IP”,”v-internet”
Password = pass
Phone = *99#
Modem Type = USB Modem
Stupid Mode = 1
Baud = 460800
New PPPD = yes
Dial Command = ATDT
Modem = /dev/ttyACM0
ISDN = 0
Username = user
Init1 = ATZ

Then, just starting wvdial from the command line :

root@1001PX:/etc# wvdial
–> WvDial: Internet dialer version 1.60
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
–> Sending: AT+CGDCONT=1,”IP”,”v-internet”
AT+CGDCONT=1,”IP”,”v-internet”
OK
–> Modem initialized.
–> Sending: ATDT*99#
–> Waiting for carrier.
ATDT*99#
CONNECT
~[7f]}#@!}!}!} }2}”}&} }*} } }#}$@#}’}”}(}”U[03]~
–> Carrier detected.  Starting PPP immediately.
–> Starting pppd at Mon Jan 10 13:44:16 2011
–> Pid of pppd: 25123
–> Using interface ppp0
–> pppd: �[7f]
–> pppd: �[7f]
–> pppd: �[7f]
–> pppd: �[7f]
–> pppd: �[7f]
–> local  IP address 10.200.104.99
–> pppd: �[7f]
–> remote IP address 10.64.64.64
–> pppd: �[7f]
–> primary   DNS address 203.113.188.2
–> pppd: �[7f]
–> secondary DNS address 203.113.131.1
–> pppd: �[7f]

But with this wvdial calling by hand, the integration with the gnome desktop is not very nice. For example, I cannot use my OpenVPN from the network manager applet, and that’s a pitty.

Patching the modemmanager

The NetworkManager doesn’t let you configure the AT commands sent to the Modem when you configure the mobile broadband connexions. It’s intelligent enough to find the right ones (yeah…). But not with a very nice fake chinese Nokia phone. Maybe I’ll write a patch for it when I’ll be payed by the jobcenter. For now, I do a quick and dirty solution.
I first started the modemmanager with –debug to have an idea of where it was blocking.
No idea which process does it, but you can kill modemmanager as long as you want, with any signal it will come very fast.
I used this very beautiful trick to start it in debug mode :

root@1001PX:~# chmod -x /usr/sbin/modemmanager ; killall modemmanager ; sleep 2 ; chmod+x /usr/sbin/modemmanager ; /usr/sbin/modemmanager –debug

Nice isn’t it ?
So, after, I got that the error doesn’t come from the FCLASS=0 like with wvdial or gnome-ppp, but from another initialization command :

ATZ E0 V1 +CMEE=1

As a very clean programmer, I patched the modemmanager to remove this stupid +CMEE=1 from the init sequence in the source code of modemmanager.

apt-get build-dep modemmanager

apt-get source modemmanager

cd modemmanager_0.3/

rgrep -n CMEE .

[…]

./src/mm-generic-gsm.c:462:    mm_serial_port_queue_command (port, “E0 +CMEE=1”, 2, NULL, NULL);
./src/mm-generic-gsm.c:2126:        g_value_set_string (value, “Z E0 V1 +CMEE=1”);

This is basically the sequence reported by modemmanager, so I started by removing this CMEE in the src/mm-generic-gsm.c source file. It worked !
The patch is there :
modemmanager-fakenokia5320_removeCMEE.patch
Works well, I wrote this post connected with this 🙂
Hope it helps someone (maybe me after the next security upgrade of network manager…)

Ce contenu a été publié dans 10 minutes of the Geek, English, avec comme mot(s)-clé(s) , , , , , , . Vous pouvez le mettre en favoris avec ce permalien.