From da1aa3d80ed3fefcd1dce58d44dc976fa030890e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wabik?= <4rafal@gmail.com> Date: Sun, 21 Apr 2024 12:48:31 +0200 Subject: [PATCH] Up to 1.0.66-20240421 - Fix for missing operator name and location - New device support: Fibocom FM350-GL & Thales's Cinterion MV31-W --- luci-app-3ginfo-lite/Makefile | 2 +- .../resources/view/modem/3gdetail.js | 9 +- .../root/usr/share/3ginfo-lite/3ginfo.sh | 88 ++++--- .../usr/share/3ginfo-lite/modem/usb/1e2d00b3 | 225 ++++++++++++++++++ .../usr/share/3ginfo-lite/modem/usb/1e2d00b7 | 225 ++++++++++++++++++ 5 files changed, 512 insertions(+), 37 deletions(-) create mode 100644 luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/1e2d00b3 create mode 100644 luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/1e2d00b7 diff --git a/luci-app-3ginfo-lite/Makefile b/luci-app-3ginfo-lite/Makefile index 16de970f..fc8ef726 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.65-20240330 +PKG_VERSION:=1.0.66-20240421 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 cc92f0b8..e95cc44a 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 @@ -549,13 +549,14 @@ simDialog: baseclass.extend({ } if (document.getElementById('location')) { - var view = document.getElementById("location"); - if (!json.location.length > 1) { - view.textContent = '-'; + var viewloc = document.getElementById("location"); + if (!json.location.length > 2) { + viewloc.style.display = 'none'; } else { - view.innerHTML = json.location; + viewloc.innerHTML = json.location; } + } if (document.getElementById('sim')) { 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 b3538c9c..b279ba3e 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 @@ -184,15 +184,6 @@ DEVICE=$($RES/detect.sh) if [ -z "$DEVICE" ]; then echo '{"error":"Device not found"}' exit 0 -#elif [ ! -e "$DEVICE" ]; then -# uci -q del 3ginfo.@3ginfo[0].device -# uci commit 3ginfo - -# DEVICE=$($RES/detect.sh) -# if [ -z "$DEVICE" ]; then -# echo '{"error":"Device not found"}' -# exit 0 -# fi fi O="" @@ -205,17 +196,39 @@ fi CONFIG=modemdefine MODEMZ=$(uci show $CONFIG | grep -o "@modemdefine\[[0-9]*\]\.modem" | wc -l | xargs) -if [[ $MODEMZ > 1 ]]; then +if [ -z "$MODEMZ" ]; then + if [[ $MODEMZ > 1 ]]; then SEC=$(uci -q get modemdefine.@general[0].main_network) -fi -if [[ $MODEMZ = "0" ]]; then + fi + if [[ $MODEMZ = "0" ]]; then SEC=$(uci -q get 3ginfo.@3ginfo[0].network) -fi -if [[ $MODEMZ = 1 ]]; then + fi + if [[ $MODEMZ = 1 ]]; then SEC=$(uci -q get modemdefine.@modemdefine[0].network) + fi fi - +getpath() { + devname="$(basename $1)" + case "$devname" in + 'wwan'*'at'*) + devpath="$(readlink -f /sys/class/wwan/$devname/device)" + P=${devpath%/*/*/*} + ;; + 'ttyACM'*) + devpath="$(readlink -f /sys/class/tty/$devname/device)" + P=${devpath%/*} + ;; + 'tty'*) + devpath="$(readlink -f /sys/class/tty/$devname/device)" + P=${devpath%/*/*} + ;; + *) + devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" + P=${devpath%/*} + ;; + esac +} if [ -z "$SEC" ]; then getpath $DEVICE @@ -275,39 +288,39 @@ fi COPS="" COPS_MCC="" COPS_MNC="" -COPS_NUM=$(echo "$O" | awk -F[\"] '/^\+COPS:\s?.,2/ {print $2}') +COPS_NUM=$(echo "$O" | awk -F[\"] '/^\+COPS: .,2/ {print $2}') if [ -n "$COPS_NUM" ]; then COPS_MCC=${COPS_NUM:0:3} COPS_MNC=${COPS_NUM:3:3} fi if [ -z "$FORCE_PLMN" ]; then - COPS=$(echo "$O" | awk -F[\"] '/^\+COPS:\s?.,0/ {print $2}') + COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: .,0/ {print $2}') else if [ -n "$COPS_NUM" ]; then - COPS=$(awk -F[\;] '/^'$COPS_NUM';/ {print $3}' $RES/mccmnc.dat) + COPS=$(awk -F[\;] '/^'$COPS_NUM';/ {print $3}' $RES/mccmnc.dat | xargs) LOC=$(awk -F[\;] '/^'$COPS_NUM';/ {print $2}' $RES/mccmnc.dat) fi 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') +COPS=$(echo $COPZ | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1' | xargs) isp=$(sms_tool -d $DEVICE at "AT+COPS?"|sed -n '2p'|cut -d '"' -f2|tr -d '\r') isp_num="$COPS_MCC $COPS_MNC" isp_numws="$COPS_MCC$COPS_MNC" -if [[ "$COPS" = "$isp_num" || "$COPS" = "$isp_numws" ]]; then +if [[ $COPS =~ ^[0-9]+$ ]]; then + if [[ "$COPS" = "$isp_num" || "$COPS" = "$isp_numws" ]]; then if [[ -n "$isp" ]]; then - COPS=$(awk -F[\;] '/^'$isp';/ {print $3}' $RES/mccmnc.dat) + COPS=$(awk -F[\;] '/^'$isp';/ {print $3}' $RES/mccmnc.dat | xargs) LOC=$(awk -F[\;] '/^'$isp';/ {print $2}' $RES/mccmnc.dat) fi -elif [[ -n "$COPS" ]]; then - COPS=$(awk -F[\;] '/^'$COPS';/ {print $3}' $RES/mccmnc.dat) - LOC=$(awk -F[\;] '/^'$COPS';/ {print $2}' $RES/mccmnc.dat) + fi fi + # operator location from temporary config LOCATIONFILE=/tmp/location if [ -e "$LOCATIONFILE" ]; then @@ -315,15 +328,27 @@ if [ -e "$LOCATIONFILE" ]; then LOC=$(cat $LOCATIONFILE) if [ -n "$LOC" ]; then LOC=$(cat $LOCATIONFILE) - else - echo "-" > /tmp/location + if [[ $LOC == "-" ]]; then + rm $LOCATIONFILE + LOC=$(awk -F[\;] '/^'$COPS_NUM';/ {print $2}' $RES/mccmnc.dat) + if [ -n "$LOC" ]; then + echo "$LOC" > /tmp/location + fi + else + LOC=$(awk -F[\;] '/^'$COPS_NUM';/ {print $2}' $RES/mccmnc.dat) + if [ -n "$LOC" ]; then + echo "$LOC" > /tmp/location + fi + fi fi else - LOC=$(awk -F[\;] '/^'$COPS_NUM';/ {print $2}' $RES/mccmnc.dat) - if [ -n "$LOC" ]; then - echo "$LOC" > /tmp/location - else - echo "-" > /tmp/location + if [[ "$COPS_MCC$COPS_MNC" =~ ^[0-9]+$ ]]; then + if [ -n "$LOC" ]; then + LOC=$(awk -F[\;] '/^'$COPS_MCC$COPS_MNC';/ {print $2}' $RES/mccmnc.dat) + echo "$LOC" > /tmp/location + else + echo "-" > /tmp/location + fi fi fi @@ -478,4 +503,3 @@ cat </dev/null) +PVCUT=$(echo $PV | awk -F 'Vendor=1e2d ProdID=00b3' '{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/1e2d00b7 b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/1e2d00b7 new file mode 100644 index 00000000..90bd4331 --- /dev/null +++ b/luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/modem/usb/1e2d00b7 @@ -0,0 +1,225 @@ +# Dell DW5930e +# Foxconn T99W175 +# Thales's Cinterion MV31-W + +O=$(sms_tool -d $DEVICE at "AT^TEMP?") + +T=$(echo "$O" | awk '/^TSENS: / {gsub("C","",$2); print $2}') +T1=$(echo "$O" | awk '/^PA: / {gsub("C","",$2); print $2}') +if [ -n "$T" ] && [ -n "$T1" ]; then + if [[ "$T1" =~ ^[0-9]+$ && "$T" =~ ^[0-9]+$ ]]; then + if [ "$T1" -gt "$T" ]; then + T="$T1" + fi + fi +fi + +T1=$(echo "$O" | awk '/^Skin Sensor: / {gsub("C","",$2); print $2}') +if [ -n "$T" ] && [ -n "$T1" ]; then + if [[ "$T1" =~ ^[0-9]+$ && "$T" =~ ^[0-9]+$ ]]; then + if [ "$T1" -gt "$T" ]; then + T="$T1" + fi + fi +fi +[ -n "$T" ] && TEMP="$T °C" + +if [ "$REGOK" = "1" ]; then + +O=$(sms_tool -d $DEVICE at "at^debug?") + +case "$MODE_NUM" in + "7") + MODE="LTE |" + echo "$O" | grep -q "scell:" && MODE="LTE-A |" + ;; + "11") + MODE="5G SA |" + ;; + "13") + MODE="5G NSA |" + ;; +esac + +T=$(echo "$O" | awk -F: '/^lte_tac:/ {print $2}' | xargs) +if [ -n "$T" ]; then +# TAC_HEX=$(printf "%X" $T) +# TAC_DEC=$(printf "%d" "0x$T") + + TAC_HEX=$(printf "%X" $T) + TAC_DEC="$T" +fi + +O1=$(echo "$O" | grep -A 3 pcell) +T=$(echo "$O1" | awk -F: '/^pcell:/ {print $3}' | cut -f1 -d" ") +if [ -n "$T" ]; then + MODE="$MODE $(band4g $T)" + T1=$(echo "$O1" | awk -F: '/^pcell:/ {print $4}' | xargs) + PBAND="$(band4g $T) @${T1/MHz/} MHz" + + T=$(echo "$O1" | awk -F: '/pci:/ {print $3}' | xargs) + [ -n "$T" ] && PCI=$T + T=$(echo "$O1" | awk -F: '/^channel:/ {print $2}' | cut -f1 -d" " | xargs) + [ -n "$T" ] && EARFCN=$T + T=$(echo "$O1" | awk -F[:,] '/^lte_rsrp:/ {print $2}') + [ -n "$T" ] && RSRP="${T/dBm/}" + T=$(echo "$O1" | awk -F[:,] '/rsrq:/ {print $4}' | xargs) + [ -n "$T" ] && RSRQ="${T/dB/}" + T=$(echo "$O1" | awk -F[:,] '/^lte_rssi:/ {print $2}') + [ -n "$T" ] && RSSI="${T/dBm/}" + T=$(echo "$O1" | awk -F[:,] '/lte_snr:/ {print $4}' | xargs) + [ -n "$T" ] && [ "$T" != "NA" ] && SINR="${T/dB/}" +fi + +O1=$(echo "$O" | grep -A 3 scell) +IDX=0; +while true; do + O2=$(echo "$O1" | head -n4) + if [ -z "$O2" ]; then + break + fi + IDX=$((IDX + 1)) + + T=$(echo "$O2" | awk -F: '/^scell:/ {print $3}' | cut -f1 -d" ") + MODE="$MODE / $(band4g $T)" + T1=$(echo "$O2" | awk -F: '/^scell:/ {print $4}' | xargs) + if [ -n "$T1" ]; then + case $IDX in + 1) S1BAND="$(band4g $T) @${T1/MHz/} MHz";; + 2) S2BAND="$(band4g $T) @${T1/MHz/} MHz";; + 3) S3BAND="$(band4g $T) @${T1/MHz/} MHz";; + 4) S4BAND="$(band4g $T) @${T1/MHz/} MHz";; + *) ;; + esac + fi + + T=$(echo "$O2" | awk -F: '/pci:/ {print $3}' | xargs) + if [ -n "$T" ]; then + case $IDX in + 1) S1PCI="$T";; + 2) S2PCI="$T";; + 3) S3PCI="$T";; + 4) S4PCI="$T";; + *) ;; + esac + fi + + T=$(echo "$O2" | awk -F: '/^channel:/ {print $2}' | cut -f1 -d" " | xargs) + if [ -n "$T" ]; then + case $IDX in + 1) S1EARFCN="$T";; + 2) S2EARFCN="$T";; + 3) S3EARFCN="$T";; + 4) S4EARFCN="$T";; + *) ;; + esac + fi + + T=$(echo "$O2" | awk -F[:,] '/^lte_rsrp:/ {print $2}') +# [ -n "$T" ] && addon $((POS + 6)) "(S${IDX}) RSRP" "${T/dBm/} dBm" + T=$(echo "$O2" | awk -F[:,] '/rsrq:/ {print $4}' | xargs) +# [ -n "$T" ] && addon $((POS + 7)) "(S${IDX}) RSRQ" "${T/dB/} dB" + T=$(echo "$O2" | awk -F[:,] '/^lte_rssi:/ {print $2}') +# [ -n "$T" ] && addon $((POS + 5)) "(S${IDX}) RSSI" "${T/dBm/} dBm" + T=$(echo "$O2" | awk -F[:,] '/lte_snr:/ {print $4}' | xargs) +# [ -n "$T" ] && [ "$T" != "NA" ] && addon $((POS + 8)) "(S${IDX}) SNR" "${T/dB/} dB" + + O1=$(echo "$O1" | sed '1,4d') +done + +T=$(echo "$O" | awk -F: '/^nr_band:/ {print $2}' | xargs) +if [ -n "$T" ]; then + MODE="$MODE / $(band5g ${T/n/})" + IDX=$((IDX + 1)) + + T1=$(echo "$O" | awk -F: '/^nr_band_width:/ {print $2}' | xargs) + if [ -n "$T1" ]; then + case $IDX in + 1) S1BAND="$(band5g ${T/n/}) @${T1/MHz/} MHz";; + 2) S2BAND="$(band5g ${T/n/}) @${T1/MHz/} MHz";; + 3) S3BAND="$(band5g ${T/n/}) @${T1/MHz/} MHz";; + 4) S4BAND="$(band5g ${T/n/}) @${T1/MHz/} MHz";; + *) ;; + esac + fi + + T=$(echo "$O" | awk -F: '/^nr_pci:/ {print $2}' | xargs) + if [ -n "$T" ]; then + case $IDX in + 1) S1PCI="$T";; + 2) S2PCI="$T";; + 3) S3PCI="$T";; + 4) S4PCI="$T";; + *) ;; + esac + fi + T=$(echo "$O" | awk -F: '/^nr_channel:/ {print $2}' | xargs) + if [ -n "$T" ]; then + case $IDX in + 1) S1EARFCN="$T";; + 2) S2EARFCN="$T";; + 3) S3EARFCN="$T";; + 4) S4EARFCN="$T";; + *) ;; + esac + fi + T=$(echo "$O" | awk -F: '/^nr_rsrp:/ {print $2}' | cut -f1 -d" ") +# [ -n "$T" ] && addon $((POS + 6)) "(S${IDX}) RSRP" "${T/dBm/} dBm" + T=$(echo "$O" | awk -F: '/^nr_rsrq:/ {print $2}' | xargs) +# [ -n "$T" ] && addon $((POS + 7)) "(S${IDX}) RSRQ" "${T/dB/} dB" + T=$(echo "$O" | awk -F: '/^nr_snr:/ {print $2}' | xargs) +# [ -n "$T" ] && [ "$T" != "NA" ] && addon $((POS + 8)) "(S${IDX}) SNR" "${T/dB/} dB" +fi + +fi + +MODE=$(echo $MODE | sed 's,/,+,'| sed 's,LTE B,LTE | B,') + + +# Modem + +MODELA=$(sms_tool -d $DEVICE at "AT+CGMM" | tr -s "\n" | xargs) +MODELB=$(sms_tool -d $DEVICE at "AT+CGMI" | tr -s "\n" | xargs) +MODELACUT=$(echo $MODELA | sed s/"AT+CGMM "//) +MODELBCUT=$(echo $MODELB | sed s/"AT+CGMI "//) +MODEL="$MODELBCUT "$MODELACUT + +FWA=$(sms_tool -d $DEVICE at "AT+CGMR" | tr -s "\n" | xargs) +FW=$(echo $FWA | sed s/"AT+CGMR "//) + +# International Mobile Equipment Identity (IMEI) +O=$(sms_tool -d $DEVICE at "AT+CGSN" | xargs) +NR_I=$(echo "$O" | sed s/"AT+CGSN "//) +if [ -n "$NR_I" ]; then + NR_IMEI="$NR_I" +fi + +# International Mobile Subscriber Identity (IMSI) +O=$(sms_tool -d $DEVICE at "AT+CIMI" | xargs) +NR_C=$(echo "$O" | sed s/"AT+CIMI "//) +if [ -n "$NR_C" ]; then + NR_IMSI="$NR_C" +fi + +# Integrated Circuit Card Identifier (ICCID) +O=$(sms_tool -d $DEVICE at "AT+ICCID") +NR_D=$(echo "$O" | awk -F [:] '/^\ICCID:/{print $2}' | xargs) +if [ -n "$NR_D" ]; then + NR_ICCID="$NR_D" +fi + +# Protocol +# DRIVER=QMI_WWAN & DRIVER=CDC_MBIM & DRIVER=CDC_ETHER + +PV=$(cat /sys/kernel/debug/usb/devices 2>/dev/null) +PVCUT=$(echo $PV | awk -F 'Vendor=1e2d ProdID=00b7' '{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