thesecretdogproject

next || prev

Using the LG KP501 as a GPRS modem with Linux

Fri Jul 31 14:02:17 BST 2009

For a techie, I'm not a massive fan of gadgets and the latest in high-tech geegaws. My laptop is a testament to this: a Thinkpad T23 with a (gasp!) P3 processor and (coo!) 1GB RAM. It's hardly a mindblowing computer experience, but it serves well enough.

Similarly, until relatively recently my mobile phone has been a study in minimalism. Not for me the WAP browser or the email access. My phone had the ability to make calls, send text messages, and light stuff up via a handy white LED stuck to the top of it. It wasn't very flashy -- well, actually, with the LED is was a bit flashy (boom! boom!), but what it lacked in high-tech credentials it made up for by being small, light, and more or less bulletproof, with a battery that lasted ages. Indeed, until I lost it I was perfectly happy.

After that, I decided to give something a bit more modern a go. That something was the LG KP501. On the whole it's a reasonable phone with what seems to be a normal sprinkling of kludgy UI bugs, random crashes, and general annoyances; much like any other mobile phone. However, in its favour it does have the ability to act as a GPRS modem via USB, and so I spent a bit of time recently figuring out how to get it up and running under Linux. Here's how it works.

0. My configuration. I'm using Crunchbang Linux, based on Ubuntu 8.10. The phone is connected via. the proprietary USB cable it came bundled with.

1. The first trap for the unwary. When you plug your phone in it recognises the USB connection and offers up a set of functions, including PC Internet, Mass Storage and PC Suite. The obvious choice, PC Internet, is incorrect -- it exposes a bunch of Windows drivers via a USB storage interface. What you actually want is PC Suite. Pick that one.

2. Make sure Linux can see the modem. The driver to use is cdc_acm. Once the phone is plugged in dmesg should show a log message something like this:

tom@orangutang:~$ dmesg | grep cdc
[ 49.145020] cdc_acm 2-2:2.0: ttyACM0: USB ACM device
[ 49.148640] usbcore: registered new interface driver cdc_acm
[ 49.149975] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters

3. Install and configure wvdial. wvdial is a ppp dialing tool which is able to autoconfigure most modems. It is included in the Ubuntu repository as of 8.10, so installation is a simple aptitude install wvdial. Configuration is a matter of running wvdialconf, which should autodetect and configure the modem.

4. Adding your ISP-specific configuration. The only things that wvdial cannot autoconfigure are your ISP username, password and phone number. These need configuring by hand. You can edit /etc/wvdial.conf to do this. Here's my configuration, for a pay-monthly Orange account:

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 and C1 and D2
Init5 = AT+CGDCONT=1,"IP","orangeinternet"
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
Modem Name = KP501
Modem Type = USB Modem
Phone = *99#
Password = multimedia
Username = orange
Stupid Mode = true

This is largely boilerplate except for the Init5 line, which is required to get the modem to dial out. I discovered this by browsing the modem Windows configuration provided on Orange's website where it was mentioned as an extra configuration command to be specified via the Control Panel.

5. Dialing out. Once you've got all that, you can attempt to dial out using wvdial. With any luck you'll get some some pppd log messages detailing your new IP address and DNS servers, like so:

--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 and C1 and D2
ATQ0 V1 E1 S0=0 and C1 and D2
OK
--> Sending: AT+CGDCONT=1,"IP","orangeinternet"
AT+CGDCONT=1,"IP","orangeinternet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Fri Jul 31 13:42:26 2009
--> Pid of pppd: 6065
--> Using interface ppp0
--> pppd: ��� ��
--> pppd: ��� ��
--> pppd: ��� ��
--> local IP address 10.37.58.137
--> pppd: ��� ��
--> remote IP address 10.37.58.137
--> pppd: ��� ��
--> primary DNS address 193.35.132.165
--> pppd: ��� ��
--> secondary DNS address 193.35.132.164
--> pppd: ��� ��

If you get something along these lines, you're ready to surf. If not... ho hum, time to debug. I had lots of trouble with wvdial reporting an "Invalid dial command" before I had the correct AT+CGDCONT command set up. YMMV.

That's it! Once it's all going, it's very cool. I'm now sat on the train answering email and writing my blog via a GPRS modem. Welcome to the future.