quarta-feira, 16 de dezembro de 2009

VIVO 3G using Huawei e1756 on Ubuntu 9.10 Karmic

Quick and fast tip to show a way to connect to 3G using Hawei e1756 modem on Ubuntu 9.10 Karmic.

The problem: The modem itself has a little micro-SD card reader inside and guess what? The kernel identifies it as card reader and not as a 3G modem. Good. ¬¬"

The fix: To solve this minor issue, first you have to install a tool that helps you to switch between storage device and usb serial device, the usb_modeswitch. For this just apt-install the usb-modeswitch package.

Then, modify its config file (/etc/usb_modeswitch.conf) adding the lines below:
# Huawei E1692/E1756
DefaultVendor= 0x12d1
DefaultProduct= 0x1446

TargetVendor= 0x12d1
TargetProduct= 0x140c

MessageContent="55534243000000000000000000000011060000000000000000000000000000"

CheckSuccess=5

These lines tells your usb_modeswitch that if the vendor id 0x12d1 and the product id 0x1446 are found on your usb devices, then it will be switched to product id 0x140c. It means that the usb_modeswitch will switch from storage device to 3G modem. So far so good. :)

Then we have to write a udev rule that tells the system to ignore the card reader and identify it as a 3G modem as we plug it in. Write a file named /etc/udev/rules.d/15-hauwei.rules containing these lines:

SUBSYSTEM=="block", \
ACTION=="add", \
SYSFS{idVendor}=="12d1", \
SYSFS{idProduct}=="1446", \
OPTIONS="ignore_device"

SUBSYSTEM=="usb", SYSFS{idProduct}=="1446", SYSFS{idVendor}=="12d1", RUN+="/usr/sbin/usb_modeswitch"

Your udev now will run usb_modeseitch every time you plug in an usb stick with product id and vendor id matching those values.

Restart your udev:
$ service udev restart

And now, your system should be able to identify your 3G modem. After all these done, you have to configure your NetworkManager. This last step is pretty simple and strightforward, so, I will let you handle this by yourself :)

Any problems please feedback!

[update] I wrote this post drinking wine (long story) and I completely forgot to thank Ursinha for the usb_modeswitch tip. Soooorry and thank you bro! :-)

[update 2] And it seems that NetworkManager doesn't like 3G modems, at least not now. So I had to configure some extra lines on /etc/wvdial.conf and /etc/ppp/options in order to use wvdial and connect using /dev/nail (yeah, that was a joke, there is no such a device):

otubo@minivader ~ $ cat /etc/wvdial.conf

[Dialer 3g]
; Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
; Phone =
ISDN = 0
; Username =
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
; Init3 = AT+CGDCONT=1,"IP","zap.vivo.com.br"
; Password =
Modem = /dev/ttyUSB0
Baud = 921600
DialCommand = ATDT
Check Def Route = on
FlowControl = Hardware(CRTSCTS)
; Username = 1997848815@vivozap.com.br
Username = vivo
Password = vivo
Phone = *99#
Stupid mode = 1
Auto Reconnect = on
Auto DNS = on

otubo@minivader ~ $ egrep -v '#|^ *$' /etc/ppp/options
asyncmap 0
noauth
crtscts
lock
hide-password
modem
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
noipx
asyncmap 0xa0000
mru 1500
refuse-chap
ipcp-max-failure 30


Then, to connect to internet using your 3G modem you just have to run:

root@minivader:~# wvdial 3g
--> 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
ATQ0 V1 E1 S0=0 &C1 &D2
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Thu Dec 17 20:38:52 2009
--> Pid of pppd: 3488
--> Using interface ppp0
--> local IP address 187.88.116.150
--> remote IP address 10.64.64.64
--> primary DNS address 200.142.130.202
--> secondary DNS address 200.220.227.100

And this time, special thanks to Kleber that helped me debugging that shit :-)
Postar um comentário