community.riocities.com
  • Home
  • Categories
  • Tags
  • Archives

Ubuntu Gutsy HSDPA E220 Modem

Tele2 Mobile "Broadband" in Ubuntu¶

Prerequisite

Device: Huawei E220 (USB)
Operator: Swedish Tele2
SIM-Card: disabled PIN code (put it in you phone first and disable the pin code)
OS: Ubuntu Gutsy Gibbon 7.10

What will be done: Setup of USB HSDPA Modem with auto connect to Internet

1. Compile huaweiAktBbo and place it in your path.¶

$ wget http://www.kanoistika.sk/bobovsky/archiv/umts/huaweiAktBbo.c
$ sudo apt-get install libusb-dev
$ gcc huaweiAktBbo.c -o huaweiAktBbo -l usb
$ sudo cp huaweiAktBbo /usr/local/bin/

2. Test the modem¶

2.1 Connect the USB modem and wait for a while

2.2 Check that you now see a USB serial device

$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 2007-11-17 19:50 /dev/ttyUSB0

2.3 Run sudo huaweiAktBbo and check the you see three USB serial devices

$ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 2007-11-17 19:50 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 2007-11-17 19:50 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 2007-11-17 19:50 /dev/ttyUSB2

3. Test the connection¶

3.1 Create a wvdial config file named /etc/wvdial.conf

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Phone = *99#
Username = gprs
Password = internet
Dial Command = ATDT
Stupid Mode = 1
ISDN = 0
Auto DNS = 1
Init3 = AT+CGDCONT=1,"IP","internet.tele2.se"

3.2 Try to connect

$ sudo wvdial

3.3 Check that you are connected

$ ifconfig ppp0
ppp0      Link encap:Point-to-Point Protocol
          inet addr:83.178.XX.YY  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:21 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:778 (778.0 b)  TX bytes:157 (157.0 b)

$ host www.slashdot.org
www.slashdot.org has address AA.BB.CC.DD
www.slashdot.org mail is handled by 10 mail.ostg.com.

4. If everything was OK up to this point you are now ready to make it automatic¶

4.1 UDEV rule

Create the file /etc/udev/rules.d/50-huawei-e220.rules with the following configuration

SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/usr/local/bin/setup_e220"

4.2 RUN script

Create the script that udev will call when you insert the device. Due to that a "bad" DNS is given at times the script contains a check for that. Name the script /usr/local/bin/setup_e220

#!/bin/sh

# This script should be called with the following line in
# /etc/udev/rules.d/50-huawei-e220.rules
# SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/root/src/setup_E220"

LOCKFILE=/var/lock/LCK..setup_E220
LOCKFILE_USB=/var/lock/LCK..ttyUSB0
LOGFILE=/tmp/setup_E220.log
BAD_DNS="10.11.12.13"           # Address of bad DNS server to check for

export PATH=/usr/sbin:/usr/bin:/sbin:/bin

setup()
{
    sleep 5
    /usr/local/bin/huaweiAktBbo >> $LOGFILE 2>&1
    #/etc/network/firewall >> $LOGFILE 2>&1
    sleep 5
    wvdial >> $LOGFILE 2>&1
    echo "Removing $LOCKFILE" >> $LOGFILE
    rm $LOCKFILE
}

check_DNS()
{
    while true
    do
        # Wait for connection
        sleep 2
        while [ ! -e $LOCKFILE_USB -a -e $LOCKFILE ]; do sleep 1; done
        while [ `(ifconfig ppp0 | grep -c inet) 2> /dev/null` -eq 0 -a -e $LOCKFILE ]; do sleep 1; done
        [ ! -e $LOCKFILE ] && break
        sleep 5
        # Check DNS
        if [ `grep -c $BAD_DNS /etc/resolv.conf` -eq 1 ];then
            echo "DNS NOK" >> $LOGFILE
            # kill wvdial & run setup again
            kill `cat $LOCKFILE_USB`
            while [ -e $LOCKFILE ]; do sleep 1; done
            setup &
            echo $! > $LOCKFILE
            sleep 10
        else
            echo "DNS OK" >> $LOGFILE
            break
        fi
    done
}

if [ ! -e $LOCKFILE ]; then
    echo "Preparing for dialup." > $LOGFILE
    setup &
    echo $! > $LOCKFILE
    [ ! -z "$BAD_DNS" ] && check_DNS &
fi

Note: I call my firewall script in the setup function.

That's it. The HSDPA USB Modem will now connect automatically when you insert it into your computer.


  • « vnc readony port.patch
  • Replacing apt-proxy with apt-cacher-ng »

Published

Nov 17, 2007

Author

henrik

Category

HW

Social

  • atom feed
  • rss feed
  • ipv6 ready
  • Powered by Pelican. Theme: Elegant by Talha Mansoor