Wednesday, May 14, 2008

Connecting Huawei E220 HSDPA Modem in Ubuntu


+


You know how to use it on windows, but how about on Linux? This is what I've done on my office mate notebook who're recently using Ubuntu Linux. There are only few steps need to be done to enable it. Some information for a new beginner on Ubuntu, root user is not automatically enable. So, we require quite a number of time using the sudo command.

sudo definition: sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

Modify the /etc/wvdial.conf as below:

[Dialer Celcom3G]
Phone = *99***1#
Modem = /dev/ttyUSB0
Username = user
Password = pass
ISDN = 0
New PPPD = yes
Baud = 1843200
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Then dial-up the Celcom3G as below:
DragonX@xzone ~ $ sudo wvdial Celcom3G
If there's some error mentioning that the modem is not responding, you only have to issue 2 commands to remove and add the uhci_hcd module (USB Driver):
DragonX@xzone ~ $ sudo modprobe -r uhci_hcd
DragonX@xzone ~ $ sudo modprobe uhci_hcd
After that, try to dial it again using the command mentioned above. If it dial successfully, verify it by using the ifconfig command. It will present a new network interface (ppp0) with IP assigned to it.

Here's is a script that will help to easily connecting the modem to the internet.

#!/bin/bash

sudo modprobe -r uhci_hcd
sudo modprobe uhci_hcd

echo "Waiting kernel to detect modem device"

# Wait till the kernel recognizes our E220
while true; do

# Read log
tail -n 20 /var/log/messages > access.history
sleep 1
tail -n 20 /var/log/messages > access.current

LOG=`diff access.history access.current | grep ">" | tr -d ">"`

# Check if it is detected
if [[ "$LOG" =~ "converter now attached to ttyUSB1" ]]; then
echo "Modem device detected, dialing..."
# If it is, get out of the loop immedietly
break
fi
done

rm access.history access.current

# Start dialing
sudo wvdial Celcom3G

1 comment:

Daffodil said...

ishk ishk.. dasat.. mende yg paling kite x suke.. serabut hahaha..