From 08e5bc7359db3eee6d19cd5bb09f6b6ffaa86d43 Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 11:01:03 +0800 Subject: [PATCH 1/7] added various fixes and new data fields --- simpleadmin/scripts/build_modem_status | 16 +- simpleadmin/scripts/modemstatus_parse.sh | 60 ++- simpleadmin/scripts/tojson.sh | 39 +- simpleadmin/www/atcommander.html | 4 +- simpleadmin/www/index.html | 443 ++++++++++++----------- simpleadmin/www/ttl.html | 2 +- 6 files changed, 323 insertions(+), 241 deletions(-) diff --git a/simpleadmin/scripts/build_modem_status b/simpleadmin/scripts/build_modem_status index 23b5215..def3a5d 100644 --- a/simpleadmin/scripts/build_modem_status +++ b/simpleadmin/scripts/build_modem_status @@ -1,9 +1,21 @@ #!/bin/bash +# Run AT+CGMM to get the modem model +echo -en "AT+CGMM\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/modemmodel.txt +sleep 2 + +# Run AT+CGCONTRDP once then proceed to while loop +echo -en "AT+CGCONTRDP\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/apn.txt +sleep 2 + +# Run AT+QUIMSLOT? to get the current sim slot +echo -en "AT+QUIMSLOT?\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/simslot.txt +sleep 2 + while true; do # Send request to modem and wait 5 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 3000 /dev/ttyOUT > /tmp/modemstatus.txt + | microcom -t 5000 /dev/ttyOUT > /tmp/modemstatus.txt if [ $? -eq 0 ] then # Parse @@ -13,4 +25,4 @@ while true; do fi fi sleep 25 # Add a sleep to avoid CPU overload -done +done \ No newline at end of file diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh index d2514bf..461f72c 100644 --- a/simpleadmin/scripts/modemstatus_parse.sh +++ b/simpleadmin/scripts/modemstatus_parse.sh @@ -36,6 +36,40 @@ nr_bw() { esac } +# Function to get the secondary LTE bands +get_secondary_bands() { + # Extract LTE BANDs from SCC lines + SCC_BANDS=$(echo "$OX" | grep '+QCAINFO: "SCC"' | grep -o '"LTE BAND [0-9]\+"' | tr -d '"' | sed '1d') + + # Extract NR5G BANDs from SCC lines + NR_BAND=$(echo "$OX" | grep '+QCAINFO: "SCC"' | grep -o '"NR5G BAND [0-9]\+"' | tr -d '"') + + # Check if both SCC and NR bands are non-empty + if [ -n "$SCC_BANDS" ] && [ -n "$NR_BAND" ]; then + # Concatenate LTE BANDs with NR5G BANDs + SC_BANDS="$SCC_BANDS
$NR_BAND" + else + # Set SC_BANDS to the non-empty variable or empty if both are empty + SC_BANDS="${SCC_BANDS}${NR_BAND}" + fi +} + +# Get the modem model from /tmp/modemmodel.txt and parse it +MODEM_MODEL=$(n"$SLBV if [ -n "$BW" ]; then @@ -194,7 +235,8 @@ case $RAT in CHANNEL=$CHANNEL", -" fi else - LBAND=$LBAND"
nxx (unknown NR5G band)" + # 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) @@ -261,6 +303,7 @@ case $RAT in PCI=$(echo $QENG5 | cut -d, -f8) CHANNEL=$(echo $QENG5 | cut -d, -f10) LBAND=$(echo $QENG5 | cut -d, -f11) + PC_BAND="NR5G BAND "$LBAND BW=$(echo $QENG5 | cut -d, -f12) LBAND="n"$LBAND" (Bandwidth $BW MHz)" RSCP=$(echo $QENG5 | cut -d, -f13) @@ -429,12 +472,11 @@ if [ -z "$LAC" ]; then RNC="-" fi - LUPDATE=$(date +%s) rm -fR /tmp/signal.txt MODEZ=$(echo $MODE | tr -d '"') { - echo 'PROVIDER="'"$PROVIDER"'"' + echo 'PROVIDER="'"$PROVIDER"'"' echo 'CSQ="'"$CSQ"'"' echo 'CSQ_PER="'"$CSQ_PER"'"' echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' @@ -447,6 +489,11 @@ MODEZ=$(echo $MODE | tr -d '"') 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"'"' @@ -454,6 +501,7 @@ MODEZ=$(echo $MODE | tr -d '"') 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"'"' @@ -463,4 +511,4 @@ MODEZ=$(echo $MODE | tr -d '"') } > /tmp/signal.txt # Pregenerate JSON File -/usrdata/simpleadmin/scripts/tojson.sh /tmp/signal.txt > /tmp/modemstatus.json +/usrdata/simpleadmin/scripts/tojson.sh /tmp/signal.txt > /tmp/modemstatus.json \ No newline at end of file diff --git a/simpleadmin/scripts/tojson.sh b/simpleadmin/scripts/tojson.sh index 199bd94..80295ad 100644 --- a/simpleadmin/scripts/tojson.sh +++ b/simpleadmin/scripts/tojson.sh @@ -2,21 +2,32 @@ # 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 -last_line=$(wc -l < $file_name) -current_line=0 +file_name="$1" echo "{" -while read line -do - current_line=$(($current_line + 1)) - if [[ $current_line -ne $last_line ]]; then - [ -z "$line" ] && continue - echo $line|awk -F'=' '{ print " \""$1"\" : "$2","}'|grep -iv '\"#' - else - echo $line|awk -F'=' '{ print " \""$1"\" : "$2""}'|grep -iv '\"#' - fi -done < $file_name +last_line=$(wc -l < "$file_name") + +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') + + # Print key-value pair in JSON format without surrounding double quotes on value + printf ' "%s" : %s' "$key" "$value" + + # Check if not the last line, add comma + if [ $((++current_line)) -lt "$last_line" ]; then + printf ',' + fi + + printf '\n' +done < "$file_name" + echo "}" \ No newline at end of file diff --git a/simpleadmin/www/atcommander.html b/simpleadmin/www/atcommander.html index 0896aa2..fd76614 100644 --- a/simpleadmin/www/atcommander.html +++ b/simpleadmin/www/atcommander.html @@ -19,7 +19,7 @@
diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index dce2290..701f9c9 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -1,233 +1,246 @@ + + + + + + Simple Admin - - - - - RM5xxx Connection Info - - - - - - + + + +
-
-
-
-
-
-

- Quectel RMxxx Connection Info -

-

- Data Updated: -

-
-
-
-
-
-
-
-

-

Network

-
-
-
-
-

-

Signal Strength

-
-
-
-
-

-

Modem Temperature

-
-
-
-
-

-

Band

-
-
-
-
-
-
-
-
-

- Signal Information -

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Provider -
CSQ -
Signal Strength -
RSSI -
ECIO3G/RSRQ4G/SS_RSRQ5G -
RSCP3G/RSRP4G/SS_RSRP5G -
SINR -
-
-
-
-
-
-
-
-

- Cell Information -

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MCC MNC - - / - -
RNC3G/eNB ID4G/5G - - -
Lag3G/TAC4G/5G - - -
Cell ID -
Band -
Channel -
PCI -
-
-
-
-
-
+
+
+
+
+
+ +

+ Quectel Connection + Info +

+

+ Data Updated: +

+
+
+
+
+
+
+ +

+

Network

+

+

Signal Strength

+
+
+
+
+ +

+

Current APN

+

+

Primary Band

+
+
+ +
+
+

+

Aggregated Bands

+
+
+
+
+

+

Current SIM

+

+

Modem Temperature

+
+
+
+
+
+
+
+
+

Signal Information

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Provider
CSQ
Signal Strength
RSSI
+ ECIO3G/RSRQ4G/SS_RSRQ5G +
+ RSCP3G/RSRP4G/SS_RSRP5G +
SINR
+
+
+
+
+
+
+
+

Cell Information

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MCC MNC + +
RNC3G/eNB ID4G/5G + + +
Lag3G/TAC4G/5G + + +
Cell ID
Band
Channel
PCI
+
+
+
+
+
+
- - + diff --git a/simpleadmin/www/ttl.html b/simpleadmin/www/ttl.html index 0a5c178..a211a65 100644 --- a/simpleadmin/www/ttl.html +++ b/simpleadmin/www/ttl.html @@ -19,7 +19,7 @@ -
- + \ No newline at end of file From 3b921694c6a1cf123cad3f3a626a707763798f50 Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 11:13:02 +0800 Subject: [PATCH 3/7] fixed MCCMNC sometimes not showing --- simpleadmin/scripts/modemstatus_parse.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh index 461f72c..e1c9678 100644 --- a/simpleadmin/scripts/modemstatus_parse.sh +++ b/simpleadmin/scripts/modemstatus_parse.sh @@ -95,9 +95,9 @@ COPS_MNC="-" CID="" CID5="" RAT="" -# get MCCMNC and then remove the quotes -MCCMNC=$(echo $OX | grep -o "+QSPN: \"[^\"]*\",\"[^\"]*\",\"[^\"]*\",[0-9]\+,\"[0-9]\+\"" | cut -d, -f5) | tr -d '"' QSPN=$(echo $OX | grep -o '+QSPN: "[^"]*","[^"]*","[^"]*",[^"]*,"[^"]*"' | cut -c 8-) +# GET MCCMNC from the last field of QSPN +MCCMNC=$(echo $QSPN | cut -d, -f5 | tr -d '"') PROVIDER=$(echo $QSPN | cut -d, -f1 | tr -d '"') PROVIDER_ID=$(echo $QSPN | cut -d, -f5 | tr -d '"') CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") From 899d405d707f6e93bf7380e47c7d9763d99fa504 Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 13:26:05 +0800 Subject: [PATCH 4/7] added conversion function for SA band bandwidth --- simpleadmin/scripts/modemstatus_parse.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh index e1c9678..f458b88 100644 --- a/simpleadmin/scripts/modemstatus_parse.sh +++ b/simpleadmin/scripts/modemstatus_parse.sh @@ -305,6 +305,7 @@ case $RAT in 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) From 9438fe515d023662a85f2ebfe7a1b23689876836 Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 13:33:17 +0800 Subject: [PATCH 5/7] added APN, Model, and Sim Slot query to loop --- simpleadmin/scripts/build_modem_status | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/simpleadmin/scripts/build_modem_status b/simpleadmin/scripts/build_modem_status index def3a5d..1429771 100644 --- a/simpleadmin/scripts/build_modem_status +++ b/simpleadmin/scripts/build_modem_status @@ -1,18 +1,18 @@ #!/bin/bash -# Run AT+CGMM to get the modem model -echo -en "AT+CGMM\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/modemmodel.txt -sleep 2 - -# Run AT+CGCONTRDP once then proceed to while loop -echo -en "AT+CGCONTRDP\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/apn.txt -sleep 2 - -# Run AT+QUIMSLOT? to get the current sim slot -echo -en "AT+QUIMSLOT?\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/simslot.txt -sleep 2 - while true; do + # Run AT+CGMM to get the modem model + echo -en "AT+CGMM\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/modemmodel.txt + sleep 2 + + # Run AT+CGCONTRDP once then proceed to while loop + echo -en "AT+CGCONTRDP\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/apn.txt + sleep 2 + + # Run AT+QUIMSLOT? to get the current sim slot + echo -en "AT+QUIMSLOT?\r\n" | microcom -t 1000 /dev/ttyOUT > /tmp/simslot.txt + sleep 2 + # Send request to modem and wait 5 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 5000 /dev/ttyOUT > /tmp/modemstatus.txt From 8ba01af38480bc15bd99bf93bb907b414c2cfaed Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 20:38:35 +0800 Subject: [PATCH 6/7] changed PCI to show both 4G and 5G when using NSA --- simpleadmin/scripts/modemstatus_parse.sh | 6 +++++- simpleadmin/www/index.html | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh index f458b88..8a06b8b 100644 --- a/simpleadmin/scripts/modemstatus_parse.sh +++ b/simpleadmin/scripts/modemstatus_parse.sh @@ -52,6 +52,9 @@ get_secondary_bands() { # Set SC_BANDS to the non-empty variable or empty if both are empty SC_BANDS="${SCC_BANDS}${NR_BAND}" fi + + # Get the PCI value. For example: 264 based on this +QCAINFO: "PCC",1775,75,"LTE BAND 3",1,264,-103,-13,-71,0 + MAIN_PCI=$(echo "$OX" | grep '+QCAINFO: "PCC"' | grep -o ',[0-9]\{1,5\},' | tr -d ',') } # Get the modem model from /tmp/modemmodel.txt and parse it @@ -219,7 +222,8 @@ case $RAT in echo "0" > /tmp/modnetwork if [ -n "$QENG5" ]; then QENG5=$QENG5",," - PCI=$(echo $QENG5 | cut -d, -f4) + # Append the initial PCI value rather than overwriting it + 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 diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 701f9c9..0283347 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -204,7 +204,7 @@ - PCI + 4G PCI, 5G PCI From d4a8d835863be898664c053c394dbf33686344bb Mon Sep 17 00:00:00 2001 From: dr-dolomite Date: Sat, 16 Mar 2024 22:46:09 +0800 Subject: [PATCH 7/7] adjusted layouts for better readability --- simpleadmin/www/index.html | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 0283347..90cf979 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -17,9 +17,7 @@