SVN-Revision: 5433master
parent
ab80113a68
commit
8cc785bdf6
@ -0,0 +1,65 @@ |
||||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
include $(TOPDIR)/rules.mk |
||||
|
||||
PKG_NAME:=comgt
|
||||
PKG_VERSION:=0.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)$(PKG_VERSION).tgz
|
||||
PKG_SOURCE_URL:=http://www.pharscape.org/3G/comgt
|
||||
PKG_MD5SUM:=cd32663025ed94a0ee623a689989f3c3
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_UNPACK:=mkdir -p $(PKG_BUILD_DIR); zcat $(DL_DIR)/$(PKG_SOURCE) | $(TAR) -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk |
||||
|
||||
|
||||
define Package/comgt |
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Option/Vodafone 3G/GPRS control tool
|
||||
DEPENDS:=+chat
|
||||
DESCRIPTION:=\
|
||||
comgt is a scripting language interpreter useful for establishing communications \\\
|
||||
on serial lines and through PCMCIA modems as well as GPRS and 3G datacards.
|
||||
URL:= http://www.pharscape.org/content/view/46/70/
|
||||
endef |
||||
|
||||
|
||||
define Build/Compile |
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
gcom
|
||||
endef |
||||
|
||||
define Package/comgt/install |
||||
install -d -m0755 $(1)/usr/bin
|
||||
install -m0755 $(PKG_BUILD_DIR)/gcom $(1)/usr/bin/
|
||||
install -d -m0755 $(1)/etc/ppp
|
||||
install -m0755 ./files/3g.connect $(1)/etc/ppp/3g.connect
|
||||
install -d -m0755 $(1)/etc/chatscripts
|
||||
install -m0644 ./files/3g.chat $(1)/etc/chatscripts/3g.chat
|
||||
install -d -m0755 $(1)/lib/network
|
||||
install -m0644 ./files/3g.sh $(1)/lib/network/3g.sh
|
||||
install -d -m0755 $(1)/etc/hotplug.d/button
|
||||
install -m0644 ./files/3g.button $(1)/etc/hotplug.d/button/05-3g
|
||||
install -d -m0755 $(1)/etc/hotplug.d/iface
|
||||
install -m0644 ./files/3g.iface $(1)/etc/hotplug.d/iface/05-3g
|
||||
install -d -m0755 $(1)/etc/gcom
|
||||
install -m0644 ./files/setpin.gcom $(1)/etc/gcom/setpin.gcom
|
||||
install -m0644 ./files/setmode.gcom $(1)/etc/gcom/setmode.gcom
|
||||
install -m0644 ./files/getcardinfo.gcom $(1)/etc/gcom/getcardinfo.gcom
|
||||
install -m0644 ./files/getstrength.gcom $(1)/etc/gcom/getstrength.gcom
|
||||
endef |
||||
|
||||
$(eval $(call BuildPackage,comgt)) |
||||
|
@ -0,0 +1,35 @@ |
||||
button_action() {( |
||||
# use led for keeping track of the state |
||||
case "$(cat /proc/diag/led/3g_green)" in |
||||
1) |
||||
ifdown "$1" |
||||
ifup wan |
||||
;; |
||||
0) |
||||
ifdown wan |
||||
ifup "$1" |
||||
;; |
||||
esac |
||||
)} |
||||
|
||||
[ "$ACTION" = "released" -a "$BUTTON" = "3g" ] && { |
||||
(echo /bin/true > /proc/sys/kernel/hotplug) |
||||
|
||||
include /lib/network |
||||
scan_interfaces |
||||
config_cb() { |
||||
config_get TYPE "$CONFIG_SECTION" TYPE |
||||
case "$TYPE" in |
||||
interface) |
||||
config_get proto "$CONFIG_SECTION" proto |
||||
config_get button "$CONFIG_SECTION" button |
||||
case "$button" in |
||||
1|on|enabled) [ "$proto" = "3g" ] && button_action "$CONFIG_SECTION";; |
||||
esac |
||||
;; |
||||
esac |
||||
} |
||||
config_load network |
||||
|
||||
(echo /sbin/hotplug > /proc/sys/kernel/hotplug) |
||||
} & |
@ -0,0 +1,12 @@ |
||||
ABORT BUSY |
||||
ABORT 'NO CARRIER' |
||||
ABORT ERROR |
||||
REPORT CONNECT |
||||
TIMEOUT 10 |
||||
"" "AT&F" |
||||
OK "ATE1" |
||||
OK 'AT+CGDCONT=1,"IP","$USE_APN"' |
||||
SAY "Calling UMTS/GPRS" |
||||
TIMEOUT 30 |
||||
OK "ATD*99***1#" |
||||
CONNECT ' ' |
@ -0,0 +1,4 @@ |
||||
#!/bin/sh |
||||
. /lib/network/3g.sh |
||||
set_3g_led 1 1 1 |
||||
/usr/sbin/chat -V -E -f /etc/chatscripts/3g.chat |
@ -0,0 +1,10 @@ |
||||
include /lib/network |
||||
config_load network |
||||
scan_interfaces |
||||
config_get proto "$INTERFACE" proto |
||||
[ "$proto" = "3g" ] && { |
||||
case "$ACTION" in |
||||
ifup) set_3g_led 1 1 0;; |
||||
ifdown) set_3g_led 0 0 0;; |
||||
esac |
||||
} |
@ -0,0 +1,89 @@ |
||||
set_3g_led() { |
||||
grep WRT54G3G /proc/diag/model >/dev/null || return 0 |
||||
echo "$1" > /proc/diag/led/3g_green |
||||
echo "$2" > /proc/diag/led/3g_blue |
||||
echo "$3" > /proc/diag/led/3g_blink |
||||
} |
||||
|
||||
scan_3g() { |
||||
local device |
||||
|
||||
scan_ppp "$@" |
||||
config_get device "$1" device |
||||
|
||||
# try to figure out the device if it's invalid |
||||
[ -n "$device" -a -e "$device" ] || { |
||||
for device in /dev/tts/2 /dev/usb/tts/0 /dev/noz0; do |
||||
[ -e "$device" ] && { |
||||
config_set "$1" device "$device" |
||||
break |
||||
} |
||||
done |
||||
} |
||||
|
||||
# enable 3G with the 3G button by default |
||||
config_get button "$1" button |
||||
[ -z "$button" ] && { |
||||
config_set "$1" button 1 |
||||
} |
||||
} |
||||
|
||||
stop_interface_3g() { |
||||
set_3g_led 0 0 0 |
||||
killall gcom >/dev/null 2>/dev/null |
||||
} |
||||
|
||||
setup_interface_3g() { |
||||
local iface="$1" |
||||
local config="$2" |
||||
|
||||
config_get device "$config" device |
||||
|
||||
for module in slhc ppp_generic ppp_async; do |
||||
/sbin/insmod $module 2>&- >&- |
||||
done |
||||
|
||||
config_get apn "$cfg" apn |
||||
config_get service "$cfg" service |
||||
config_get pincode "$cfg" pincode |
||||
config_get mtu "$cfg" mtu |
||||
|
||||
set_3g_led 1 0 1 |
||||
|
||||
# figure out hardware specific commands for the card |
||||
if gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | grep Novatel 2>/dev/null >/dev/null; then |
||||
case "$service" in |
||||
umts_only) CODE=2;; |
||||
gprs_only) CODE=1;; |
||||
*) CODE=0;; |
||||
esac |
||||
mode="AT\$NWRAT=${CODE},2" |
||||
else |
||||
case "$service" in |
||||
umts_only) CODE=1;; |
||||
gprs_only) CODE=0;; |
||||
*) CODE=3;; |
||||
esac |
||||
mode="AT_OPSYS=${CODE}" |
||||
fi |
||||
|
||||
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || { |
||||
echo "$cfg(3g): Failed to set the PIN code." |
||||
set_3g_led 0 0 0 |
||||
return 1 |
||||
} |
||||
MODE="$mode" gcom -d "$device" -s /etc/gcom/setmode.gcom |
||||
set_3g_led 1 0 0 |
||||
|
||||
start_pppd "$config" \ |
||||
noaccomp \ |
||||
nopcomp \ |
||||
novj \ |
||||
nobsdcomp \ |
||||
noauth \ |
||||
lock \ |
||||
crtscts \ |
||||
connect "USE_APN=\"$apn\" /etc/ppp/3g.connect" \ |
||||
${mtu:+mtu $mtu mru $mtu} \ |
||||
460800 "$device" |
||||
} |
@ -0,0 +1,14 @@ |
||||
opengt |
||||
set com 115200n81 |
||||
set comecho off |
||||
set senddelay 0.02 |
||||
waitquiet 0.2 0.2 |
||||
flash 0.1 |
||||
|
||||
:start |
||||
send "ATI^m" |
||||
get 1 "" $s |
||||
print $s |
||||
|
||||
:continue |
||||
exit 0 |
@ -0,0 +1,14 @@ |
||||
opengt |
||||
set com 115200n81 |
||||
set comecho off |
||||
set senddelay 0.02 |
||||
waitquiet 0.2 0.2 |
||||
flash 0.1 |
||||
|
||||
:start |
||||
send "AT+CSQ^m" |
||||
get 1 "" $s |
||||
print $s |
||||
|
||||
:continue |
||||
exit 0 |
@ -0,0 +1,26 @@ |
||||
# set wwan mode from environment |
||||
opengt |
||||
set com 115200n81 |
||||
set senddelay 0.02 |
||||
waitquiet 1 0.2 |
||||
flash 0.1 |
||||
|
||||
:start |
||||
print "Trying to set mode\n" |
||||
send $env("MODE") |
||||
send "^m" |
||||
|
||||
waitfor 15 "OK","ERR","ERROR" |
||||
if % = 0 goto continue |
||||
if % = 1 goto modeerror |
||||
if % = 2 goto modeerror |
||||
|
||||
print "Timeout setting WWAN mode!\n" |
||||
exit 1 |
||||
|
||||
:modeerror |
||||
print "Error setting WWAN mode!\n" |
||||
exit 1 |
||||
|
||||
:continue |
||||
exit 0 |
@ -0,0 +1,55 @@ |
||||
# set pin code from evnironment "$PINCODE" |
||||
opengt |
||||
set com 115200n81 |
||||
set senddelay 0.05 |
||||
waitquiet 3 0.5 |
||||
flash 0.1 |
||||
|
||||
let c=0 |
||||
:start |
||||
send "AT+CPIN?^m" |
||||
waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR" |
||||
if % = -1 goto timeout |
||||
if % = 0 goto ready |
||||
if % = 1 goto setpin |
||||
if % = 2 goto ready |
||||
if % = 3 goto checkrepeat |
||||
if % = 4 goto checkrepeat |
||||
|
||||
:checkrepeat |
||||
inc c |
||||
if c>3 goto pinerror |
||||
waitquiet 12 0.5 |
||||
goto start |
||||
|
||||
:timeout |
||||
print "timeout checking for PIN." |
||||
exit 1 |
||||
|
||||
:ready |
||||
print "SIM ready\n" |
||||
goto continue |
||||
exit 0 |
||||
|
||||
:setpin |
||||
# check if output was "SIM PIN2", that's ok. |
||||
waitfor 1 "2" |
||||
if % = 0 goto ready |
||||
|
||||
print "Trying to set PIN\n" |
||||
send "AT+CPIN=\"" |
||||
send $env("PINCODE") |
||||
send "\"^m" |
||||
|
||||
waitfor 20 "OK","ERR" |
||||
if % = -1 goto pinerror |
||||
if % = 0 goto continue |
||||
if % = 1 goto pinerror |
||||
|
||||
:pinerror |
||||
print "Error setting PIN, check card manually\n" |
||||
exit 1 |
||||
|
||||
:continue |
||||
print "PIN set successfully\n" |
||||
exit 0 |
@ -0,0 +1,32 @@ |
||||
--- gcom-0.3.x/Makefile 2006-01-04 17:05:28.000000000 +0200
|
||||
+++ gcom-0.3/Makefile 2006-02-26 13:02:07.000000000 +0200
|
||||
@@ -20,8 +20,6 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
-LIB = -L/usr/local/lib
|
||||
-INC = -I/usr/local/include
|
||||
EXE = /usr/local/bin
|
||||
MAN = /usr/share/man/man1
|
||||
CPROG = gcom
|
||||
@@ -29,9 +27,6 @@
|
||||
BIN = $(CPROG) $(SCRIPT)
|
||||
MANP = gcom.1 sigmon.1
|
||||
|
||||
-CFLAGS = -c
|
||||
-LDFLAGS =
|
||||
-
|
||||
all: $(BIN)
|
||||
|
||||
install:
|
||||
@@ -53,8 +48,8 @@
|
||||
|
||||
|
||||
gcom: gcom.o
|
||||
- cc gcom.o $(LDFLAGS) -o gcom
|
||||
+ $(CC) gcom.o $(LDFLAGS) -o gcom
|
||||
|
||||
gcom.o: gcom.c gcom.h
|
||||
- cc gcom.c $(CFLAGS)
|
||||
+ $(CC) -c $(CFLAGS) gcom.c
|
||||
|
Loading…
Reference in new issue