Tuesday, May 19, 2009

Huawei EC168C on Ubuntu 8.04 Hardy Heron

If you are using Ubuntu 8.10 (Intrepid Ibex) or later, it is very likely that your USB stick will be detected as a modem and you can use Network Manager to connect to the Internet by following the instructions here: ubuntuforums.org

On my Hardy system the USB stick was not detected as a modem but as a mass storage device. First thing I needed to do was to make the system detect it as a modem

For that we need a small program called usb_modeswitch.
Add the following to your /etc/apt/sources.list file

deb http://ppa.launchpad.net/wader/ppa/ubuntu hardy main
deb-src http://ppa.launchpad.net/wader/ppa/ubuntu hardy main


Run the following command:
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 5E5F772E


Then run:
$ sudo apt-get update && sudo apt-get install usb-modeswitch


Now using this program we can switch the USB mode from "Mass Storage" to "modem"

Run:
$ lsusb


You should see something like the following:
Bus 004 Device 005: ID 12d1:140b Huawei Technologies Co., Ltd.


Now the first part of the bold text above is the vendor id and the second part is the product id.

We have to execute the usb_modeswitch command with the following options
-v : vendor id (prefixed by 0x)
-p : product id (prefixed by 0x)
-d : detach storage driver (value=1)
-H : Huawei Mode (value=1)

So we first execute:
$ sudo usb_modeswitch -v 0x12d1 -p 0x140b -d 1

This will detach the storage driver

And then :
$ sudo usb_modeswitch -v 0x12d1 -p 0x140b -H 1

This will enable the usb modem mode

Now run
$ dmesg


You will see something like this:
[ 2386.441282] usb 4-1: generic converter now attached to ttyUSB0
[ 2386.446273] usbserial_generic 4-1:1.1: generic converter detected
[ 2386.446400] usb 4-1: generic converter now attached to ttyUSB1
[ 2386.448209] usbserial_generic 4-1:1.2: generic converter detected
[ 2386.448308] usb 4-1: generic converter now attached to ttyUSB2


This means that the USB stick has now been detected as a modem.

You can now edit /etc/wvdial.conf

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyUSB2
ISDN = 0
Phone = #777
Password =
Username =
stupid mode = 1


In some cases you might have to change the Phone to *99# or some other variation. #777 worked for me as the Phone.

To connect all you need to do now is run :
$ sudo wvdial


To disconnect, use ctrl+C

To make sure that the usb_modeswitch steps happen automatically, do the following:

Thats all !



Credits:
http://ubuntuforums.org/showthread.php?t=1128097
http://www.rimweb.in/forums/index.php?showtopic=8865
http://crazyaboutubuntu.wordpress.com/huawei-e169g-hsdpa-usb-stick-on-ubuntu/
http://forums.hardwarezone.com.sg/showthread.php?t=2004736

P.S. Will post later on how to have the USB stick be detected as a Modem automatically

Follow this blog !!!