Using UMTS modems
This document gives instructions on using UMTS modems with a Huawei K3765 as example.
Contents |
Install three applications
wvdial
A utility that helps in making modem-based connections to the internet (http://en.wikipedia.org/wiki/Wvdial).
slapt-get -i wvdial
usb_modeswitch
A mode switching tool for controlling "flip flop" (multiple device) USB gear (http://www.draisberghof.de/usb_modeswitch/#intro).
slapt-get -i usb_modeswitch
comgt
Comgt is a command line tool for controlling, configuring and interacting with Option Wireless 3G and 2G ( HSDPA, UMTS, EDGE, GPRS, GSM) data devices within the Linux environment (http://sourceforge.net/projects/comgt/).
wget http://sourceforge.net/projects/comgt/files/comgt/0.32/comgt.0.32.tgz tar xvf comgt.0.32.tgz cd comgt.0.32 make all make install
Set up the wvdial
Save this content to the /etc/wvdial.conf.
[Dialer Defaults] Modem = /dev/ttyUSB0 ISDN = off Modem Type = USB Modem Baud = 460800 Init = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init4 = Init5 = Init6 = Init7 = Init8 = Init9 = Phone1 = Phone2 = Phone3 = Phone4 = Dial Prefix = Dial Attempts = 1 Dial Command = ATM1L3DT Ask Password = off Auto Reconnect = off Abort on Busy = off Carrier Check = on Check Def Route = on Abort on No Dialtone = on Stupid Mode = off Idle Seconds = 0 Init3 = AT+CGDCONT=1,"IP","internet" Password = vodafone Username = vodafone Phone = *99#
You can change the last four lines for your provider. This setting is for Vodafone in Czech Republuc - Europe
APN (Access Point Name): internet Username: vodafone Password: vodafone Phone number for dial-up = *99#
Prepare the dialling
When you have KDE or GNOME, you can set-up kppp or gnome-ppp. For Xfce you need create next dialling script /usr/local/bin/umts-connect with "x" attribut.
Save this content to the file /usr/local/bin/umts-connect.
#!/bin/bash # # umts-connect 0.3 # # Script to connect UMTS modems # via comgt (PIN activation) and wvdial # # - icon with established connection # - used volume is shown after the connection is closed # - choice of the device (modem, handy via usb or bluetooth # # Thomas Schönhütl <pilleus.pulcher@arcor.de> # 22. September 2008 # 20. April 2009 # 20. Juli 2009 # # Lizenz: GPL, Version 2 # DEVICE=$(zenity --title "Modem/Handy" --width=400 --height=200 --radiolist --text "Which device shall be used?" --list --column Choice --column Device TRUE "UMTS-Modem (USB/PCMCIA/Express34)" FALSE "Handy/PDA via USB connection" FALSE "Handy/PDA via bluetooth") if [ -z "`echo $DEVICE`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # # # if [ "`echo $DEVICE`" = "UMTS-Modem (USB/PCMCIA/Express34)" ]; then # if [ -z "`/bin/ls /dev/ttyUSB*`" -a -z "`/bin/ls /dev/ttyACM*`" ]; then zenity --title "UMTS connection" --info --text "No UMTS modem available!\n\nThe script will finish now ..." exit fi # PIN=$(zenity --title "PIN" --entry --text "Please insert the PIN of the SIM card:" --hide-text) # export COMGTPIN=$PIN /usr/local/bin/comgt PIN -d /dev/ttyUSB0 # WAHL=$(zenity --title "UMTS connection" --list --radiolist --text "Use the last configuration?" --column Choice --column Action TRUE "Yes, use it." FALSE "No, configure a new one.") # if [ -z "`echo $WAHL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # if [ "`echo $WAHL`" = "Yes, use it." ]; then sed -i "s:ttyACM:ttyUSB:" /etc/wvdial.conf sed -i "s:rfcomm0:ttyUSB0:" /etc/wvdial.conf export MAIN_DIALOG=" <window title=\"UMTS connection\"> <hbox> <vbox> <text> <label>Preparing the UMTS modem for wvdial ...</label> </text> </vbox> </hbox> </window>" { sleep 15 killall gtkdialog } | gtkdialog -c --program MAIN_DIALOG (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done else TEL=$(zenity --title "UMTS connection" --entry --text "Insert telefonnumber or accept:" --entry-text *99#) if [ -z "`echo $TEL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi NETZ=$(zenity --title "UMTS connection" --entry --text "Please insert APN of the provider:") if [ -z "`echo $NETZ`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi USER=$(zenity --title "UMTS connection" --entry --text "Please insert username:") if [ -z "`echo $USER`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi PASSWD=$(zenity --title "UMTS connection" --entry --text "Please insert password:") if [ -z "`echo $PASSWD`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # tac /etc/wvdial.conf | sed -e '1,4d' | tac > /tmp/wvdial.conf echo "Init3 = AT+CGDCONT=1,\"IP\",\"`echo $NETZ`\"" >> /tmp/wvdial.conf echo "Password = `echo $PASSWD`" >> /tmp/wvdial.conf echo "Username = `echo $USER`" >> /tmp/wvdial.conf echo "Phone = `echo $TEL`" >> /tmp/wvdial.conf rm -f /etc/wvdial.conf mv /tmp/wvdial.conf /etc/ sed -i "s:ttyACM:ttyUSB:" /etc/wvdial.conf sed -i "s:rfcomm0:ttyUSB0:" /etc/wvdial.conf (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done fi killall zenity fi # # # if [ "`echo $DEVICE`" = "Handy/PDA via USB connection" ]; then if [ -z "`/bin/ls /dev/ttyUSB*`" -a -z "`/bin/ls /dev/ttyACM*`" ]; then zenity --title "UMTS connection" --info --text "No UMTS modem available!\n\nThe script will finish now ..." exit fi # # WAHL=$(zenity --title "UMTS connection" --list --radiolist --text "Use the last configuration?" --column Choice --column Action TRUE "Yes, use it." FALSE "No, configure a new one.") # if [ -z "`echo $WAHL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # if [ "`echo $WAHL`" = "Yes, use it." ]; then sed -i "s:ttyUSB:ttyACM:" /etc/wvdial.conf sed -i "s:rfcomm0:ttyACM0:" /etc/wvdial.conf export MAIN_DIALOG=" <window title=\"UMTS connection\"> <hbox> <vbox> <text> <label>Preparing Handy/PDA for wvdial ...</label> </text> </vbox> </hbox> </window>" { sleep 4 killall gtkdialog } | gtkdialog -c --program MAIN_DIALOG (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done else TEL=$(zenity --title "UMTS connection" --entry --text "Insert telefonnumber or accept:" --entry-text *99#) if [ -z "`echo $TEL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi NETZ=$(zenity --title "UMTS connection" --entry --text "Please insert APN of the provider:") if [ -z "`echo $NETZ`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi USER=$(zenity --title "UMTS connection" --entry --text "Please insert username:") if [ -z "`echo $USER`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi PASSWD=$(zenity --title "UMTS connection" --entry --text "Please insert password:") if [ -z "`echo $PASSWD`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # tac /etc/wvdial.conf | sed -e '1,4d' | tac > /tmp/wvdial.conf echo "Init3 = AT+CGDCONT=1,\"IP\",\"`echo $NETZ`\"" >> /tmp/wvdial.conf echo "Password = `echo $PASSWD`" >> /tmp/wvdial.conf echo "Username = `echo $USER`" >> /tmp/wvdial.conf echo "Phone = `echo $TEL`" >> /tmp/wvdial.conf rm -f /etc/wvdial.conf mv /tmp/wvdial.conf /etc/ sed -i "s:ttyUSB:ttyACM:" /etc/wvdial.conf sed -i "s:rfcomm0:ttyACM0:" /etc/wvdial.conf (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done fi killall zenity fi # # # if [ "`echo $DEVICE`" = "Handy/PDA via bluetooth" ]; then zenity --title "UMTS connection" --info --text "Some handies must be paired with the pc before this script will work, just try it!\n\nPair the handy with the pc and make the pc known in the handy as allowed device ..." # if [ "`hcitool dev | awk '{ print $2 $3 }'`" = "" ]; then zenity --title "UMTS connection" --info --text "No bluetooth device available!\n\nThe script will finish now!" /etc/rc.d/rc.bluetooth stop /etc/rc.d/rc.bluetooth start exit fi # # OLD=$(cat /etc/bluetooth/hcid.conf | grep passkey | cut -d " " -f2 | sed -e 's/\";//' -e 's/\"//') PIN=$(zenity --title "UMTS connection" --entry --text "The actual PIN of the pc is `echo $OLD`. It can be changed now:" --entry-text `echo $OLD`) echo $PIN > /etc/bluetooth/passkeys/default if [ -z "`echo $PIN`" ]; then /etc/rc.d/rc.bluetooth stop /etc/rc.d/rc.bluetooth start exit fi sed -i "s/`echo $OLD`/`echo $PIN`/" /etc/bluetooth/hcid.conf zenity --title "UMTS connection" --info --text "The actual PIN of the pc is `echo $PIN`!" # # zenity --title "UMTS connection" --progress --text "Scanning for bluetooth devices in range ..." --pulsate --auto-close & hcitool scan > ERG EMPF=`cat ERG | sed -e '1d' -e 's/ //g'` rm -f ERG killall zenity # if [ "`echo $EMPF | awk '{ print $1 }'`" = "" ]; then zenity --title "UMTS connection" --info --text "No bluetooth devices in range!\n\nThe script will finish now!" /etc/rc.d/rc.bluetooth stop /etc/rc.d/rc.bluetooth start exit fi # EMPFWAHL=$(zenity --title "UMTS connection" --list --radiolist --text "Choose the bluetooth device:" --column Choice --column Device TRUE "`echo $EMPF | cut -d " " -f1,2`" FALSE "`echo $EMPF | cut -d " " -f3,4`" FALSE "`echo $EMPF | cut -d " " -f5,6`") if [ -z "`echo $EMPFWAHL`" ]; then /etc/rc.d/rc.bluetooth stop /etc/rc.d/rc.bluetooth start exit fi # # KANAL=$(sdptool search dun | grep -i "`echo $EMPFWAHL | cut -d " " -f1`" -A 9 | grep Channel | cut -d ":" -f2 | sed -e 's: ::g') rfcomm connect 0 "`echo $EMPFWAHL | cut -d " " -f1`" "`echo $KANAL`" & # # WAHL=$(zenity --title "UMTS connection" --list --radiolist --text "Use the last configuration?" --column Choice --column Action TRUE "Yes, use it." FALSE "No, configure a new one.") # if [ -z "`echo $WAHL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # if [ "`echo $WAHL`" = "Yes, use it." ]; then sed -i "s:ttyUSB0:rfcomm0:" /etc/wvdial.conf sed -i "s:ttyACM0:rfcomm0:" /etc/wvdial.conf export MAIN_DIALOG=" <window title=\"UMTS connection\"> <hbox> <vbox> <text> <label>Preparing Handy/PDA for wvdial ...</label> </text> </vbox> </hbox> </window>" { sleep 30 killall gtkdialog } | gtkdialog -c --program MAIN_DIALOG (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & #sleep 30 && tail /var/log/messages | grep DNS | sed 's/ primary //' | sed 's/ secondary//' \ | cut -d" " -f8 | while read line; do echo "nameserver $line" > /etc/resolv.conf; done sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done else TEL=$(zenity --title "UMTS connection" --entry --text "Insert telefonnumber or accept:" --entry-text *99#) if [ -z "`echo $TEL`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi NETZ=$(zenity --title "UMTS connection" --entry --text "Please insert APN of the provider:") if [ -z "`echo $NETZ`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi USER=$(zenity --title "UMTS connection" --entry --text "Please insert username:") if [ -z "`echo $USER`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi PASSWD=$(zenity --title "UMTS connection" --entry --text "Please insert password:") if [ -z "`echo $PASSWD`" ]; then zenity --title "UMTS connection" --info --text "The script will finish now ..." exit fi # tac /etc/wvdial.conf | sed -e '1,4d' | tac > /tmp/wvdial.conf echo "Init3 = AT+CGDCONT=1,\"IP\",\"`echo $NETZ`\"" >> /tmp/wvdial.conf echo "Password = `echo $PASSWD`" >> /tmp/wvdial.conf echo "Username = `echo $USER`" >> /tmp/wvdial.conf echo "Phone = `echo $TEL`" >> /tmp/wvdial.conf rm -f /etc/wvdial.conf mv /tmp/wvdial.conf /etc/ sed -i "s:ttyUSB0:rfcomm0:" /etc/wvdial.conf sed -i "s:ttyACM0:rfcomm0:" /etc/wvdial.conf (xterm -title "Please do NOT close this window during the connection ..." -e wvdial && ERG=$(echo "`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '2,3d'`+`tail /var/log/messages | grep Sent | tr " " "\n" | grep bytes -1 | sed -e '2,3d' | sed -e '1d' | sed -e '2d'`" | bc -l) && ERG1=$(echo "`echo $ERG`/1024" | bc -l) && ERG2=$(echo $ERG1 | cut -d "." -f1) && zenity --info --text "Used data volume:\n\n`echo $ERG2` Kb" && killall zenity) & #sleep 30 && tail /var/log/messages | grep DNS | sed 's/ primary //' | sed 's/ secondary//' \ | cut -d" " -f8 | while read line; do echo "nameserver $line" > /etc/resolv.conf; done sleep 45 rm /etc/resolv.conf echo "nameserver `tail -30 /var/log/messages | grep DNS | sed -e '2d'| rev | cut -d " " -f1 | rev`" > /etc/resolv.conf while [ "`ps -e | grep wvdial`" ]; do zenity --notification --window-icon=/usr/share/pixmaps/vinagre.svg --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`" && zenity --info --text "UMTS connection: activ; local IP: `ifconfig | grep P-t-P | tr " " "\n" | grep addr | cut -b 6-`; DNS: `cat /etc/resolv.conf`"; continue; done fi killall zenity rfcomm release "`echo $EMPFWAHL | cut -d " " -f1`" "`echo $KANAL`" fi #
Set up file attributs
Set up X (executable) attribut of the file /usr/local/bin/umts-connect.
chmod a+x /usr/local/bin/umts-connect
ldconfig
Run ldconfig command. ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).
ldconfig
Set-up modem and dialling
Create link to the file /etc/ppp/resolv.conf.
Remove file /etc/resolv.conf and cretae symlink to the file /etc/ppp/resolv.conf.
rm /etc/resolv.conf ln -s /etc/ppp/resolv.conf /etc/resolv.conf
Set-up modem type
Save modem type setting to the files /etc/usb_modeswitch.conf and /etc/usb_modeswitch.setup. For example for UMTS modem Huawei K3765 write these setings to the files.
## # Huawei K3765 # # Contributor: Felix Schwarz DefaultVendor= 0x12d1 DefaultProduct= 0x1520 TargetVendor= 0x12d1 TargetProduct= 0x1465 MessageContent="55534243123456780000000000000011060000000000000000000000000000"
For params of other UMTS modems see to the author's web http://www.draisberghof.de/usb_modeswitch.
Using modem and connecting to the Internet
Restart PC or notebook after theese settings. After reboot run /usr/local/bin/umts-connect (under root rights) when you have Xfce or use dialling utils gnome-ppp (GNOME) or kppp (KDE).