From a592d3f93094d1061623e161b69f503956b262c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wabik?= <4rafal@gmail.com> Date: Sun, 12 May 2024 14:27:23 +0200 Subject: [PATCH] Up to 1.0.71-20240512 Fix for duplicate operator name --- luci-app-3ginfo-lite/Makefile | 2 +- .../resources/view/modem/3gdetail.js | 23 +++++++++++-- .../root/usr/share/3ginfo-lite/3ginfo.sh | 33 ++++--------------- .../usr/share/3ginfo-lite/modem/usb/413c81d7 | 7 ++-- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/luci-app-3ginfo-lite/Makefile b/luci-app-3ginfo-lite/Makefile index 4923ac20..c130a442 100644 --- a/luci-app-3ginfo-lite/Makefile +++ b/luci-app-3ginfo-lite/Makefile @@ -12,7 +12,7 @@ MAINTAINER:=RafaƂ Wabik <4Rafal@gmail.com> LUCI_DESCRIPTION:=LuCI JS interface for the 3ginfo-lite. The package allows you to view the parameters of the mobile internet connection. LUCI_DEPENDS:=+sms-tool +comgt +kmod-usb-serial-option LUCI_PKGARCH:=all -PKG_VERSION:=1.0.70-20240510 +PKG_VERSION:=1.0.71-20240512 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luci-app-3ginfo-lite/htdocs/luci-static/resources/view/modem/3gdetail.js b/luci-app-3ginfo-lite/htdocs/luci-static/resources/view/modem/3gdetail.js index a28ff30e..87973f63 100644 --- a/luci-app-3ginfo-lite/htdocs/luci-static/resources/view/modem/3gdetail.js +++ b/luci-app-3ginfo-lite/htdocs/luci-static/resources/view/modem/3gdetail.js @@ -237,6 +237,25 @@ function formatDateTime(s) { return s; } +function checkOperatorName(t) { + var w = t.split(" "); + var f = {}; + + for (var i = 0; i < w.length; i++) { + var wo = w[i].toLowerCase(); + if (!f.hasOwnProperty(wo)) { + f[wo] = i; + } + } + + var u = Object.keys(f).map(function(wo) { + return w[f[wo]]; + }); + + var r = u.join(" "); + return r; +} + return view.extend({ @@ -361,7 +380,7 @@ simDialog: baseclass.extend({ render: function(content) { - let json = JSON.parse(content); + var json = JSON.parse(content); if (json) { if (!json.imei.length > 2) { @@ -570,7 +589,7 @@ simDialog: baseclass.extend({ view.textContent = '-'; } else { - view.textContent = json.operator_name; + view.textContent = checkOperatorName(json.operator_name); } } diff --git a/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/3ginfo.sh b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/3ginfo.sh index 1465a3da..5f293ba9 100644 --- a/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/3ginfo.sh +++ b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/3ginfo.sh @@ -217,27 +217,6 @@ getpath() { esac } -rmduplicates() { - local rv="" - set_uplow() { - echo "$1" | tr '[:upper:]' '[:lower:]' - } - for name in $1; do - d_name=$(set_uplow "$name") - d=false - for vn in $rv; do - if [ "$(set_uplow "$vn")" = "$d_name" ]; then - d=true - break - fi - done - if [ "$d" = false ]; then - rv="$rv $name" - fi - done - echo "$rv" | xargs -} - # --- modemdefine - WAN config --- CONFIG=modemdefine MODEMZ=$(uci show $CONFIG | grep -o "@modemdefine\[[0-9]*\]\.modem" | wc -l | xargs) @@ -319,10 +298,10 @@ if [ -n "$COPS_NUM" ]; then COPS_MNC=${COPS_NUM:3:3} fi -if [ -z "$FORCE_PLMN" ]; then - T=$(echo "$O" | awk -F[\"] '/^\+COPS:\s*.,0/ {print $2}') - [ "x$T" != "x" ] && COPS="$T" -else +TCOPS=$(echo "$O" | awk -F[\"] '/^\+COPS:\s*.,0/ {print $2}') +[ "x$TCOPS" != "x" ] && COPS="$TCOPS" + +if [ -z "$COPS" ]; then if [ -n "$COPS_NUM" ]; then COPS=$(awk -F[\;] '/^'$COPS_NUM';/ {print $3}' $RES/mccmnc.dat | xargs) LOC=$(awk -F[\;] '/^'$COPS_NUM';/ {print $2}' $RES/mccmnc.dat) @@ -330,7 +309,9 @@ else fi [ -z "$COPS" ] && COPS=$COPS_NUM -COPS=$(rmduplicates "$COPS") +if [[ $COPS =~ " " ]]; then + COPS=$(echo "$COPS" | awk '{if(NF==2 && tolower($1)==tolower($2)){print $1}else{print $0}}') +fi isp=$(sms_tool -d $DEVICE at "AT+COPS?"|sed -n '2p'|cut -d '"' -f2|tr -d '\r') isp_num="$COPS_MCC $COPS_MNC" diff --git a/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/413c81d7 b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/413c81d7 index 5035edf1..2828b6e6 100644 --- a/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/413c81d7 +++ b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/413c81d7 @@ -148,7 +148,7 @@ if [ -n "$T" ]; then # [ -n "$T" ] && addon 68 "(S4) SNR" "$T" fi -MODE=$(echo $MODE | sed 's,/,+,' | sed 's,LTE_A,LTE-A | ,') +MODE=$(echo $MODE | sed 's,/,+,' | sed 's,LTE_A,LTE-A | ,' | sed 's,LTE B,LTE | B,') # Cell ID & LAC & TAC LAC_HEX=$(printf "%X" $LAC_DEC) @@ -184,8 +184,9 @@ if [ -z "$MODEL" ] then MODELBCUT=$(echo $PVMODEL | awk -F 'Manufacturer=|S: Product=' '{print $2}' | sed s/"Inc. "// | xargs) MODELACUT=$(echo $PVMODEL | awk -F 'Product=| S: SerialNumber' '{print $2}'| xargs) - MODELC="$MODELBCUT "$MODELACUT - MODEL=$(echo "$MODELC" | awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}' | tr -d '\r\n') + MODEL="$MODELBCUT "$MODELACUT +# MODELC="$MODELBCUT "$MODELACUT +# MODEL=$(echo "$MODELC" | awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}' | tr -d '\r\n') fi # FW