From ebd9ac759a0c4e9131887ad31d391c276e45bfdb Mon Sep 17 00:00:00 2001
From: ling <1042585959@qq.com>
Date: Sun, 24 Dec 2023 19:28:51 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0modem=E6=8F=92=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../luasrc/view/modem/modem_status.htm | 9 ++-
luci-app-modem/root/etc/init.d/modem | 16 +++--
.../root/usr/share/modem/fibocom.sh | 18 +++++-
.../root/usr/share/modem/modem_debug.sh | 4 +-
.../root/usr/share/modem/modem_info.sh | 24 ++++----
.../root/usr/share/modem/quectel.sh | 61 ++++++++-----------
6 files changed, 74 insertions(+), 58 deletions(-)
diff --git a/luci-app-modem/luasrc/view/modem/modem_status.htm b/luci-app-modem/luasrc/view/modem/modem_status.htm
index a1fc965..6a24c59 100644
--- a/luci-app-modem/luasrc/view/modem/modem_status.htm
+++ b/luci-app-modem/luasrc/view/modem/modem_status.htm
@@ -16,8 +16,13 @@
for ( var key in modems)
{
var modem=modems[key];
+ var mode="unknown mode";
+ if (modem["mode"]!=null) {
+ mode=modem["mode"].toUpperCase()
+ }
+
var state = '';
- var css = ''
+ var css = '';
switch (modem["connect_status"])
{
case 'connect':
@@ -51,7 +56,7 @@
);
modem_view += String.format(
'
<%:Mode%>: %s
',
- modem.mode.toUpperCase()
+ mode
);
modem_view += String.format(
'<%:Moblie Network%>: %s
',
diff --git a/luci-app-modem/root/etc/init.d/modem b/luci-app-modem/root/etc/init.d/modem
index 45db0bd..47005b6 100755
--- a/luci-app-modem/root/etc/init.d/modem
+++ b/luci-app-modem/root/etc/init.d/modem
@@ -326,7 +326,6 @@ stop_ncm()
get_modem_no()
{
local modem_number=$(uci -q get modem.@global[0].modem_number)
- echo "modem_number:$modem_number" >> /root/a
local modem_network
for i in $(seq 0 $((modem_number-1))); do
modem_network=$(uci -q get modem.modem$i.network)
@@ -336,7 +335,6 @@ get_modem_no()
break
fi
done
- echo "modem_no:$modem_no" >> /root/a
}
#获取实例运行状态(未使用)
@@ -437,6 +435,9 @@ dial()
#获取模组的拨号模式
[ -z "$modem_no" ] && return 0
local mode=$(uci -q get modem.modem$modem_no.mode)
+ if [ "$mode" = "unknown" ]; then
+ mode="qmi"
+ fi
#查看移动网络是否已经有配置在运行
local run_path="/tmp/modem"
@@ -494,10 +495,17 @@ stop_service()
rm -rf /tmp/modem
#停止qmi、mbim拨号
killall quectel-CM >/dev/null 2>&1
- #停止ecm、rndis、ncm拨号
+ #停止gobinet、ecm、rndis、ncm拨号
local modem_number=$(uci -q get modem.@global[0].modem_number)
for i in $(seq 0 $((modem_number-1))); do
modem_no=$i
- stop_ecm
+ local mode=$(uci -q get modem.modem$modem_no.mode)
+ case $mode in
+ "gobinet") stop_gobinet ;;
+ "ecm") stop_ecm ;;
+ "rndis") stop_rndis ;;
+ "ncm") stop_ncm ;;
+ "*") stop_ecm ;;
+ esac
done
}
diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh
index 0c55c8e..806d045 100755
--- a/luci-app-modem/root/usr/share/modem/fibocom.sh
+++ b/luci-app-modem/root/usr/share/modem/fibocom.sh
@@ -14,7 +14,7 @@ get_fibocom_mode()
"17") mode="qmi" ;; #-
"31") mode="qmi" ;; #-
"32") mode="qmi" ;;
- "32") mode="gobinet" ;;
+ # "32") mode="gobinet" ;;
"18") mode="ecm" ;;
"23") mode="ecm" ;; #-
"33") mode="ecm" ;; #-
@@ -97,9 +97,21 @@ fibocom_net_info()
net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+PSRAT: //g' | sed 's/\r//g')
#CSQ
+ local at_command="AT+CSQ"
+ csq=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'[ ,]+' '{print $2}')
+ if [ $CSQ = "99" ]; then
+ csq=""
+ fi
- #per(信号强度)
+ #PER(信号强度)
+ if [ -n "$csq" ]; then
+ per=$(($csq * 100/31))"%"
+ fi
+ #RSSI(信号接收强度)
+ if [ -n "$csq" ]; then
+ rssi=$((2 * $csq - 113))" dBm"
+ fi
}
# fibocom获取基站信息
@@ -248,7 +260,7 @@ get_fibocom_info()
#网络信息
fibocom_net_info
- # All_CSQ
+ return
# Fibocom_Cellinfo
#基站信息
diff --git a/luci-app-modem/root/usr/share/modem/modem_debug.sh b/luci-app-modem/root/usr/share/modem/modem_debug.sh
index 15198a6..ef3114c 100755
--- a/luci-app-modem/root/usr/share/modem/modem_debug.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_debug.sh
@@ -51,8 +51,8 @@ get_mode()
"fibocom") mode=$(get_fibocom_mode "$2") ;;
"simcom") mode=$(get_simcom_mode "$2") ;;
"*")
- debug "未适配该模块,尝试使用拨号工具自动拨号"
- mode="qmi"
+ debug "未适配该模块"
+ mode="unknown"
;;
esac
echo "$mode"
diff --git a/luci-app-modem/root/usr/share/modem/modem_info.sh b/luci-app-modem/root/usr/share/modem/modem_info.sh
index 9efe4ce..7481eb2 100755
--- a/luci-app-modem/root/usr/share/modem/modem_info.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_info.sh
@@ -26,16 +26,15 @@ init_modem_info()
#信号信息
net_type="-" #蜂窝网络类型
- csq="" #CSQ
- csq_per=""
- ssi="" #信号强度
+ csq="" #CSQ
+ per="" #信号强度
rssi="" #信号接收强度 RSSI
- ECIO="-" #参考信号接收质量 RSRQ ecio
- ECIO1=" " #参考信号接收质量 RSRQ ecio1
- RSCP="-" #参考信号接收功率 RSRP rscp0
- RSCP1=" " #参考信号接收功率 RSRP rscp1
- SINR="-" #信噪比 SINR rv["sinr"]
- NETMODE="-" #连接状态监控 rv["netmode"]
+ ECIO="-" #参考信号接收质量 RSRQ ecio
+ ECIO1=" " #参考信号接收质量 RSRQ ecio1
+ RSCP="-" #参考信号接收功率 RSRP rscp0
+ RSCP1=" " #参考信号接收功率 RSRP rscp1
+ SINR="-" #信噪比 SINR rv["sinr"]
+ NETMODE="-" #连接状态监控 rv["netmode"]
#基站信息
MCC=""
@@ -66,14 +65,13 @@ info_to_json()
\"phone\":\"$phone\",
\"net_type\":\"$net_type\",
- \"csq\":\"$csq\"
+ \"csq\":\"$csq\",
+ \"per\":\"$per\",
+ \"rssi\":\"$rssi\"
}"
}
-
-
- # echo $CSQ_RSSI
# echo $ECIO #参考信号接收质量 RSRQ ecio
# echo $ECIO1 #参考信号接收质量 RSRQ ecio1
# echo $RSCP #参考信号接收功率 RSRP rscp0
diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh
index 5774736..1aa1dd6 100755
--- a/luci-app-modem/root/usr/share/modem/quectel.sh
+++ b/luci-app-modem/root/usr/share/modem/quectel.sh
@@ -7,7 +7,7 @@ get_quectel_mode()
{
local at_port="$1"
local at_command='AT+QCFG="usbnet"'
- local mode_num=$(echo "$response" | sed -n '2p' | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
+ local mode_num=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
local mode
case "$mode_num" in
@@ -72,9 +72,11 @@ quectel_sim_info()
isp=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
isp="中国移动"
- elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then
+ # elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then
+ elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "CUCC" ] || [ "$isp" = "46001" ]; then
isp="中国联通"
- elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
+ # elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
+ elif [ "$isp" = "CHN-TELECOM" ] || [ "$isp" = "CTCC" ] || [ "$isp" = "46011" ]; then
isp="中国电信"
fi
@@ -106,8 +108,21 @@ quectel_net_info()
net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
#CSQ
- #per(信号强度)
+ local at_command="AT+CSQ"
+ csq=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'[ ,]+' '{print $2}')
+ if [ $CSQ = "99" ]; then
+ csq=""
+ fi
+ #PER(信号强度)
+ if [ -n "$csq" ]; then
+ per=$((csq * 100/31))"%"
+ fi
+
+ #RSSI(信号接收强度)
+ if [ -n "$csq" ]; then
+ rssi=$((2 * csq - 113))" dBm"
+ fi
}
#quectel
@@ -137,27 +152,6 @@ nr_bw() {
esac
}
-#查询信息强度
-All_CSQ()
-{
- debug "All_CSQ"
- #信号
- OX=$( sh modem_at.sh $at_port "AT+CSQ" |grep "+CSQ:")
- OX=$(echo $OX | tr 'a-z' 'A-Z')
- CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}")
- if [ $CSQ = "99" ]; then
- CSQ=""
- fi
- if [ -n "$CSQ" ]; then
- CSQ_PER=$(($CSQ * 100/31))"%"
- CSQ_RSSI=$((2 * CSQ - 113))" dBm"
- else
- CSQ="-"
- CSQ_PER="-"
- CSQ_RSSI="-"
- fi
-}
-
# SIMCOM获取基站信息
Quectel_Cellinfo()
{
@@ -302,7 +296,6 @@ get_quectel_info()
quectel_net_info
return
- # All_CSQ
# Quectel_Cellinfo
@@ -311,14 +304,14 @@ get_quectel_info()
NR_NSA=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",")
NR_SA=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",")
if [ -n "$NR_NSA" ]; then
- QENG=",,"$(echo $OX" " | grep -o -i "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",")
- QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,5\},[-0-9]\{1,3\},-[0-9]\{2,3\},[0-9]\{1,7\},[0-9]\{1,3\}.\{1,6\}")
- if [ -z "$QENG5" ]; then
- QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,3\},[-0-9]\{1,3\},-[0-9]\{2,3\}")
- if [ -n "$QENG5" ]; then
- QENG5=$QENG5",,"
- fi
- fi
+ QENG=",,"$(echo $OX" " | grep -o -i "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",")
+ QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,5\},[-0-9]\{1,3\},-[0-9]\{2,3\},[0-9]\{1,7\},[0-9]\{1,3\}.\{1,6\}")
+ if [ -z "$QENG5" ]; then
+ QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,3\},[-0-9]\{1,3\},-[0-9]\{2,3\}")
+ if [ -n "$QENG5" ]; then
+ QENG5=$QENG5",,"
+ fi
+ fi
elif [ -n "$NR_SA" ]; then
QENG=$(echo $NR_SA | tr " " ",")
QENG5=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",[ 0-9]\{3,4\},[0-9]\{2,3\},[0-9A-F]\{1,10\},[0-9]\{1,5\},[0-9A-F]\{2,6\},[0-9]\{6,7\},[0-9]\{1,3\},[0-9]\{1,2\},-[0-9]\{2,5\},-[0-9]\{2,3\},[-0-9]\{1,3\}")