From 488486bcdc823b03e4e18bd375b4fce3ffc90b4e Mon Sep 17 00:00:00 2001 From: Russel Yasol Date: Mon, 25 Mar 2024 08:52:54 +0800 Subject: [PATCH] added dedicated NR-CA NSA parser --- simpleadmin/scripts/modemstatus_parse.sh | 47 ++++++++++++++---------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh index cab2c34..aaddf90 100644 --- a/simpleadmin/scripts/modemstatus_parse.sh +++ b/simpleadmin/scripts/modemstatus_parse.sh @@ -37,27 +37,33 @@ nr_bw() { } # 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 '"') - - # 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}" +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/qa.txt. + # 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') @@ -181,7 +187,7 @@ case $RAT in else MODE="$RAT" fi - get_secondary_bands + get_secondary_bands_lte PCI=$(echo $QENG | cut -d, -f9) CHANNEL=$(echo $QENG | cut -d, -f10) LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}") @@ -232,8 +238,9 @@ case $RAT in echo "0" > /tmp/modnetwork if [ -n "$QENG5" ]; then QENG5=$QENG5",," - # Append the initial PCI value rather than overwriting it - get_secondary_bands + 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