From bc2695c988dd47805c84c9c7f72e13c46f6f2ac6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Wabik?= <4rafal@gmail.com>
Date: Fri, 10 May 2024 10:02:21 +0200
Subject: [PATCH] Up to 1.0.70-20240510
- Minor visual fixes
- Updated mccmnc.dat
- Updated scripts for BroadMobi BM806U (DLINK DWR-921 C1)
- Updated scripts for DW5821e Snapdragon X20 LTE
---
luci-app-3ginfo-lite/Makefile | 2 +-
.../resources/view/modem/3gdetail.js | 34 +-
.../root/etc/uci-defaults/set_3ginfo_port.sh | 30 +-
.../root/usr/share/3ginfo-lite/3ginfo.sh | 45 +-
.../root/usr/share/3ginfo-lite/mccmnc.dat | 609 +++++++++---------
.../usr/share/3ginfo-lite/modem/usb/20202033 | 135 ++--
.../usr/share/3ginfo-lite/modem/usb/413c81d7 | 10 +-
7 files changed, 462 insertions(+), 403 deletions(-)
diff --git a/luci-app-3ginfo-lite/Makefile b/luci-app-3ginfo-lite/Makefile
index 2eff6bac..4923ac20 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.69-20240427
+PKG_VERSION:=1.0.70-20240510
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 4d252b4b..a28ff30e 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
@@ -210,6 +210,32 @@ function active_select() {
});
}
+function formatDuration(sec) {
+ if (sec === '-') { return '-'; }
+ if (sec === '') { return '-'; }
+ var d = Math.floor(sec / 86400),
+ h = Math.floor(sec / 3600) % 24,
+ m = Math.floor(sec / 60) % 60,
+ s = sec % 60;
+ var time = d > 0 ? d + 'd ' : '';
+ if (time !== '') { time += h + 'h '; } else { time = h > 0 ? h + 'h ' : ''; }
+ if (time !== '') { time += m + 'm '; } else { time = m > 0 ? m + 'm ' : ''; }
+ time += s + 's';
+ return time;
+}
+
+function formatDateTime(s) {
+ if (s.length == 14) {
+ return s.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, "$1-$2-$3 $4:$5:$6");
+ } else if (s.length == 12) {
+ return s.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/, "$1-$2-$3 $4:$5");
+ } else if (s.length == 8) {
+ return s.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
+ } else if (s.length == 6) {
+ return s.replace(/(\d{4})(\d{2})/, "$1-$2");
+ }
+ return s;
+}
return view.extend({
@@ -530,11 +556,11 @@ simDialog: baseclass.extend({
if (document.getElementById('connst')) {
var view = document.getElementById("connst");
- if (json.connt == '' || json.connt == '-') {
+ if (json.conn_time == '' || json.conn_time == '-') {
view.innerHTML = String.format('' + ' ' +_('Waiting for connection data...'), wicon, p);
}
else {
- view.innerHTML = String.format('' + ' ' + json.connt + ' ' + ' | \u25bc\u202f' + json.connrx + ' \u25b2\u202f' + json.conntx, ticon, t);
+ view.innerHTML = String.format('' + ' ' + formatDuration(json.conn_time_sec) + ' ' + ' | \u25bc\u202f' + json.rx + ' \u25b2\u202f' + json.tx, ticon, t);
}
}
@@ -571,7 +597,7 @@ simDialog: baseclass.extend({
if (json.registration == '0') {
view.textContent = _('Not registered');
}
- if (json.registration == '1' || json.registration == '6') {
+ if (json.registration == '1') {
view.textContent = _('Registered');
}
if (json.registration == '2') {
@@ -646,7 +672,7 @@ simDialog: baseclass.extend({
var view = document.getElementById("temp");
var viewn = document.getElementById("tempn");
var t = json.mtemp;
- if (!t.length > 1) {
+ if (!t.length > 1 && t.includes(' ') || t == '' || t == '-') {
viewn.style.display = 'none';
}
else {
diff --git a/luci-app-3ginfo-lite/root/etc/uci-defaults/set_3ginfo_port.sh b/luci-app-3ginfo-lite/root/etc/uci-defaults/set_3ginfo_port.sh
index 3d63b60a..d3fd50d8 100644
--- a/luci-app-3ginfo-lite/root/etc/uci-defaults/set_3ginfo_port.sh
+++ b/luci-app-3ginfo-lite/root/etc/uci-defaults/set_3ginfo_port.sh
@@ -13,33 +13,5 @@ chmod +x /usr/share/3ginfo-lite/modem/hilink/zte.sh 2>&1 &
rm -rf /tmp/luci-indexcache 2>&1 &
rm -rf /tmp/luci-modulecache/ 2>&1 &
-DEVICE=$(cat /tmp/sysinfo/board_name)
-
-if [[ "$DEVICE" == *"mf289f"* ]]; then
-
- uci set 3ginfo.@3ginfo[0].device="/dev/ttyUSB1" 2>&1 &
- uci commit 3ginfo 2>&1 &
-
-fi
-
-if [[ "$DEVICE" == *"mf286r"* ]]; then
-
- uci set 3ginfo.@3ginfo[0].device="/dev/ttyACM0" 2>&1 &
- uci commit 3ginfo 2>&1 &
-
-fi
-
-if [[ "$DEVICE" == *"mf286d"* ]]; then
-
- uci set 3ginfo.@3ginfo[0].device="/dev/ttyUSB1" 2>&1 &
- uci commit 3ginfo 2>&1 &
-
-fi
-
-if [[ "$DEVICE" == *"mf286"* ]]; then
-
- uci set 3ginfo.@3ginfo[0].device="/dev/ttyUSB1" 2>&1 &
- uci commit 3ginfo 2>&1 &
-
-fi
+exit 0
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 7165cacf..1465a3da 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
@@ -137,6 +137,8 @@ band5g() {
"102") echo " (6200 MHz)";;
"104") echo " (6700 MHz)";;
"105") echo " (600 MHz)";;
+ "106") echo " (900 MHz)";;
+ "109") echo " (700/1500 MHz)";;
"257") echo " (28 GHz)";;
"258") echo " (26 GHz)";;
"259") echo " (41 GHz)";;
@@ -215,7 +217,28 @@ getpath() {
esac
}
-# Luci-app-modemdefine - WAN config
+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)
if [[ $MODEMZ > 1 ]]; then
@@ -239,7 +262,7 @@ fi
fi
done
fi
-# modemdefine config
+# --- modemdefine config ---
CONN_TIME="-"
RX="-"
@@ -256,18 +279,21 @@ if [ -n "$NETUP" ]; then
CT=$((UPTIME-CT))
fi
if [ ! -z $CT ]; then
+
D=$(expr $CT / 60 / 60 / 24)
H=$(expr $CT / 60 / 60 % 24)
M=$(expr $CT / 60 % 60)
S=$(expr $CT % 60)
CONN_TIME=$(printf "%dd, %02d:%02d:%02d" $D $H $M $S)
+ CONN_TIME_SINCE=$(date "+%Y%m%d%H%M%S" -d "@$(($(date +%s) - CT))")
+
fi
+
IFACE=$(ifstatus $SEC | awk -F\" '/l3_device/ {print $4}')
if [ -n "$IFACE" ]; then
RX=$(ifconfig $IFACE | awk -F[\(\)] '/bytes/ {printf "%s",$2}')
TX=$(ifconfig $IFACE | awk -F[\(\)] '/bytes/ {printf "%s",$4}')
fi
-
fi
# CSQ
@@ -283,7 +309,7 @@ fi
# COPS numeric
# see https://mcc-mnc.com/
-# Update: 13/01/2024 items: 2965
+# Update: 28/04/2024 items: 2970
COPS=""
COPS_MCC=""
COPS_MNC=""
@@ -304,8 +330,7 @@ else
fi
[ -z "$COPS" ] && COPS=$COPS_NUM
-COPZ=$(echo $COPS | sed ':s;s/\(\<\S*\>\)\(.*\)\<\1\>/\1\2/g;ts')
-COPS=$(echo $COPZ | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1' | xargs)
+COPS=$(rmduplicates "$COPS")
isp=$(sms_tool -d $DEVICE at "AT+COPS?"|sed -n '2p'|cut -d '"' -f2|tr -d '\r')
isp_num="$COPS_MCC $COPS_MNC"
@@ -445,9 +470,11 @@ fi
cat </dev/null)
+PVCUT=$(echo $PV | awk -F 'Vendor=2020 ProdID=2033' '{print $2}' | cut -c-1290)
+if echo "$PVCUT" | grep -q "Driver=qmi_wwan"
+then
+ PROTO="qmi"
+elif echo "$PVCUT" | grep -q "Driver=cdc_mbim"
+then
+ PROTO="mbim"
+elif echo "$PVCUT" | grep -q "Driver=cdc_ether"
+then
+ PROTO="ecm"
fi
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 9be2da04..5035edf1 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
@@ -15,6 +15,7 @@ fi
O=$(sms_tool -d $DEVICE at "at^ca_info?;^debug?")
O1=$(echo "$O" | sed -n '/^RAT:/,/^SCell1:/p')
+[ -z "$O1" ] && O1=$(echo "$O" | sed -n '/^EARFCN/,/^SCell1:/p')
T=$(echo "$O1" | awk '/TAC:/ {print $2}')
if [ -n "$T" ]; then
@@ -156,6 +157,11 @@ if [ -n "$LAC_DEC" ]; then
fi
CID_HEX=$(printf "%X" $CID_DEC)
+if [ -z "$TAC_DEC" ]
+then
+ [ -n "$TAC_HEX" ] && TAC_DEC=$(echo $((0x$TAC_HEX)))
+fi
+
# Protocol
# DRIVER=QMI_WWAN & DRIVER=CDC_MBIM & DRIVER=CDC_ETHER
PV=$(cat /sys/kernel/debug/usb/devices)
@@ -176,8 +182,8 @@ fi
PVMODEL=$(echo $PV | awk -F 'Vendor=413c ProdID=81d7' '{print $2}' | cut -c-150)
if [ -z "$MODEL" ]
then
- MODELBCUT=$(echo $PVMODEL | awk -F 'Manufacturer=|S: Product=' '{print $2}'| xargs)
- MODELACUT=$(echo $PVMODEL | awk -F 'Product=|S: SerialNumber' '{print $2}'| xargs)
+ 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')
fi