add 3g/umts init script to comgt package
authorFelix Fietkau <nbd@openwrt.org>
Sat, 2 Sep 2006 19:32:04 +0000 (19:32 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 2 Sep 2006 19:32:04 +0000 (19:32 +0000)
SVN-Revision: 4733

openwrt/package/comgt/Config.in
openwrt/package/comgt/Makefile
openwrt/package/comgt/files/ifup.wwan [new file with mode: 0644]
openwrt/package/comgt/files/wwan.chat [new file with mode: 0644]

index 9898a64198eb550a8b72a2388192edad136b2557..1f02c78d821f409a7dae6e8a581febfba4f8345d 100644 (file)
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_COMGT
        tristate "comgt - Option/Vodafone 3G/GPRS control tool"
        default m
+       select BR2_PACKAGE_CHAT
        help
          Option GlobeTrotter GPRS/EDGE/3G/HSDPA and Vodafone 3G/GPRS datacard control tool
          
@@ -8,3 +9,5 @@ config BR2_PACKAGE_COMGT
          on serial lines and through PCMCIA modems as well as GPRS and 3G datacards.
          
          http://www.pharscape.org/content/view/46/70/
+
+         This package contains the scripts for setting up 3G/UMTS/GPRS
index fae5df9b542f8b9fff4cfb547a76084b567d20f3..793cad7f3c678c363c1fdb208c125bf5574e2250 100644 (file)
@@ -31,11 +31,15 @@ $(PKG_BUILD_DIR)/.built:
 $(IPKG_COMGT):
        install -d -m0755 $(IDIR_COMGT)/usr/bin
        install -m0755 $(PKG_BUILD_DIR)/gcom $(IDIR_COMGT)/usr/bin/
+       install -d -m0755 $(IDIR_COMGT)/etc/chatscripts
+       install -m0644 ./files/wwan.chat $(IDIR_COMGT)/etc/chatscripts/wwan.chat
        install -d -m0755 $(IDIR_COMGT)/etc/gcom
        install -m0644 ./files/setpin.gcom $(IDIR_COMGT)/etc/gcom/setpin.gcom
        install -m0644 ./files/setmode.gcom $(IDIR_COMGT)/etc/gcom/setmode.gcom
        install -m0644 ./files/getcardinfo.gcom $(IDIR_COMGT)/etc/gcom/getcardinfo.gcom
        install -m0644 ./files/getstrength.gcom $(IDIR_COMGT)/etc/gcom/getstrength.gcom
+       install -d -m0755 $(IDIR_COMGT)/sbin
+       install -m0755 ./files/ifup.wwan $(IDIR_COMGT)/sbin/
        $(RSTRIP) $(IDIR_COMGT)
        $(IPKG_BUILD) $(IDIR_COMGT) $(PACKAGE_DIR)
 
diff --git a/openwrt/package/comgt/files/ifup.wwan b/openwrt/package/comgt/files/ifup.wwan
new file mode 100644 (file)
index 0000000..e9b959c
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+[ $# = 0 ] && { echo "  $0 <group>"; exit; }
+. /etc/functions.sh
+type=$1
+
+[ "$(nvram get ${type}_proto)" = "wwan" ] || {
+       echo "$0: ${type}_proto isn't wwan"
+       exit
+}
+
+mkdir -p /var/lock
+
+for module in slhc ppp_generic pppox pppoe; do
+       /sbin/insmod $module 2>&- >&-
+done
+
+wwan_device="$(nvram get wwan_device)"
+[ -n "$wwan_device" -a -e "$wwan_device" ] || {
+       # try the defaults
+       for dev in /dev/tts/2 /dev/usb/tts/0 /dev/noz0; do
+               [ -e "$dev" ] && {
+                       wwan_device="$dev"
+                       nvram set wwan_device="$dev"
+                       break
+               }
+       done
+       [ -z "$wwan_device" ] && {
+               echo "$0: No device found"
+               exit 1
+       }
+}
+
+if gcom -d $wwan_device -s /etc/gcom/getcardinfo.gcom | grep Novatel 2>/dev/null >/dev/null; then
+       case "$(nvram get wwan_service)" in
+               umts_only) CODE=2;;
+               gprs_only) CODE=1;;
+               *)
+                       # umts_first
+                       CODE=0
+               ;;
+       esac
+       MODE="AT\$NWRAT=${CODE},2"
+else
+       case "$(nvram get wwan_service)" in
+               umts_only) CODE=1;;
+               gprs_only) CODE=0;;
+               *)
+                       # umts_first
+                       CODE=3
+               ;;
+       esac
+       MODE="AT_OPSYS=${CODE}"
+fi
+
+(while :; do
+       USERNAME="$(nvram get wwan_username)"
+       PASSWORD="$(nvram get wwan_passwd)"
+       KEEPALIVE="$(nvram get wwan_redialperiod)"
+       KEEPALIVE="${KEEPALIVE:+lcp-echo-failure 5 lcp-echo-interval $KEEPALIVE}"
+       DEMAND="$(nvram get wwan_demand)"
+       APN="$(nvram get wwan_apn)"
+       case "$DEMAND" in
+               on|1|enabled)
+                       DEMAND=$(nvram get wwan_idletime)
+                       DEMAND=${DEMAND:+demand idle $DEMAND}
+                       [ -f /etc/ppp/filter ] && DEMAND=${DEMAND:+precompiled-active-filter /etc/ppp/filter $DEMAND}
+                       # set up a dummy nameserver for dial on demand
+                       echo "nameserver 1.1.1.1" > /tmp/resolv.conf
+               ;;
+               *) DEMAND="";;
+       esac
+                       
+       MTU=$(nvram get wwan_mtu)
+
+       if PINCODE=$(nvram get wwan_pincode) gcom -d $wwan_device -s /etc/gcom/setpin.gcom; then
+               MODE="$MODE" gcom -d $wwan_device -s /etc/gcom/setmode.gcom
+               /usr/sbin/pppd nodetach \
+                       noaccomp \
+                       nopcomp \
+                       novj \
+                       nobsdcomp \
+                       noauth \
+                       connect /bin/true \
+                       usepeerdns \
+                       defaultroute \
+                       replacedefaultroute \
+                       ipparam "$type" \
+                       linkname "$type" \
+                       user "$USERNAME" \
+                       password "$PASSWORD" \
+                       ${MTU:+mtu $MTU mru $MTU} \
+                       $DEMAND \
+                       $KEEPALIVE \
+                       lock \
+                       crtscts \
+                       connect "WWAN_APN=\"$APN\" /usr/sbin/chat -V -E -f /etc/chatscripts/wwan.chat"
+                       460800 "$wwan_device"
+       else
+               echo "Wrong Pincode."
+               break
+       fi
+done 2>&1 | logger) &
diff --git a/openwrt/package/comgt/files/wwan.chat b/openwrt/package/comgt/files/wwan.chat
new file mode 100644 (file)
index 0000000..5c78b30
--- /dev/null
@@ -0,0 +1,12 @@
+ABORT   BUSY
+ABORT   'NO CARRIER'
+ABORT   ERROR
+REPORT  CONNECT
+TIMEOUT 10
+""      "AT&F"
+OK      "ATE1"
+OK      'AT+CGDCONT=1,"IP","$WWAN_APN"'
+SAY     "Calling UMTS/GPRS"
+TIMEOUT 30
+OK      "ATD*99***1#"
+CONNECT ' '