From 5b0e5ef051c75be005b284504f7b37625f451a3b Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Fri, 3 May 2024 22:21:02 -0400 Subject: [PATCH] Remove no longer needed scripts --- simpleadmin/old/build_modem_status | 25 -- simpleadmin/old/modemstatus_parse.sh | 540 --------------------------- simpleadmin/old/tojson.sh | 48 --- 3 files changed, 613 deletions(-) delete mode 100644 simpleadmin/old/build_modem_status delete mode 100644 simpleadmin/old/modemstatus_parse.sh delete mode 100644 simpleadmin/old/tojson.sh diff --git a/simpleadmin/old/build_modem_status b/simpleadmin/old/build_modem_status deleted file mode 100644 index 7487372..0000000 --- a/simpleadmin/old/build_modem_status +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -while true; do - # Run AT+CGMM to get the modem model - echo -en "AT+CGMM\r\n" | microcom -t 15 /dev/ttyOUT > /tmp/modemmodel.txt - - # Run AT+CGCONTRDP once then proceed to while loop - echo -en "AT+CGCONTRDP=1\r\n" | microcom -t 15 /dev/ttyOUT > /tmp/apn.txt - - # Run AT+QUIMSLOT? to get the current sim slot - echo -en "AT+QUIMSLOT?\r\n" | microcom -t 15 /dev/ttyOUT > /tmp/simslot.txt - - # Send request to modem and wait 0.03 seconds for data - echo -en "AT+QSPN;+CEREG=2;+CEREG?;+CEREG=0;+C5GREG=2;+C5GREG?;+C5GREG=0;+CSQ;+QENG=\"servingcell\";+QRSRP;+QCAINFO;+QNWPREFCFG=\"mode_pref\";+QTEMP\r\n" \ - | microcom -t 30 /dev/ttyOUT > /tmp/modemstatus.txt - if [ $? -eq 0 ] - then - # Parse - if [ -f /tmp/modemstatus.txt ] - then - /usrdata/simpleadmin/scripts/modemstatus_parse.sh - fi - fi - sleep 1 # Add a sleep to avoid CPU overload -done diff --git a/simpleadmin/old/modemstatus_parse.sh b/simpleadmin/old/modemstatus_parse.sh deleted file mode 100644 index aaddf90..0000000 --- a/simpleadmin/old/modemstatus_parse.sh +++ /dev/null @@ -1,540 +0,0 @@ -#!/bin/bash - -# Adapted to work with RJ45 / Quectel Board Dev -# Quectel AT Parsing Original source ROOter2203 -# https://github.com/ofmodemsandmen/ROOterSource2203/blob/6636758b945ff16b6c5b54494de04b74b011c204/package/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quecteldata.sh -# - - -rspr2rssi() { - echo ${RSCP} ${BW_N} | awk '{printf "%.0f\n", (($1+10*log(12*$2)/log(10)))}' -} - -lte_bw() { - BW=$(echo $BW | grep -o "[0-5]\{1\}") - case $BW in - "0") - BW="1.4" ;; - "1") - BW="3" ;; - "2"|"3"|"4"|"5") - BW=$((($(echo $BW) - 1) * 5)) ;; - esac -} - -nr_bw() { - BW=$(echo $BW | grep -o "[0-9]\{1,2\}") - case $BW in - "0"|"1"|"2"|"3"|"4"|"5") - BW=$((($(echo $BW) + 1) * 5)) ;; - "6"|"7"|"8"|"9"|"10"|"11"|"12") - BW=$((($(echo $BW) - 2) * 10)) ;; - "13") - BW="200" ;; - "14") - BW="400" ;; - esac -} - -# Function to get the secondary LTE & NR5G bands -get_secondary_bands_lte() { - # Extract the LTE BANDs from SCC lines from /tmp/modemstatus.txt. - # If there are multiple bands, they will be concatenated with
tags. - SC_BANDS=$(grep -o '"LTE BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed '1d' | sed ':a;N;$!ba;s/\n//g') - - # If there are no LTE bands or NR5G bands, set SC_BANDS to empty - if [ -z "$SC_BANDS" ]; then - SC_BANDS="-" - fi - -} - -# Function to get the secondary NR5G bands for NR5G NSA -get_secondary_bands_nsa() { - # Extract the NR5G NSA BANDs from SCC lines from /tmp/modemstatus.txt. - # If there are multiple bands, they will be concatenated with
tags. - SC_BANDS_NSA=$(grep -o '"NR5G BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed ':a;N;$!ba;s/\n//g') - echo $SC_BANDS_NSA > /tmp/scbands.txt - - # If there are no NR5G NSA bands, set SC_BANDS_NSA to empty - if [ -z "$SC_BANDS_NSA" ]; then - SC_BANDS_NSA="-" - fi -} - -get_secondary_bands_sa() { - # Extract the NR5G SA BANDs from SCC lines from /tmp/modemstatus.txt. - # If there are multiple bands, they will be concatenated with
tags. - SC_BANDS=$(grep -o '"NR5G BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed '1d' | sed ':a;N;$!ba;s/\n//g') - - # If there are no NR5G SA bands, set SC_BANDS to empty - if [ -z "$SC_BANDS" ]; then - SC_BANDS="-" - fi -} - -# Get the modem model from /tmp/modemmodel.txt and parse it -MODEM_MODEL=$( /tmp/modnetwork - if [ -n "$QENG5" ]; then - QENG5=$QENG5",," - get_secondary_bands_nsa - # Append the SC_BANDS_NSA to SC_BANDS with
tags - SC_BANDS=$SC_BANDS"
"$SC_BANDS_NSA - PCI="$PCI, "$(echo $QENG5 | cut -d, -f4) - SCHV=$(echo $QENG5 | cut -d, -f8) - SLBV=$(echo $QENG5 | cut -d, -f9) # Now correctly captures the NR band - BW=$(echo $QENG5 | cut -d, -f10) # Now gets the correct BW - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
n"$SLBV - if [ -n "$BW" ]; then - nr_bw - LBAND=$LBAND" (Bandwidth $BW MHz)" - fi - if [ "$SCHV" -ge 123400 ]; then - CHANNEL=$CHANNEL", "$SCHV - else - CHANNEL=$CHANNEL", -" - fi - else - # removed the (unknown NR5G BAND) and replaced with No NR5G Band to avoid confusion - LBAND=$LBAND"
No NR5G Band Detected" - CHANNEL=$CHANNEL", -" - fi - RSCP=$RSCP" dBm
"$(echo $QENG5 | cut -d, -f5) - SINRR=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$SINR"
"$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - ECIO=$ECIO" (4G) dB
"$(echo $QENG5 | cut -d, -f7)" (5G) " - fi - fi - if [ -z "$LBAND" ]; then - LBAND="-" - else - if [ -n "$QCA" ]; then - QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+") - for QCAL in $(echo "$QCA"); do - if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then - SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+") - SRATP="B" - if [ -n "$SCHV" ]; then - CHANNEL="$CHANNEL, $SCHV" - if [ "$SCHV" -gt 123400 ]; then - SRATP="n" - fi - fi - SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}") - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
"$SRATP$SLBV - BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}") - if [ -n "$BWD" ]; then - UPDOWN=$(echo $QCAL | cut -d, -f13) - case "$UPDOWN" in - "UL" ) - CATYPE="CA"$(printf "\xe2\x86\x91") ;; - "DL" ) - CATYPE="CA"$(printf "\xe2\x86\x93") ;; - * ) - CATYPE="CA" ;; - esac - if [ $BWD -gt 14 ]; then - LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)" - else - LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)" - fi - fi - LBAND=$LBAND - fi - PCI="$PCI, "$(echo $QCAL | cut -d, -f8) - fi - done - fi - fi - if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then - LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)" - fi - ;; - "NR5G-SA") - MODE="NR5G-SA" - echo "0" > /tmp/modnetwork - if [ -n "$QENG5" ]; then - MODE="$RAT $(echo $QENG5 | cut -d, -f4)" - PCI=$(echo $QENG5 | cut -d, -f8) - get_secondary_bands_sa - # Apply | sed '1d' to NR_BAND - # Temporarily removed the sed command for testing - CHANNEL=$(echo $QENG5 | cut -d, -f10) - LBAND=$(echo $QENG5 | cut -d, -f11) - PC_BAND="NR5G BAND "$LBAND - BW=$(echo $QENG5 | cut -d, -f12) - nr_bw - LBAND="n"$LBAND" (Bandwidth $BW MHz)" - RSCP=$(echo $QENG5 | cut -d, -f13) - ECIO=$(echo $QENG5 | cut -d, -f14) - if [ "$CSQ_PER" = "-" ]; then - BW_N=($BW * 5) - RSSI=$(rspr2rssi) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" - fi - SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - fi - ;; -esac - -QRSRP=$(echo "$OX" | grep -o "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*") -if [ -n "$QRSRP" ] && [ "$RAT" != "WCDMA" ]; then - QRSRP1=$(echo $QRSRP | cut -d, -f1 | grep -o "[-0-9]\+") - QRSRP2=$(echo $QRSRP | cut -d, -f2) - QRSRP3=$(echo $QRSRP | cut -d, -f3) - QRSRP4=$(echo $QRSRP | cut -d, -f4) - QRSRPtype=$(echo $QRSRP | cut -d, -f5) - if [ "$QRSRPtype" == "NR5G" ]; then - if [ -n "$NR_SA" ]; then - RSCP=$QRSRP1 - if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" ]; then - RSCP1="RxD "$QRSRP2 - fi - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" -a "$QRSRP3" != "-44" ]; then - RSCP=$RSCP" dBm
"$QRSRP3 - fi - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" -a "$QRSRP4" != "-44" ]; then - RSCP1="RxD "$QRSRP4 - fi - else - RSCP=$RSRPLTE - if [ -n "$QRSRP1" -a "$QRSRP1" != "-32768" -a "$QRSRP1" != "-44" ]; then - RSCP=$RSCP" (4G) dBm
"$QRSRP1 - if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" -a "$QRSRP2" != "-44" ]; then - RSCP="$RSCP, $QRSRP2" - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" -a "$QRSRP3" != "-44" ]; then - RSCP="$RSCP, $QRSRP3" - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" -a "$QRSRP4" != "-44" ]; then - RSCP="$RSCP, $QRSRP4" - fi - fi - RSCP=$RSCP" (5G) " - fi - fi - fi - elif [ "$QRSRP2$QRSRP3$QRSRP4" != "-44-44-44" -a -z "$QENG5" ]; then - RSCP=$QRSRP1 - if [ "$QRSRP3$QRSRP4" == "-140-140" -o "$QRSRP3$QRSRP4" == "-44-44" -o "$QRSRP3$QRSRP4" == "-32768-32768" ]; then - RSCP1="RxD "$(echo $QRSRP | cut -d, -f2) - else - RSCP=$RSCP" dBm (RxD "$QRSRP2" dBm)
"$QRSRP3 - RSCP1="RxD "$QRSRP4 - fi - fi -fi - -QNSM=$(echo "$QNSM" | grep -o "[0-9]") -if [ -n "$QNSM" ]; then - MODTYPE="6" - case $QNSM in - "0" ) - NETMODE="1" ;; - "1" ) - NETMODE="3" ;; - "2"|"5" ) - NETMODE="5" ;; - "3" ) - NETMODE="7" ;; - esac -fi -if [ -n "$QNWP" ]; then - MODTYPE="6" - case $QNWP in - "AUTO" ) - NETMODE="1" ;; - "WCDMA" ) - NETMODE="5" ;; - "LTE" ) - NETMODE="7" ;; - "LTE:NR5G" ) - NETMODE="8" ;; - "NR5G" ) - NETMODE="9" ;; - esac -fi - -OX=$(echo "${OX//[ \"]/}") - -REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}") -if [ -n "$REGV" ]; then - LAC5=$(echo "$REGV" | cut -d, -f3) - LAC5=$LAC5" ($(printf "%d" 0x$LAC5))" - CID5=$(echo "$REGV" | cut -d, -f4) - CID5L=$(printf "%010X" 0x$CID5) - RNC5=${CID5L:1:6} - RNC5=$RNC5" ($(printf "%d" 0x$RNC5))" - CID5=${CID5L:7:3} - CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))" - RAT=$(echo "$REGV" | cut -d, -f5) -fi -REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}") -REGFMT="3GPP" -if [ -z "$REGV" ]; then - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}") - REGFMT="SW" -fi -if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - if [ $REGFMT = "3GPP" ]; then - CID=$(echo "$REGV" | cut -d, -f4) - else - CID=$(echo "$REGV" | cut -d, -f5) - fi - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:5} - RNC=$RNC" ($(printf "%d" 0x$RNC))" - CID=${CIDL:6:2} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - -else - REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}") - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - CID=$(echo "$REGV" | cut -d, -f4) - if [ ${#CID} -gt 4 ]; then - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:3} - CID=${CIDL:4:4} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - else - LAC="" - fi - else - LAC="" - fi -fi -REGSTAT=$(echo "$REGV" | cut -d, -f2) -if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then - COPS_MNC=$COPS_MNC" (Roaming)" -fi -if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then - LAC="4G $LAC, 5G $LAC5" - CID="4G $CID
5G $CID5" - RNC="4G $RNC, 5G $RNC5" -elif [ -n "$CID5" ]; then - LAC=$LAC5 - CID=$CID5 - RNC=$RNC5 -fi -if [ -z "$LAC" ]; then - LAC="-" - CID="-" - RNC="-" -fi - -LUPDATE=$(date +%s) -rm -fR /tmp/signal.txt -MODEZ=$(echo $MODE | tr -d '"') -{ - echo 'PROVIDER="'"$PROVIDER"'"' - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODEZ"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PC_BAND="'"$PC_BAND"'"' - echo 'SC_BANDS="'"$SC_BANDS"'"' - echo 'APN="'"$APN"'"' - echo 'MODEM_MODEL="'"$MODEM_MODEL"'"' - echo 'SIMSLOT="'"$SIMSLOT"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$CTEMP"'"' - echo 'SINR="'"$SINR"'"' - echo 'LASTUPDATE="'"$LUPDATE"'"' - echo 'COPS="'"$COPS"'"' - echo 'COPS_MCC="'"$COPS_MCC"'"' - echo 'COPS_MNC="'"$COPS_MNC"'"' - echo 'MCCMNC="'"$MCCMNC"'"' - echo 'LAC="'"$LAC"'"' - echo 'LAC_NUM="'""'"' - echo 'CID="'"$CID"'"' - echo 'CID_NUM="'""'"' - echo 'RNC="'"$RNC"'"' - echo 'RNC_NUM="'""'"' -} > /tmp/signal.txt - -# Pregenerate JSON File -/usrdata/simpleadmin/scripts/tojson.sh /tmp/signal.txt > /tmp/modemstatus.json \ No newline at end of file diff --git a/simpleadmin/old/tojson.sh b/simpleadmin/old/tojson.sh deleted file mode 100644 index d53836a..0000000 --- a/simpleadmin/old/tojson.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# sarav (hello@grity.com) -# convert key=value to json -# Created at Gritfy ( Devops Junction ) -# Updated by: dr-dolomite to make it more robust since it was failing on some casess - -file_name="$1" - -echo "{" -last_line=$(wc -l < "$file_name") -first_line=true - -while IFS='=' read -r key value || [[ -n "$key" ]]; do - # Skip empty lines and comments - if [[ -z "$key" || "$key" == \#* ]]; then - continue - fi - - # Trim leading and trailing whitespace from key and value - key=$(echo "$key" | awk '{$1=$1};1') - value=$(echo "$value" | awk '{$1=$1};1') - - # Check if value includes double quotes inside it like: "value,"value"". If there is, remove the inner double quotes. - if [[ "$value" == *\"* ]]; then - value=$(echo "$value" | sed 's/\"//g') - # enclose the value in double quotes again - value="\"$value\"" - fi - - # Check if value is empty, if so, skip printing this key-value pair - if [[ -z "$value" ]]; then - continue - fi - - # Print comma before each pair except for the first one - if $first_line; then - first_line=false - else - printf ',' - fi - - # Print key-value pair in JSON format without surrounding double quotes on value - printf ' "%s" : %s' "$key" "$value" - - printf '\n' -done < "$file_name" - -echo "}"