From f757c10cc1a340b4681e65764621660d8c555d77 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 2 Sep 2006 19:32:04 +0000 Subject: [PATCH] add 3g/umts init script to comgt package SVN-Revision: 4733 --- openwrt/package/comgt/Config.in | 3 + openwrt/package/comgt/Makefile | 4 + openwrt/package/comgt/files/ifup.wwan | 102 ++++++++++++++++++++++++++ openwrt/package/comgt/files/wwan.chat | 12 +++ 4 files changed, 121 insertions(+) create mode 100644 openwrt/package/comgt/files/ifup.wwan create mode 100644 openwrt/package/comgt/files/wwan.chat diff --git a/openwrt/package/comgt/Config.in b/openwrt/package/comgt/Config.in index 9898a64198..1f02c78d82 100644 --- a/openwrt/package/comgt/Config.in +++ b/openwrt/package/comgt/Config.in @@ -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 diff --git a/openwrt/package/comgt/Makefile b/openwrt/package/comgt/Makefile index fae5df9b54..793cad7f3c 100644 --- a/openwrt/package/comgt/Makefile +++ b/openwrt/package/comgt/Makefile @@ -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 index 0000000000..e9b959c704 --- /dev/null +++ b/openwrt/package/comgt/files/ifup.wwan @@ -0,0 +1,102 @@ +#!/bin/sh +[ $# = 0 ] && { echo " $0 "; 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 index 0000000000..5c78b30921 --- /dev/null +++ b/openwrt/package/comgt/files/wwan.chat @@ -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 ' ' -- 2.30.2