PDA

View Full Version : HOWTO :: Setup Singtel Mobile Broadband on Command Line


royong
20-11-2008, 13:57
From the previous threads, you will realize that I have an existing Singtel Mobile Broadband connection that allows me to connect to the Internet via my trusty HUAWEI E220 USB modem. Its been working well and is well suited for my needs.

Recently, I've been caught in a situation where I am required to bash out a script that will allow an administrator to connect to the Internet via Singtel Mobile Broadband connection using only the command line.

Mmm, that should be relatively easy. I sat down and 30 minutes later, I got the following done for my existing Singtel Mobile Broadband connection via my trusty HUAWEI E220 USB modem. Hope this helps someone.

PS - Just hope that the client is using the same device and all I need a cut & paste and I'm done :D

Perform the following steps, logging into the Linux system as root. Yes, I know the stuff about running as root, but this is a simple script and I am concerned about getting it to work rather than securing it. I'm sure you can figure out the "securing" portion on your own :D

# cat > /etc/wvdial.conf <<"EOF"
[Modem0]
Modem = /dev/modem
Baud = 115200
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
Init3 = ATM0
FlowControl = CRTSCTS
[Dialer Singtel]
Username = dummy
Password = dummy
Phone = *99#
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Inherits = Modem0
EOF

That setups up the wvdial.conf file. Now for the script itself.

# cd /root
# mkdir addons
# cd /
# cat > /root/addons/cmb-smbb <<"EOF"
#!/bin/bash
################################################## ################
### Command line dialer for the Singnet Mobile BroadBand
################################################## ################
LOGFILE=/root/addons/cmd-smbb-log
rmmod usb_storage
sleep 1
modprobe usbserial vendor=0x12d1 product=0x1003
sleep 1
### Wait for the kernel to recognizes
### our usb mobile broadband device
echo "NOTE: Waiting for our kernel to detect the modem device"
while true; do
sleep 1
ls -1 /dev/ttyU* | grep ttyUSB0 > $LOGFILE
LOG=`cat $LOGFILE`
if [[ "$LOG" =~ "/dev/ttyUSB0" ]]; then
echo "NOTE: Modem device detected!!!"
### If modem detected, get out of the loop immediately
break
fi
done
sleep 1
ln -sf /dev/ttyUSB0 /dev/modem
rm -fr $LOGFILE
echo "NOTE: Waiting for modem device to register itself to the 3G network ..."
sleep 3
echo "NOTE: Waiting for modem device to register itself to the 3G network ..."
sleep 3
echo "NOTE: Waiting for modem device to register itself to the 3G network ..."
sleep 3
echo "NOTE: Waiting for modem device to register itself to the 3G network ..."
sleep 3
echo "NOTE: Waiting for modem device to register itself to the 3G network ..."
sleep 3
echo "NOTE: Dialing mobile connection now ..."
### Start dialing
wvdial Singtel
EOF
# chmod +x /root/addons/cmb-smbb


That's all to it. Now to give it a go ...

# /root/addons/cmd-smbb

And if it works, you will see an output like the following:

NOTE: Waiting for our kernel to detect the modem device
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
ls: cannot access /dev/ttyU*: No such file or directory
NOTE: Modem device detected!!!
NOTE: Waiting for modem device to register itself to the 3G network ...
NOTE: Waiting for modem device to register itself to the 3G network ...
NOTE: Waiting for modem device to register itself to the 3G network ...
NOTE: Waiting for modem device to register itself to the 3G network ...
NOTE: Waiting for modem device to register itself to the 3G network ...
NOTE: Dialing mobile connection now ...
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
<snip>
<snip>
<snip>
--> primary DNS address 165.21.100.88
--> secondary DNS address 165.21.83.88
--> Script /etc/ppp/ip-up run successful
--> Default route Ok.
--> Nameserver (DNS) Ok.
--> Connected... Press Ctrl-C to disconnect


Looks like you are connected.

Yippeee .... Singnet Mobile BroadBand connection activated with a simple bash script

:D:D:D