From dea33f9ad9eca34abf0de964c90511a513ba61e0 Mon Sep 17 00:00:00 2001
From: iamromulan <50184035+iamromulan@users.noreply.github.com>
Date: Mon, 18 Mar 2024 00:02:30 -0400
Subject: [PATCH] Sync changes with development
Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
---
simpleadmin/scripts/build_modem_status | 6 +-
simpleadmin/scripts/modemstatus_parse.sh | 25 +-
simpleadmin/scripts/tojson.sh | 25 +-
simpleadmin/www/atcommander.html | 424 +++++++++++++++--------
simpleadmin/www/cgi-bin/get_atcommand | 34 +-
simpleadmin/www/index.html | 4 +-
simpleadmin/www/ttl.html | 16 +-
7 files changed, 338 insertions(+), 196 deletions(-)
diff --git a/simpleadmin/scripts/build_modem_status b/simpleadmin/scripts/build_modem_status
index 1429771..627ec3e 100644
--- a/simpleadmin/scripts/build_modem_status
+++ b/simpleadmin/scripts/build_modem_status
@@ -6,16 +6,16 @@ while true; do
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
+ echo -en "AT+CGCONTRDP=1\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
+ # Send request to modem and wait 3 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
+ | microcom -t 3000 /dev/ttyOUT > /tmp/modemstatus.txt
if [ $? -eq 0 ]
then
# Parse
diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh
index e6e5581..234d88f 100644
--- a/simpleadmin/scripts/modemstatus_parse.sh
+++ b/simpleadmin/scripts/modemstatus_parse.sh
@@ -36,13 +36,15 @@ nr_bw() {
esac
}
-# Function to get the secondary LTE bands
+# Function to get the secondary LTE & NR5G bands
+# Now conditionally calls the functions to get the secondary bands
+# Only apply | sed '1d' to NR_BAND when network mode is SA
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 '"' | sed '1d')
+ 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
@@ -52,9 +54,6 @@ 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
@@ -63,8 +62,7 @@ MODEM_MODEL=$( /tmp/modnetwork
if [ -n "$QENG5" ]; then
QENG5=$QENG5",,"
# Append the initial PCI value rather than overwriting it
+ get_secondary_bands
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
@@ -305,6 +305,9 @@ case $RAT in
if [ -n "$QENG5" ]; then
MODE="$RAT $(echo $QENG5 | cut -d, -f4)"
PCI=$(echo $QENG5 | cut -d, -f8)
+ get_secondary_bands
+ # Apply | sed '1d' to NR_BAND
+ NR_BAND=$(echo $NR_BAND | sed '1d')
CHANNEL=$(echo $QENG5 | cut -d, -f10)
LBAND=$(echo $QENG5 | cut -d, -f11)
PC_BAND="NR5G BAND "$LBAND
@@ -516,4 +519,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 80295ad..d53836a 100644
--- a/simpleadmin/scripts/tojson.sh
+++ b/simpleadmin/scripts/tojson.sh
@@ -8,6 +8,7 @@ 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
@@ -19,15 +20,29 @@ while IFS='=' read -r key value || [[ -n "$key" ]]; do
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 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 not the last line, add comma
- if [ $((++current_line)) -lt "$last_line" ]; then
+ # 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 "}"
\ No newline at end of file
+echo "}"
diff --git a/simpleadmin/www/atcommander.html b/simpleadmin/www/atcommander.html
index fd76614..8bbe4af 100644
--- a/simpleadmin/www/atcommander.html
+++ b/simpleadmin/www/atcommander.html
@@ -1,179 +1,303 @@
-
-