There was an error in this gadget

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

15 comments:

  1. Thanks a lot ... after surfing lot of sites I found solution.

    Thanks,
    Phaniraj

    ReplyDelete
  2. Hi,

    Thanks for the information. I was able to connect through USB modem. But unable to browse. can you help me?

    Thanks,
    Ramesh.

    ReplyDelete
  3. You mean you cannot connect to any site via the web browser ?

    Does you get an error message, saying "cannot connect to the website"

    The browser may have gone to "offline mode"
    For firefox un-check: File -> Work Offline
    OR maybe that you have not set your DNS servers ?

    edit /etc/resolv.conf and type:
    ###########################
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    ############################

    These are the OpenDns namservers at http://www.opendns.com

    ReplyDelete
  4. Excellent info. I had just bought an EC168C and used this information to share it through a router.

    You might want to add the following lines to wvdia.conf:

    Auto DNS = 1
    Check Def Route = 1

    The first line will take care of DNS resolution problems. The second line will take care of routing problems. Browsing problems can result from incorrect DNS and/or routing problems. So try out both/either lines to solve it.

    ReplyDelete
  5. When I executed the "dmesg" command I got a big out put in which I did not find any ttyUSB.

    When I run "sudo wvdial" I get following error.

    --> WvDial: Internet dialer version 1.60
    --> Cannot open /dev/ttyUSB2: No such file or directory
    --> Cannot open /dev/ttyUSB2: No such file or directory
    --> Cannot open /dev/ttyUSB2: No such file or directory

    Any idea what is wrong here?

    ReplyDelete
  6. it is possible that you might have a different device name(something other than /dev/ttyUSB2) attached to the modem ?

    check the end of the output of dmesg and see which device it actually is.

    ReplyDelete
  7. I am using Huawei 1550 USB modem. I checked the logs but didn't find anything that says usb attached to some device. the closest log message to the ones shown in instructions is following

    [ 22.917459] usb 3-1: new low speed USB device using uhci_hcd and address 2
    ---------------
    I used following commands to change the modem.
    sudo usb_modeswitch -v 0x12d1 -p 0x1446 -d 1
    sudo usb_modeswitch -v 0x12d1 -p 0x1446 -H 1

    ReplyDelete
  8. Ok now I was able to get the proper ttyUSB0 with the help of following article
    http://www.draisberghof.de/usb_modeswitch/#intro

    But when I now run the "$ sudo wvdial" command then I get following errors.
    khurum@Khurum-ThinkPad:~$ sudo wvdial
    --> WvDial: Internet dialer version 1.60
    --> Cannot get information for serial port.
    --> Initializing modem.
    --> Sending: ATZ
    --> Sending: ATQ0
    --> Re-Sending: ATZ
    --> Modem not responding.

    May be settings in the wvdial.config is not correct?

    ReplyDelete
  9. I am now able to detect the modem. But get following error when dailing.

    khurum@Khurum-ThinkPad:~$ sudo wvdial
    --> 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
    --> Modem initialized.
    --> Sending: ATDT*99#
    --> Waiting for carrier.
    ATDT*99#
    ERROR
    --> Invalid dial command.
    --> Disconnecting at Wed Sep 23 13:23:46 2009
    ---------

    My wvdial.config file looks like this

    [Dialer Defaults]
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Init 3 = AT+CGDCONT=1,"IP","data.tre.se"
    Modem Type = USB Modem
    Dial Command = ATDT
    Baud = 460800
    New PPPD = yes
    Modem = /dev/ttyUSB0
    ISDN = 0
    Phone = *99#
    Password = na
    Username = na
    stupid mode = 1

    ------------------
    Any idea why it gives error when dialing?

    ReplyDelete
  10. Well as far as I can see the dialer says that ATDT is an invalid dial command. Are you sure the contents of wvdial.conf are correct. If possible search for the correct contents of wvdial.conf for your particular Huawei modem

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Im having some serious problems getting it to work. I can detach the device ok, but nothing shows up in dmesg when I do the switch. No modem, no nothing..

    ReplyDelete
  13. Thanks for all your support. But the problem is I have got Reliance Broadband Netconnect+ HUAWEI EC168C data card (usb) and it is not working in my KUBUNTU 9.10 KARMIC . In windows it gets automatally detected but here it is automatically detected as a CD rom. How can i install it in my KUBUNTU 9.10 ??

    ReplyDelete
  14. @saurav (and others for whom the usb stick is detected as a mass storage device instead of a modem)
    try installing the package modemmanager

    In the terminal:
    $ sudo aptitude install modemmanager

    This worked for me in Ubuntu 9.10 Karmic

    ReplyDelete
  15. Hello, I'm new to ubuntu and have ec168c data card.
    I don't have any other internet connection. Can you please tell me how should i go about it?
    I guess for getting usb_modeswitch i need internet first on ubuntu. So can i get it through windows and then install it on ubuntu?

    ReplyDelete

Follow this blog !!!