#!/bin/sh
. /usr/lib/libmodcgi.sh
. /mod/etc/conf/ppp.cfg
if [ -n "$PPP_DIAGTTY" ]; then
eval "$(modcgi branding:pkg:cmd mod_cgi)"
if [ ! -z "$MOD_CGI_CMD" ]; then
sec_begin '$(lang de:"Hinweis" en:"Remark")'
echo "
$(lang de:"Aktualisierung wurde angefordert. Dies kann bis zu einer Minute dauern." en:"Refresh initiated. This max take up to one minute.")
"
sec_end
(sleep 1; echo -en "AT+CPIN?\r" >$PPP_DIAGTTY;)&
(sleep 2; echo -en "AT+CSQ\r" >$PPP_DIAGTTY;)&
(sleep 3; echo -en "at+COPS?\r" >$PPP_DIAGTTY;)&
(sleep 4; echo -en "at+COPS=?\r" >$PPP_DIAGTTY;)&
fi
sec_begin '$(lang de:"Status" en:"State")'
local_ALL="
"
RECVALL=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^+COPS: (" | tail -n1 | sed 's/.*: (//; s/)$//;s/ /_/g;s/),*(/ /g')
for RECVONE in $RECVALL; do
if ! echo "$RECVONE" | grep -q ^0; then
NAME=$(echo -n "$RECVONE" | cut -d "," -f2 | sed 's/\"//g;s/_/ /g')
RECV=$(echo -n "$RECVONE" | cut -d "," -f5 | sed 's/2$/3G/;s/0$/2G/')
local_ALL="${local_ALL}- ${RECV}: ${NAME}"
fi
done
local_ALL="${local_ALL}
"
local_PIN=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^+CPIN: " | tail -n1 | sed 's/^+CPIN: //')
local_NET=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^+COPS: [0-9]" | tail -n1 | sed 's/.*,"//;s/",/ (/;s/2$/3G)/;s/0$/2G)/')
local_SIG=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^+CSQ:" | tail -n1 | sed 's/,.*//;s/.* //')
local_MOD=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^\^MODE:" | tail -n1 | sed 's/.*MODE://; s/5,4/UMTS/;s/5,5/HSDPA/;s/0,0/NONE/;s/3,3/EDGE/;s/3,2/GPRS/')
local_FLW=$(cat /tmp/ppp_logger.tmp 2>/dev/null | grep "^^DSFLOWRPT:" | tail -n1 | sed 's/.*DSFLOWRPT://;')
let dH=0x0$(echo $local_FLW | cut -d "," -f 1)/3600
let dM=0x0$(echo $local_FLW | cut -d "," -f 1)-3600*dH
let dM=dM/60
[ $dM -le 9 ] && dM=0$dM
conntime=$dH:$dM
let xH=0x0$(echo $local_FLW | cut -d "," -f 4)/1048576
let xL=0x0$(echo $local_FLW | cut -d "," -f 4)-1048576*xH
let xL=xL/1024
[ $xL -le 99 ] && xL=0$xL
[ $xL -le 9 ] && xL=0$xL
[ $xL -le 0 ] && xL=000
TXsumMB=$xH,$xL
let TXcurMB=0x0$(echo $local_FLW | cut -d "," -f 2)/128
let TXcurKB=TXcurMB/8
let xH=TXcurMB/1024
let xL=TXcurMB-1024*xH
let xL=xL*1000/1024
[ $xL -le 99 ] && xL=0$xL
[ $xL -le 9 ] && xL=0$xL
[ $xL -le 0 ] && xL=000
TXcurMB=$xH,$xL
let xH=0x0$(echo $local_FLW | cut -d "," -f 5)/1048576
let xL=0x0$(echo $local_FLW | cut -d "," -f 5)-1048576*xH
let xL=xL/1024
[ $xL -le 99 ] && xL=0$xL
[ $xL -le 9 ] && xL=0$xL
[ $xL -le 0 ] && xL=000
RXsumMB=$xH,$xL
let RXcurMB=0x0$(echo $local_FLW | cut -d "," -f 3)/128
let RXcurKB=RXcurMB/8
let xH=RXcurMB/1024
let xL=RXcurMB-1024*xH
let xL=xL*1000/1024
[ $xL -le 99 ] && xL=0$xL
[ $xL -le 9 ] && xL=0$xL
[ $xL -le 0 ] && xL=000
RXcurMB=$xH,$xL
cat << EOF
$(lang de:"Verbindungsdauer" en:"Connect time"): | ${conntime} h |
|
Upstream: | ${TXcurMB} MBit/s (${TXcurKB} KB/s) |
Downstream: | ${RXcurMB} MBit/s (${RXcurKB} KB/s) |
$(lang de:"Hochgeladen" en:"Uploaded"): | ${TXsumMB} MB |
$(lang de:"Heruntergeladen" en:"Downloaded"): | ${RXsumMB} MB |
|
$(lang de:"PIN-Status" en:"PIN-state"): | $local_PIN |
$(lang de:"Eingebucht" en:"Connected"): | $local_NET |
$(lang de:"Netzwerkart" en:"Network-mode"): | $local_MOD |
$(lang de:"Signalstärke" en:"Signal-strength"): | $local_SIG |
|
EOF
[ "$local_ALL" != " " ] && echo "$(lang de:"Verfügbare Netze" en:"Detected networks"): $local_ALL"
cat << EOF
|
EOF
sec_end
echo '
'
fi
echo "$(lang de:"Logdatei" en:"Logfile"): $PPP_LOGFILE
"
echo -n ''
[ -e $PPP_LOGFILE ] && html < "$PPP_LOGFILE"
echo -n '
'
if [ -e $PPP_FABALOG ]; then
echo "$(lang de:"Fallback" en:"Fallback"): $PPP_FABALOG
"
echo -n ''
[ -e $PPP_FABALOG ] && html < "$PPP_FABALOG"
echo -n '
'
fi