您的位置:首页 > 运维架构 > Linux

华为E180在linux下使用3G的注意事项(linux in modem Huawei Using E180)

2009-06-11 17:29 676 查看
I had been trying to get my Huawei E180 wireless modem that came with my Singtel wireless Broadband plan to work with my linux laptop.
It wasn't easy and I had to search for information on how to do it. I'll thought I'll write something on how I did it.

The main concept
First you need to get udev to create a device node for the modem at /dev/ttyUSB0. At this point which turns the modem is just like an analog modem.
Then you will then use a modem dialer program (such as wvdial) to use the modem dial to the Singtel network. If it works correctly, you'll see
a ppp0 link when you do a ifconfig at the console:

ppp0 Link encap:Point-to-Point Protocol
inet addr:10.111.22.151 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:13 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:658 (658.0 b) TX bytes:688 (688.0 b)


Setting up USB_Modeswitch
The Huawei E180 is one of those new style devices that comes with Windows device driver stored in them. When first plugged in, it will appear as a
pseudo CD-ROM and then Windows will use it install the device drivers for it. This is convinent forWindows users but prevents it from being
recongized as a modem when you use in a Linux system. So the first thong to do is to install the USB_ModeSwitch utility (http://www.draisberghof.de/usb_modeswitch/)

Get the code, compile and put the binary in your /sbin directory and the usb_modeswitch.conf at /etc/. Then you need to configure it. The utility
reads the configuration from /etc/usb_modeswitch.conf. Take a look at the file and uncomment the section for your modem. There is a section for Huawei modems in there.
The important thing is to get the Vendor and Product id right, to check do a lsusb like this:

# lsusb
Bus 007 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 001 Device 009: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
Bus 001 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000


Here the Vendor id for the Huawei E180 modem is 12d1 and the product ID is 1003.

########################################################
# Huawei E220 (aka "Vodafone EasyBox II", aka "T-Mobile wnw Box Micro")
# Huawei E270
# Huawei E870
#
# Two options: 1. removal of "usb-storage" 2. the special control
# message found by Miroslav Bobovsky
#
# Contributor: Hans Kurent, Denis Sutter

DefaultVendor= 0x12d1;
DefaultProduct= 0x1003

# choose one of these:
;DetachStorageOnly=1
HuaweiMode=1


For the Huawei modem, I uncommented the "HuaweiMode=1" line which should detach the CD-ROM mode and turn the modem into a modem.
For other modems you may have to experiement a bit. The utility takes in command line arguments which should make it easier to test changes.

Creating the /dev/ttyUSB0 node
First create a script for udev as /sbin/usb_modeswitch.sh:

#!/bin/sh
# close these FDs to detach from udev
exec 1<&- 2<&- 5<&- 7<&-
sh -c "sleep 4; /usr/bin/usb_modeswitch" &
exit 0


The exec is a hack for RHEL 5 and UDEV 0.95 which I am using (see http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=11).
Then you need to tell the udev process to execute the script when it sense the modem is plugged and after this to load the usb_serial module:

# cat /etc/udev/rules.d/66-huawei.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", SYSFS{idProduct}=="1003", RUN+="/sbin/usb_modeswitch.sh"
SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", SYSFS{idProduct}=="1003", RUN+="/sbin/modprobe usbserial vendor=0x12d1 product=0x1003"


The important thing is to get the vendor and product id, the script and modprobe command correct.

Now if everything is ok, when you plug in the modem you should be a /dev/ttyUSB0 node created.

Dialing the ISP
You can use any modem dialler to do this. I like simpicity and so I prefer wvdial. To do I add the following entry to /etc/wvdial.conf

# http://ubuntuforums.org/showthread.php?t=426354&page=4 [Dialer singtel-wireless]
Phone = *99#
Username = 123
Password = 123
Stupid Mode = 1
Dial Command = ATDT
Modem = /dev/ttyUSB0
Baud = 115200
Init2 = ATZ
Init3 = ATQ0V1E1S0=0&C1&D2+FCLASS=0
INIT5 = AT+CGDCONT=1,"IP","internet"
ISDN = 0
Modem Type = Analog Modem


Then I execute "wvdial singtel-wireless" to starting dialling. If everything works, then a ppp0 link in created and you can start surfing. Posted by chan kok leong in linux at 12:28 | Comments (0) | Trackbacks (0)
TrackbacksTrackback specific URI for this entry
No Trackbacks
CommentsDisplay comments as (=linear#comments]Linear | Threaded)
No comments
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: