conn

A script repository to manage connections in Linux.
git clone git://r-36.net/conn
Log | Files | Refs | LICENSE

commit e1484d17510f4776e9e4a579d57b336833ee0e82
parent e5170835638b8e9ebfb2a24e712336e90aea4a68
Author: Christoph Lohmann <20h@r-36.net>
Date:   Fri,  1 Apr 2011 23:23:48 +0200

Some convenience and cleanups in wwan examples.

Diffstat:
examples/wwan/f3507g-x201-init | 36+++++++++++++++++++++++++++++-------
examples/wwan/f3507g-x201-usbnet | 7++++---
examples/wwan/gobi-x201-init | 15+++++++++++----
examples/wwan/ppp0-run.sh | 9++++++++-
4 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/examples/wwan/f3507g-x201-init b/examples/wwan/f3507g-x201-init @@ -1,7 +1,16 @@ -#!/bin/bash +#!/bin/sh +# +# The control interface. +# CONTROL_DEVICE="/dev/ttyACM1" -PIN="XXXXX" +# +# Your SIM card PIN. +# +PIN="XXXX" +# +# The APN of your provider. +# APN="surfo2" case "$1" in @@ -11,26 +20,39 @@ case "$1" in echo -n "Powering up F3507g card.." echo enable > /proc/acpi/ibm/wan rfkill unblock wwan - while [ ! -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done + while [ ! -c $CONTROL_DEVICE ]; + do + sleep 0.5 + echo -n "." + done echo "done" + echo -n "Turning on F3507g card..." sleep 5 if [ -n "$PIN" ]; then echo -n "PIN..." - /usr/sbin/chat -v "" "AT+CPIN?" "SIM PIN" "AT" "OK" "AT+CPIN=\"$PIN\"" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE + chat -v "" "AT+CPIN?" "SIM PIN" "AT" "OK" \ + "AT+CPIN=\"$PIN\"" "OK" > $CONTROL_DEVICE \ + < $CONTROL_DEVICE fi echo -n "CFUN..." - /usr/sbin/chat -v "" "AT+CPIN?" "OK" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE + chat -v "" "AT+CPIN?" "OK" "AT+CFUN=1" "+PACSP0" "AT" \ + "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE echo "done" ;; -k) echo -n "Turning off F3507g card..." - /usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE + chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE echo "done" + echo -n "Powering down F3507g card.." rfkill block wwan echo disable > /proc/acpi/ibm/wan - while [ -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done + while [ -c $CONTROL_DEVICE ]; + do + sleep 0.5 + echo -n "." + done echo "done" rmmod zaurus diff --git a/examples/wwan/f3507g-x201-usbnet b/examples/wwan/f3507g-x201-usbnet @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh CONTROL_DEVICE="/dev/ttyACM1" APN="surfo2" @@ -6,13 +6,14 @@ APN="surfo2" case "$1" in -s) echo -n "Starting usbnet connection..." - /usr/sbin/chat -v "" "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" "AT*ENAP=1,1" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE + chat -v "" "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" \ + "AT*ENAP=1,1" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE sleep 1 echo "done" ;; -k) echo -n "Stopping usbnet connection..." - /usr/sbin/chat -v "" "AT*ENAP=0" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE + chat -v "" "AT*ENAP=0" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE echo "done" ;; -r) diff --git a/examples/wwan/gobi-x201-init b/examples/wwan/gobi-x201-init @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh # # My rule for udev is: # SUBSYSTEM=="tty", DRIVERS=="qcserial", ATTRS{bInterfaceNumber}=="02", \ -# SYMLINK+="gobimodem" +# SYMLINK+="gobimodem" # The other ttyUSB0 can be symlinked with "01" and "03" respectively, # where "03" is "gobigps" and "01" is "gobidiag". # @@ -41,6 +41,8 @@ case "$1" in echo -n "Turning on Gobi card..." sleep 5 + chat -t 2 -v "" "AT+CFUN=1" "OK" > $CONTROL_DEVICE \ + < $CONTROL_DEVICE if [ -n "$PIN" ]; then echo -n "PIN..." @@ -49,14 +51,17 @@ case "$1" in > $CONTROL_DEVICE < $CONTROL_DEVICE fi echo -n "COM..." - /usr/sbin/chat -t 2 -v "" "AT+CPIN?" "READY" "AT" "OK" \ + chat -t 2 -v "" "AT+CPIN?" "READY" "AT" "OK" \ "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" \ "ATDT${NUMBER}" "CONNECT" \ > $CONTROL_DEVICE < $CONTROL_DEVICE echo "done" echo -n "Starting pppd ..." - ip route del default 2>&1 > /dev/null + if [ "`ip route | grep default`" != "" ]; + then + ip route del default + fi pppd $CONTROL_DEVICE 9600 modem crtscts defaultroute \ usehostname user $USER noipdefault usepeerdns noauth \ nolock nolog @@ -68,6 +73,8 @@ case "$1" in echo "done" echo -n "Powering down Gobi card..." + chat -t 2 -v "" "AT+CFUN=0" "OK" > $CONTROL_DEVICE \ + < $CONTROL_DEVICE rfkill block wwan echo disable > /proc/acpi/ibm/wan echo "done" diff --git a/examples/wwan/ppp0-run.sh b/examples/wwan/ppp0-run.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . ../common.sh @@ -7,6 +7,13 @@ interface=`getinterface $0` case "$1" in -s) ${WWANDIR}/gobi-x201-init -s + echo -n "Waiting for ppp0 to be online ..." + while [ "`ip addr show dev $interface | grep inet`" == "" ]; + do + sleep 0.5; + echo -n "." + done + echo "done" startpingd $interface exit $? ;;