Skip to content

Commit

Permalink
Up to 1.0.70-20240510
Browse files Browse the repository at this point in the history
- Minor visual fixes
- Updated mccmnc.dat
- Updated scripts for BroadMobi BM806U (DLINK DWR-921 C1)
- Updated scripts for DW5821e Snapdragon X20 LTE
  • Loading branch information
4IceG authored May 10, 2024
1 parent 36793d5 commit bc2695c
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 403 deletions.
2 changes: 1 addition & 1 deletion luci-app-3ginfo-lite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({

Expand Down Expand Up @@ -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('<img style="width: 16px; height: 16px; vertical-align: middle;" src="%s"/>' + ' ' +_('Waiting for connection data...'), wicon, p);
}
else {
view.innerHTML = String.format('<img style="width: 16px; height: 16px; vertical-align: middle;" src="%s"/>' + ' ' + json.connt + ' ' + ' | \u25bc\u202f' + json.connrx + ' \u25b2\u202f' + json.conntx, ticon, t);
view.innerHTML = String.format('<img style="width: 16px; height: 16px; vertical-align: middle;" src="%s"/>' + ' ' + formatDuration(json.conn_time_sec) + ' ' + ' | \u25bc\u202f' + json.rx + ' \u25b2\u202f' + json.tx, ticon, t);
}
}

Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 1 addition & 29 deletions luci-app-3ginfo-lite/root/etc/uci-defaults/set_3ginfo_port.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

45 changes: 36 additions & 9 deletions luci-app-3ginfo-lite/root/usr/share/3ginfo-lite/3ginfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)";;
Expand Down Expand Up @@ -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
Expand All @@ -239,7 +262,7 @@ fi
fi
done
fi
# modemdefine config
# --- modemdefine config ---

CONN_TIME="-"
RX="-"
Expand All @@ -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
Expand All @@ -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=""
Expand All @@ -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"
Expand Down Expand Up @@ -445,9 +470,11 @@ fi

cat <<EOF
{
"connt":"$CONN_TIME",
"conntx":"$TX",
"connrx":"$RX",
"conn_time":"$CONN_TIME",
"conn_time_sec":"$CT",
"conn_time_since":"$CONN_TIME_SINCE",
"rx":"$RX",
"tx":"$TX",
"modem":"$MODEL",
"mtemp":"$TEMP",
"firmware":"$FW",
Expand Down
Loading

0 comments on commit bc2695c

Please sign in to comment.