#!/bin/sh
#------------------------------------------------------------------------------
# opt/files/srv/www/admin/umts.cgi                                 __FLI4LVER__
#
# Creation:     Hans Kraus
# Last Update:  $Id$
#------------------------------------------------------------------------------
. /srv/www/include/cgi-helper
# Security
check_rights "umts" "view"
show_html_header "UMTS"
val=`get_umts_csq webif`
signalval=`echo $val | cut -d "," -f 1`
error=`echo $val | cut -d "," -f 2`
if [ x$signalval = x -o x$signalval = x99 ] ; then
	signal="keine Angabe"
else
	signal="$signalval (`expr $signalval \* 2 - 113`dbm)"
fi
if [ x$error = x -o x$error = x99 ] ; then
	error="keine Angabe"
fi 
show_tab_header "Empfang" no
echo "
   | Status | 
   |  Signalqualität: $signal  | 
   |  Bitfehlerrate: $error  | 
"
show_tab_footer
echo '
'
show_tab_header "Signalqualität" no
echo ""
echo "| "
if echo $signalval | grep -q "^[0-9]\{1,2\}$" && [ "$signalval" -le 31 ]
then
   width=$(expr $signalval \* 500 / 31)
   echo ""
else
   echo " Ungültiger Wert "
fi
echo ' | 
'
echo '
'
show_tab_footer
echo '
'
show_tab_header "Adapter" no
echo "
   | aktuelle Einstellungen | 
   | Befehl | Wert | Bedeutung | 
"
sed -e '{/^\(AT\&V\|OK\)$/d};s/; /\n/g;s/;//g;s/\\/\\\\/g' /tmp/umts.settings |
while read line; do 
  syntax=$(echo $line | cut -d":" -f1 | sed -e 's/\\/[\\]/g')
  [ -z $syntax ] || echo $line:$(grep "^$syntax:" /usr/share/at_syntax|cut -d: -f2-)
done | 
sed -e "s#\(..*\)#   | & | 
#g;s#:##g;s# | \(\| \) | #\  | #g"
echo "
"
show_tab_footer
show_html_footer