Wednesday, May 7, 2008

Huawei E220 UMTS Modem

One of the reasons why i changed to Fedora was my UMTS Modem. Ubuntu does not detect it as a modem and calling the program with udev doesn't work. So every time i plugged-in the modem, i had to run the program.

That page helps a lot for the first time with a E220 modem (and others, in German): http://linux.frankenberger.at/Huawei_E220.html

With Fedora 8 you just need to create a new network interface with the Network Manager, enter the phone number, user, password and the init connection string for your connection. Then you are ready to start your connection with ifup/ifdown.


Disable PIN code
If you are to lazy, like me, to disable the pin code, use udev to send the pin code every time the modem is pluged in:
Create a file with the name /etc/udev/rules.d/50-UMTS.rules and put the content in it:

BUS=="usb", KERNEL=="ttyUSB0", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", SYMLINK+="umts", RUN+="/usr/bin/wvdial -n --config /etc/wvdial-pin.conf"

Maybe you have to replace the values of SYSFS{idProduct} and SYSFS{idVendor} to match your modem, use lsusb to get the values.

As you can see, you need also the file /etc/wvdial-pin.conf which contains the pin:

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800
SetVolume = 0
Dial Command = ATDT
FlowControl = NOFLOW
Init1 = ATZ
Init2 = AT+CPIN=XXXX


Replace XXXX with your PIN code.
Warning: The file wvdial-pin.conf should only be readable for root and no other users. (chown root:root /etc/wvdial-pin.conf;chmod u=rw,go-rwx /etc/wvdial-pin.conf)

When your remove the -n option for the wvdial command in the file 50-UMTS.rules, you will see in a log file (usually messages), what wvdial is doing and your PIN code, so be careful.


Nice script for the desktop
I have written a script for ifup/ifdown that shows the status/errors via a nice windows. First it wats til /dev/ttyUSB0 is available.

Command: network.sh up|down networkinterface
A newer version of the script can be found at my Linux Stuff page.
#!/bin/sh


if [[ $1 = "up" ]] ; then
CMD="/sbin/ifup"

#wait for modem

DEV=/dev/ttyUSB0

if [ ! -e $DEV ] ; then
(echo 1; while [ ! -e $DEV ] ; do sleep 3; done; sleep 7; echo 100) | zenity --progress --text="Auf Modem warten ..." --auto-close --auto-kill --pulsate
fi
fi

if [[ $1 = "down" ]] ; then
CMD="/sbin/ifdown"
fi


if [[ ! $CMD || ! $2 ]] ; then
zenity --error --text="Was willst du machen ?"
exit 1
fi

zenity --progress --auto-kill --text="Bitte warten ..." --percentage=30 --pulsate <<<30 progress_pid="$!" msg="`$CMD">&1`
EXIT_CODE=$?

kill $PROGRESS_PID

if [ $EXIT_CODE != 0 ] ; then
echo $MSG
zenity --error --text="$MSG"
exit $EXIT_CODE
else
if [[ $1 = "up" ]] ; then
zenity --notification --text="Verbindung hergestellt" --window-icon=info &
PROGRESS_PID=$!
sleep 30
kill $PROGRESS_PID
fi
fi

exit 0

No comments: