[CONTACT]

[ABOUT]

[POLICY]

Log gph Files gph Refs gph

Found at: gopher.r-36.net:70/scm/conn/commit/80bba872000b34247e1caeb9c820bf4bab118d32.gph

Adding Gobi WWAN example. - conn - A script repository to manage connections in Linux.

Log

Files

Refs

LICENSE

---

commit 80bba872000b34247e1caeb9c820bf4bab118d32

parent 0ee672c2d587fe0443998106cf4bdbd36028da9f

Author: Christoph Lohmann <20h@r-36.net>

Date:   Wed, 23 Mar 2011 17:42:49 +0100
Adding Gobi WWAN example.
Diffstat:
  examples/wwan/gobi-x201-init        |      88 +++++++++++++++++++++++++++++++
  examples/wwan/ppp0-run.sh           |      30 ++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+), 0 deletions(-)
---

diff --git a/examples/wwan/gobi-x201-init b/examples/wwan/gobi-x201-init

@@ -0,0 +1,88 @@
+#!/bin/bash
+
+#
+# My rule for udev is:
+# SUBSYSTEM=="tty", DRIVERS=="qcserial", ATTRS{bInterfaceNumber}=="02", \
+#         SYMLINK+="gobimodem"
+# The other ttyUSB0 can be symlinked with "01" and "03" respectively,
+# where "03" is "gobiusb" and "01" is "gobidiag".
+#
+CONTROL_DEVICE="/dev/gobimodem"
+#
+# Change the PIN to your SIM PIN.
+#
+PIN="XXXX"
+#
+# Your provider's APN.
+#
+APN="surfo2"
+#
+# The user, which is used. It shouldn't matter anyway.
+#
+USER="o2"
+#
+# The number to dial to start the link.
+#
+NUMBER="*99#"
+
+case "$1" in
+        -s)
+                modprobe qcserial
+
+                echo -n "Powering up Gobi card.."
+                echo enable > /proc/acpi/ibm/wan
+                rfkill unblock wwan
+                while [ ! -c $CONTROL_DEVICE ];
+                do
+                        sleep 0.5;
+                        echo -n ".";
+                done
+                echo "done"
+
+                echo -n "Turning on Gobi card..."
+                sleep 5
+                if [ -n "$PIN" ];
+                then
+                        echo -n "PIN..."
+                            /usr/sbin/chat -t 2 -v "" "AT+CPIN?" "SIM PIN" \
+                                "AT" "OK" "AT+CPIN=\"$PIN\"" "OK" \
+                                > $CONTROL_DEVICE < $CONTROL_DEVICE
+                fi
+                echo -n "COM..."
+                /usr/sbin/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
+                pppd $CONTROL_DEVICE 9600 modem crtscts defaultroute \
+                        usehostname user $USER noipdefault usepeerdns noauth \
+                        nolock nolog
+                echo "done"
+        ;;
+        -k)
+                echo -n "Killing pppd ..."
+                pkill -KILL -f "pppd $CONTROL_DEVICE"
+                echo "done"
+
+                echo -n "Powering down Gobi card..."
+                rfkill block wwan
+                echo disable > /proc/acpi/ibm/wan
+                echo "done"
+
+                echo -n "Removing qcserial driver ..."
+                rmmod qcserial
+                echo "done"
+        ;;
+        -r)
+                $0 -k
+                $0 -s
+        ;;
+        *)
+                echo "usage: $0 [-s|-k|-r]"
+        ;;
+esac
+exit 0
+

diff --git a/examples/wwan/ppp0-run.sh b/examples/wwan/ppp0-run.sh

@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. ../common.sh
+
+interface=`getinterface $0`
+
+case "$1" in
+        -s)
+                ${WWANDIR}/gobi-x201-init -s
+                startpingd $interface
+                exit $?
+                ;;
+        -k)
+                stoppingd $interface
+                ${WWANDIR}/gobi-x201-init -k
+                exit $?
+                ;;
+        -u)
+                exit 0
+                ;;
+        -r)
+                $0 -k $interface;
+                $0 -s $interface;
+                ;;
+        *)
+                echo "usage: $0 [-s|-k|-u|-r] interface"
+                exit 1
+                ;;
+esac
+
.


AD: