-

- <%:Loading modem status...%>
+
+

+ <%:Loading modem status%>...
diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po
index f1eff7f..c08b353 100644
--- a/luci-app-modem/po/zh-cn/modem.po
+++ b/luci-app-modem/po/zh-cn/modem.po
@@ -19,16 +19,22 @@ msgstr "选择模组"
msgid "Check information about adapted modem on this page"
msgstr "在此页面查看已适配模组的信息"
-msgid "Loading modem status..."
+msgid "Loading modem information"
+msgstr "正在加载模组信息"
+
+msgid "Loading modem status"
msgstr "正在加载模组状态"
-msgid "Connect"
+msgid "Loading modem"
+msgstr "正在加载模组"
+
+msgid "connect"
msgstr "已连接"
-msgid "Disconnect"
+msgid "disconnect"
msgstr "未连接"
-msgid "Disabled"
+msgid "disabled"
msgstr "未启用"
msgid "Data Interface"
@@ -52,7 +58,7 @@ msgstr "AT命令"
msgid "Debugging Your Module with AT Command"
msgstr "使用AT命令调试你的模组"
-msgid "Modem Info"
+msgid "Modem Information"
msgstr "模组信息"
msgid "No modems found"
@@ -76,6 +82,9 @@ msgstr "移动网络"
msgid "UNKNOWN"
msgstr "未知"
+msgid "unknown"
+msgstr "未知"
+
msgid "Mobile network not found"
msgstr "未发现移动网络"
@@ -125,4 +134,202 @@ msgid "Authentication Type"
msgstr "认证类型"
msgid "NONE"
-msgstr "无"
\ No newline at end of file
+msgstr "无"
+
+msgid "Message"
+msgstr "信息"
+
+msgid "Base Information"
+msgstr "基本信息"
+
+msgid "Manufacturer"
+msgstr "制造商"
+
+msgid "Revision"
+msgstr "固件版本"
+
+msgid "AT Port"
+msgstr "AT串口"
+
+msgid "Temperature"
+msgstr "温度"
+
+msgid "Update Time"
+msgstr "更新时间"
+
+msgid "SIM Information"
+msgstr "SIM卡信息"
+
+msgid "ISP"
+msgstr "运营商"
+
+msgid "IMEI"
+msgstr "IMEI"
+
+msgid "IMSI"
+msgstr "IMSI"
+
+msgid "ICCID"
+msgstr "ICCID"
+
+msgid "SIM Number"
+msgstr "SIM卡号码"
+
+msgid "Network Information"
+msgstr "网络信息"
+
+msgid "Network Type"
+msgstr "网络类型"
+
+msgid "Cell Information"
+msgstr "小区信息"
+
+msgid "Network Mode"
+msgstr "网络模式"
+
+msgid "NR5G-SA Mode"
+msgstr "NR5G-SA 模式"
+
+msgid "EN-DC Mode"
+msgstr "EN-DC 模式"
+
+msgid "LTE Mode"
+msgstr "LTE 模式"
+
+msgid "WCDMA Mode"
+msgstr "WCDMA 模式"
+
+msgid "MCC"
+msgstr "移动国家代码"
+
+msgid "MNC"
+msgstr "移动网络代码"
+
+msgid "Duplex Mode"
+msgstr "双工模式"
+
+msgid "LAC"
+msgstr "位置区码"
+
+msgid "Cell ID"
+msgstr "小区ID"
+
+msgid "Physical Cell ID"
+msgstr "物理小区ID"
+
+msgid "TAC"
+msgstr "跟踪区编码"
+
+msgid "ARFCN"
+msgstr "绝对射频信道号"
+
+msgid "EARFCN"
+msgstr "E-UTRA绝对射频信道号"
+
+msgid "UARFCN"
+msgstr "UTRA绝对射频信道号"
+
+msgid "Band"
+msgstr "频段"
+
+msgid "Freq band indicator"
+msgstr "频带指示"
+
+msgid "UL Bandwidth"
+msgstr "上行带宽"
+
+msgid "DL Bandwidth"
+msgstr "下行带宽"
+
+msgid "RSRP"
+msgstr "参考信号接收功率"
+
+msgid "RSRQ"
+msgstr "参考信号接收质量"
+
+msgid "RSSI"
+msgstr "接收信号强度指示"
+
+msgid "SINR"
+msgstr "信号与干扰加噪声比"
+
+msgid "RSSNR"
+msgstr "信号干扰比"
+
+msgid "SCS"
+msgstr "NR子载波间隔"
+
+msgid "CQI"
+msgstr "信道质量指示"
+
+msgid "TX Power"
+msgstr "TX 功率"
+
+msgid "PSC"
+msgstr "主扰码"
+
+msgid "RAC"
+msgstr "路由区域码"
+
+msgid "RSCP"
+msgstr "接收信号码功率"
+
+msgid "Ec/Io"
+msgstr "Ec/Io"
+
+msgid "Ec/No"
+msgstr "Ec/No"
+
+msgid "Physical Channel"
+msgstr "物理信道"
+
+msgid "Spreading Factor"
+msgstr "扩频因子"
+
+msgid "Slot"
+msgstr "插槽格式"
+
+msgid "Speech Code"
+msgstr "语音编码"
+
+msgid "Compression Mode"
+msgstr "压缩模式"
+
+msgid "RxLev"
+msgstr "接收信号功率"
+
+msgid "CHN-CMCC"
+msgstr "中国移动"
+
+msgid "CMCC"
+msgstr "中国移动"
+
+msgid "46000"
+msgstr "中国移动"
+
+msgid "CHN-UNICOM"
+msgstr "中国联通"
+
+msgid "UNICOM"
+msgstr "中国联通"
+
+msgid "CUCC"
+msgstr "中国联通"
+
+msgid "46001"
+msgstr "中国联通"
+
+msgid "CHN-CT"
+msgstr "中国电信"
+
+msgid "CHN-TELECOM"
+msgstr "中国电信"
+
+msgid "CTCC"
+msgstr "中国电信"
+
+msgid "CT"
+msgstr "中国电信"
+
+msgid "46011"
+msgstr "中国电信"
diff --git a/luci-app-modem/root/etc/init.d/modem b/luci-app-modem/root/etc/init.d/modem
index 47005b6..d266a91 100755
--- a/luci-app-modem/root/etc/init.d/modem
+++ b/luci-app-modem/root/etc/init.d/modem
@@ -25,7 +25,7 @@ USE_PROCD=1
# "mbim") mode_num='2' ;;
# "rndis") mode_num='3' ;;
# "ncm") mode_num='5' ;;
-# "*") mode_num='0' ;;
+# *) mode_num='0' ;;
# esac
# #查询当前拨号模式
@@ -41,7 +41,7 @@ USE_PROCD=1
# "mbim") command='AT+QCFG="usbnet",2' ;;
# "rndis") command='AT+QCFG="usbnet",3' ;;
# "ncm") command='AT+QCFG="usbnet",5' ;;
-# "*") command='AT+QCFG="usbnet",0' ;;
+# *) command='AT+QCFG="usbnet",0' ;;
# esac
# at_result=$(sh /usr/share/modem/modem_at.sh "$at_port" "$command")
# #移远切换模式后,还需要重启模块,待测试
@@ -58,7 +58,7 @@ USE_PROCD=1
# "mbim") mode_num='29' ;;
# "rndis") mode_num='24' ;;
# "ncm") mode_num='23' ;;
-# "*") mode_num='32' ;;
+# *) mode_num='32' ;;
# esac
# #查询当前拨号模式
@@ -73,7 +73,7 @@ USE_PROCD=1
# "mbim") command='AT+GTUSBMODE=29' ;;
# "rndis") command='AT+GTUSBMODE=24' ;;
# "ncm") command='AT+GTUSBMODE=23' ;;
-# "*") command='AT+GTUSBMODE=32' ;;
+# *) command='AT+GTUSBMODE=32' ;;
# esac
# at_result=$(sh /usr/share/modem/modem_at.sh "$at_port" "$command")
# sleep 5
@@ -157,7 +157,7 @@ set_interface()
set_ipv4_interface "wwan_5g_$1" $2
set_ipv6_interface "wwan6_5g_$1" $2
;;
- "*")
+ *)
set_ipv4_interface "wwan_5g_$1" $2
set_ipv6_interface "wwan6_5g_$1" $2
;;
@@ -185,7 +185,7 @@ qmi()
"ipv4") procd_append_param command -4 ;;
"ipv6") procd_append_param command -6 ;;
"ipv4_ipv6") procd_append_param command -4 -6 ;;
- "*") procd_append_param command -4 -6 ;;
+ *) procd_append_param command -4 -6 ;;
esac
if [ "$apn" != "" ]; then
@@ -505,7 +505,7 @@ stop_service()
"ecm") stop_ecm ;;
"rndis") stop_rndis ;;
"ncm") stop_ncm ;;
- "*") stop_ecm ;;
+ *) 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 806d045..40331ba 100755
--- a/luci-app-modem/root/usr/share/modem/fibocom.sh
+++ b/luci-app-modem/root/usr/share/modem/fibocom.sh
@@ -22,11 +22,36 @@ get_fibocom_mode()
"30") mode="mbim" ;;
"24") mode="rndis" ;;
"18") mode='ncm' ;;
- "*") mode="$mode_num" ;;
+ *) mode="$mode_num" ;;
esac
echo "$mode"
}
+#获取SIM卡状态
+get_fibocom_sim_status()
+{
+ debug "检查SIM状态"
+ local sim_status
+
+ local at_command="AT+CPIN?"
+ local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ local sim_error=$(echo "$response" | grep "ERROR")
+ if [ -n "$sim_error" ]; then
+ debug "未插入SIM卡"
+ sim_status="miss"
+ return
+ fi
+ local sim_ready=$(echo "$response" | grep "READY")
+ if [ -n "$sim_ready" ]; then
+ debug "SIM卡正常"
+ sim_status="ready"
+ else
+ debug "SIM卡被锁定"
+ sim_status="locked"
+ return
+ fi
+ echo "$sim_status"
+}
#基本信息
fibocom_base_info()
@@ -62,13 +87,13 @@ fibocom_sim_info()
#ISP(互联网服务提供商)
local at_command="AT+COPS?"
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
- isp="中国联通"
- elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
- isp="中国电信"
- fi
+ # if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
+ # isp="中国移动"
+ # elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then
+ # isp="中国联通"
+ # elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
+ # isp="中国电信"
+ # fi
#IMEI
at_command="AT+CGSN"
@@ -81,39 +106,235 @@ fibocom_sim_info()
#ICCID
at_command="AT+ICCID"
iccid=$(sh $current_dir/modem_at.sh $at_port $at_command | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
-
+
#SIM卡号码(手机号)
at_command="AT+CNUM?"
- phone=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
+ sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
}
#网络信息
-fibocom_net_info()
+fibocom_network_info()
{
- debug "Fibocom net info"
+ debug "Fibocom network info"
#Network Type(网络类型)
local at_command="AT+PSRAT?"
- net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+PSRAT: //g' | sed 's/\r//g')
+ network_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
+ # #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(信号强度)
- if [ -n "$csq" ]; then
- per=$(($csq * 100/31))"%"
- fi
+ # #PER(信号强度)
+ # if [ -n "$csq" ]; then
+ # per=$(($csq * 100/31))"%"
+ # fi
- #RSSI(信号接收强度)
- if [ -n "$csq" ]; then
- rssi=$((2 * $csq - 113))" dBm"
- fi
+ # #RSSI(信号接收强度)
+ # if [ -n "$csq" ]; then
+ # rssi=$((2 * $csq - 113))" dBm"
+ # fi
}
+#获取上行带宽
+# $1:上行带宽数字
+get_ul_bandwidth()
+{
+ local ul_bandwidth
+ case $1 in
+ "6") ul_bandwidth="1.4" ;;
+ "15"|"25"|"50"|"75"|"100") ul_bandwidth=$(( $1 / 5 )) ;;
+ esac
+ echo "$ul_bandwidth"
+}
+
+#获取下行带宽
+# $1:下行带宽数字
+get_dl_bandwidth()
+{
+ local dl_bandwidth
+ case $1 in
+ "6") ul_bandwidth="1.4" ;;
+ "15"|"25"|"50"|"75"|"100") ul_bandwidth=$(( $1 / 5 )) ;;
+ esac
+ echo "$dl_bandwidth"
+}
+
+#获取NR下行带宽
+# $1:下行带宽数字
+get_nr_dl_bandwidth()
+{
+ local nr_dl_bandwidth
+ case $1 in
+ "0") nr_dl_bandwidth="5" ;;
+ "10"|"15"|"20"|"25"|"30"|"40"|"50"|"60"|"70"|"80"|"90"|"100"|"200"|"400") nr_dl_bandwidth="$1" ;;
+ esac
+ echo "$nr_dl_bandwidth"
+}
+
+#获取参考信号接收功率
+# $1:网络类型
+# $2:参考信号接收功率数字
+get_rsrp()
+{
+ local rsrp
+ case $1 in
+ "LTE") rsrp=$(($2-141)) ;;
+ "NR") rsrp=$(($2-157)) ;;
+ esac
+ echo "$rsrp"
+}
+
+#获取参考信号接收质量
+# $1:网络类型
+# $2:参考信号接收质量数字
+get_rsrq()
+{
+ local rsrq
+ case $1 in
+ "LTE") rsrq=$(awk 'BEGIN{ printf "%.2f", $2 * 0.5 - 20 }' | sed 's/\.*0*$//') ;;
+ "NR") rsrq=$(awk -v num="$2" 'BEGIN{ printf "%.2f", (num+1) * 0.5 - 44 }' | sed 's/\.*0*$//') ;;
+ esac
+ echo "$rsrq"
+}
+
+#获取信号干扰比
+# $1:信号干扰比数字
+get_rssnr()
+{
+ #去掉小数点后的0
+ local rssnr=$(awk 'BEGIN{ printf "%.2f", $1 / 2 }' | sed 's/\.*0*$//')
+ echo "$rssnr"
+}
+
+#获取接收信号功率
+# $1:网络类型
+# $2:接收信号功率数字
+get_rxlev()
+{
+ local rxlev
+ case $1 in
+ "WCDMA") rxlev=$(($2-121)) ;;
+ "LTE") rxlev=$(($2-141)) ;;
+ "NR") rxlev=$(($2-157)) ;;
+ esac
+ echo "$rxlev"
+}
+
+
+#网络信息
+fibocom_cell_info()
+{
+ debug "Fibocom cell info"
+
+ #RSRQ,RSRP,SINR
+ at_command='AT+GTCCINFO?'
+ local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ local rat=$(echo "$response" | grep "service" | awk -F' ' '{print $1}')
+ response=$(echo "$response" | sed -n '4p')
+ case $rat in
+ "NR")
+ network_mode="NR5G-SA Mode"
+ nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ nr_tac=$(echo "$response" | awk -F',' '{print $5}')
+ nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
+ nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ nr_band=$(echo "$response" | awk -F',' '{print $9}')
+ nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
+ nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ nr_rxlev=$(get_rxlev "NR" $nr_rxlev_num)
+ nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ nr_rsrp=$(get_rsrp "NR" $nr_rsrp_num)
+ nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ nr_rsrq=$(get_rsrq "NR" $nr_rsrq_num)
+ ;;
+ "LTE-NR")
+ network_mode="EN-DC Mode"
+ #LTE
+ endc_lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ endc_lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ endc_lte_tac=$(echo "$response" | awk -F',' '{print $5}')
+ endc_lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ endc_lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
+ endc_lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ endc_lte_band=$(echo "$response" | awk -F',' '{print $9}')
+ ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ endc_lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
+ endc_lte_dl_bandwidth="$endc_lte_ul_bandwidth"
+ endc_lte_rssnr_num=$(echo "$response" | awk -F',' '{print $11}')
+ endc_lte_rssnr=$(get_rssnr $endc_lte_rssnr_num)
+ endc_lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ endc_lte_rxlev=$(get_rxlev "LTE" $endc_lte_rxlev_num)
+ endc_lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ endc_lte_rsrp=$(get_rsrp "LTE" $endc_lte_rsrp_num)
+ endc_lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ endc_lte_rsrq=$(get_rsrq "LTE" $endc_lte_rsrq_num)
+ #NR5G-NSA
+ endc_nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ endc_nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ endc_nr_tac=$(echo "$response" | awk -F',' '{print $5}')
+ endc_nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ endc_nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
+ endc_nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ endc_nr_band=$(echo "$response" | awk -F',' '{print $9}')
+ nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ endc_nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ endc_nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
+ endc_nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ endc_nr_rxlev=$(get_rxlev "NR" $endc_nr_rxlev_num)
+ endc_nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ endc_nr_rsrp=$(get_rsrp "NR" $endc_nr_rsrp_num)
+ endc_nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ endc_nr_rsrq=$(get_rsrq "NR" $endc_nr_rsrq_num)
+ ;;
+ "LTE"|"eMTC"|"NB-IoT")
+ network_mode="LTE Mode"
+ lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ lte_tac=$(echo "$response" | awk -F',' '{print $5}')
+ lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
+ lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ lte_band=$(echo "$response" | awk -F',' '{print $9}')
+ ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
+ lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
+ lte_dl_bandwidth="$lte_ul_bandwidth"
+ lte_rssnr=$(echo "$response" | awk -F',' '{print $11}')
+ lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
+ lte_rxlev=$(get_rxlev "LTE" $lte_rxlev_num)
+ lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
+ lte_rsrp=$(get_rsrp "LTE" $lte_rsrp_num)
+ lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
+ lte_rsrq=$(get_rsrq "LTE" $lte_rsrq_num)
+ ;;
+ "WCDMA"|"UMTS")
+ network_mode="WCDMA Mode"
+ wcdma_mcc=$(echo "$response" | awk -F',' '{print $3}')
+ wcdma_mnc=$(echo "$response" | awk -F',' '{print $4}')
+ wcdma_lac=$(echo "$response" | awk -F',' '{print $5}')
+ wcdma_cell_id=$(echo "$response" | awk -F',' '{print $6}')
+ wcdma_uarfcn=$(echo "$response" | awk -F',' '{print $7}')
+ wcdma_psc=$(echo "$response" | awk -F',' '{print $8}')
+ wcdma_band=$(echo "$response" | awk -F',' '{print $9}')
+ wcdma_ecno=$(echo "$response" | awk -F',' '{print $10}')
+ wcdma_rscp=$(echo "$response" | awk -F',' '{print $11}')
+ wcdma_rac=$(echo "$response" | awk -F',' '{print $12}')
+ wcdma_rxlev_num=$(echo "$response" | awk -F',' '{print $13}')
+ wcdma_rxlev=$(get_rxlev "WCDMA" $wcdma_rxlev_num)
+ wcdma_reserved=$(echo "$response" | awk -F',' '{print $14}')
+ wcdma_ecio=$(echo "$response" | awk -F',' '{print $15}' | sed 's/\r//g')
+ ;;
+ esac
+}
+
+
# fibocom获取基站信息
Fibocom_Cellinfo()
{
@@ -255,10 +476,19 @@ get_fibocom_info()
#基本信息
fibocom_base_info
+
+ #获取SIM状态
+ sim_status=$(get_fibocom_sim_status)
+ if [ "$sim_status" != "ready" ];then
+ return
+ fi
+
#SIM卡信息
fibocom_sim_info
#网络信息
- fibocom_net_info
+ fibocom_network_info
+ #小区信息
+ fibocom_cell_info
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 ef3114c..eb641a6 100755
--- a/luci-app-modem/root/usr/share/modem/modem_debug.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_debug.sh
@@ -50,10 +50,10 @@ get_mode()
"quectel") mode=$(get_quectel_mode "$2") ;;
"fibocom") mode=$(get_fibocom_mode "$2") ;;
"simcom") mode=$(get_simcom_mode "$2") ;;
- "*")
+ *)
debug "未适配该模块"
mode="unknown"
- ;;
+ ;;
esac
echo "$mode"
}
\ No newline at end of file
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 7481eb2..111cb06 100755
--- a/luci-app-modem/root/usr/share/modem/modem_info.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_info.sh
@@ -13,72 +13,295 @@ init_modem_info()
manufacturer='' #制造商
revision='-' #固件版本
at_port='-' #AT串口
- mode='' #拨号模式
+ mode='unknown' #拨号模式
temperature="NaN $(printf "\xc2\xb0")C" #温度
update_time='' #更新时间
#SIM卡信息
- isp="-" #运营商(互联网服务提供商)
- imei='-' #IMEI
- imsi='-' #IMSI
- iccid='-' #ICCID
- phone='-' #SIM卡号码(手机号)
+ sim_status="miss" #SIM卡状态
+ isp="-" #运营商(互联网服务提供商)
+ imei='-' #IMEI
+ imsi='-' #IMSI
+ iccid='-' #ICCID
+ sim_number='-' #SIM卡号码(手机号)
+
+ #网络信息
+ network_type="-" #蜂窝网络类型
+
+ #小区信息
+ network_mode="-" #网络模式
+ #NR5G-SA模式
+ nr_mcc=''
+ nr_mnc=''
+ nr_duplex_mode=''
+ nr_cell_id=''
+ nr_physical_cell_id=''
+ nr_tac=''
+ nr_arfcn=''
+ nr_band=''
+ nr_dl_bandwidth=''
+ nr_rsrp=''
+ nr_rsrq=''
+ nr_sinr=''
+ nr_scs=''
+ nr_rxlev=''
+ #EN-DC模式(LTE)
+ endc_lte_mcc=''
+ endc_lte_mnc=''
+ endc_lte_duplex_mode=''
+ endc_lte_cell_id=''
+ endc_lte_physical_cell_id=''
+ endc_lte_earfcn=''
+ endc_lte_freq_band_ind=''
+ endc_lte_ul_bandwidth=''
+ endc_lte_dl_bandwidth=''
+ endc_lte_tac=''
+ endc_lte_rsrp=''
+ endc_lte_rsrq=''
+ endc_lte_rssi=''
+ endc_lte_sinr=''
+ endc_lte_cql=''
+ endc_lte_tx_power=''
+ endc_lte_rxlev=''
+ #EN-DC模式(NR5G-NSA)
+ endc_nr_mcc=''
+ endc_nr_mnc=''
+ endc_nr_physical_cell_id=''
+ endc_nr_arfcn=''
+ endc_nr_band=''
+ endc_nr_dl_bandwidth=''
+ endc_nr_rsrp=''
+ endc_nr_rsrq=''
+ endc_nr_sinr=''
+ endc_nr_scs=''
+ #LTE模式
+ lte_mcc=''
+ lte_mnc=''
+ lte_duplex_mode=''
+ lte_cell_id=''
+ lte_physical_cell_id=''
+ lte_earfcn=''
+ lte_freq_band_ind=''
+ lte_ul_bandwidth=''
+ lte_dl_bandwidth=''
+ lte_tac=''
+ lte_rsrp=''
+ lte_rsrq=''
+ lte_rssi=''
+ lte_sinr=''
+ lte_cql=''
+ lte_tx_power=''
+ lte_rxlev=''
+ #WCDMA模式
+ wcdma_mcc=''
+ wcdma_mnc=''
+ wcdma_lac=''
+ wcdma_cell_id=''
+ wcdma_uarfcn=''
+ wcdma_psc=''
+ wcdma_rac=''
+ wcdma_rscp=''
+ wcdma_ecio=''
+ wcdma_phych=''
+ wcdma_sf=''
+ wcdma_slot=''
+ wcdma_speech_code=''
+ wcdma_com_mod=''
#信号信息
- net_type="-" #蜂窝网络类型
csq="" #CSQ
per="" #信号强度
rssi="" #信号接收强度 RSSI
- ECIO="-" #参考信号接收质量 RSRQ ecio
- ECIO1=" " #参考信号接收质量 RSRQ ecio1
+ ecio="-" #参考信号接收质量 RSRQ ecio
+ ecio1=" " #参考信号接收质量 RSRQ ecio1
RSCP="-" #参考信号接收功率 RSRP rscp0
RSCP1=" " #参考信号接收功率 RSRP rscp1
SINR="-" #信噪比 SINR rv["sinr"]
NETMODE="-" #连接状态监控 rv["netmode"]
#基站信息
- MCC=""
+ mcc="-"
+ mnc="-"
eNBID=""
TAC=""
cell_id=""
LBAND="-" #频段
- CHANNEL="-" #频点
+ channel="-" #频点
PCI="-" #物理小区标识
qos="" #最大Qos级别
}
-#保存模块数据
-info_to_json()
+#获取基本信息
+get_base_info()
{
- modem_info="{
+ base_info="\"base_info\":{
\"manufacturer\":\"$manufacturer\",
\"revision\":\"$revision\",
\"at_port\":\"$at_port\",
\"mode\":\"$mode\",
\"temperature\":\"$temperature\",
- \"update_time\":\"$update_time\",
+ \"update_time\":\"$update_time\"
+ },"
+}
+#获取SIM卡信息
+get_sim_info()
+{
+ sim_info="\"sim_info\":{
\"isp\":\"$isp\",
\"imei\":\"$imei\",
\"imsi\":\"$imsi\",
\"iccid\":\"$iccid\",
- \"phone\":\"$phone\",
+ \"sim_number\":\"$sim_number\"
+ },"
+}
- \"net_type\":\"$net_type\",
- \"csq\":\"$csq\",
- \"per\":\"$per\",
- \"rssi\":\"$rssi\"
+#获取网络信息
+get_network_info()
+{
+ network_info="\"network_info\":{
+ \"network_type\":\"$network_type\"
+ },"
+}
-
- }"
+#获取信号信息
+get_cell_info()
+{
+ if [ "$network_mode" = "NR5G-SA Mode" ]; then
+ cell_info="\"cell_info\":{
+ \"NR5G-SA Mode\":[
+ {\"MCC\":\"$nr_mcc\", \"full_name\":\"Mobile Country Code\"},
+ {\"MNC\":\"$nr_mnc\", \"full_name\":\"Mobile Network Code\"},
+ {\"Duplex Mode\":\"$nr_duplex_mode\", \"full_name\":\"Duplex Mode\"},
+ {\"Cell ID\":\"$nr_cell_id\", \"full_name\":\"Cell ID\"},
+ {\"Physical Cell ID\":\"$nr_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
+ {\"TAC\":\"$nr_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"},
+ {\"ARFCN\":\"$nr_arfcn\", \"full_name\":\"Absolute Radio-Frequency Channel Number\"},
+ {\"Band\":\"$nr_band\", \"full_name\":\"Band\"},
+ {\"DL Bandwidth\":\"$nr_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
+ {\"RSRP\":\"$nr_rsrp\", \"full_name\":\"Reference Signal Received Power\"},
+ {\"RSRQ\":\"$nr_rsrq\", \"full_name\":\"Reference Signal Received Quality\"},
+ {\"SINR\":\"$nr_sinr\", \"full_name\":\"Signal to Interference plus Noise Ratio Bandwidth\"},
+ {\"SCS\":\"$nr_scs\", \"full_name\":\"SCS\"},
+ {\"RxLev\":\"$nr_rxlev\", \"full_name\":\"Received Signal Level\"}
+ ]
+ }"
+ elif [ "$network_mode" = "EN-DC Mode" ]; then
+ cell_info="\"cell_info\":{
+ \"EN-DC Mode\":[
+ {\"LTE\":[
+ {\"MCC\":\"$endc_lte_mcc\", \"full_name\":\"Mobile Country Code\"},
+ {\"MNC\":\"$endc_lte_mnc\", \"full_name\":\"Mobile Network Code\"},
+ {\"Duplex Mode\":\"$endc_lte_duplex_mode\", \"full_name\":\"Duplex Mode\"},
+ {\"Cell ID\":\"$endc_lte_cell_id\", \"full_name\":\"Cell ID\"},
+ {\"Physical Cell ID\":\"$endc_lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
+ {\"EARFCN\":\"$endc_lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"},
+ {\"Freq band indicator\":\"$endc_lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"},
+ {\"UL Bandwidth\":\"$endc_lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"},
+ {\"DL Bandwidth\":\"$endc_lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
+ {\"TAC\":\"$endc_lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"},
+ {\"RSRP\":\"$endc_lte_rsrp\", \"full_name\":\"Reference Signal Received Power\"},
+ {\"RSRQ\":\"$endc_lte_rsrq\", \"full_name\":\"Reference Signal Received Quality\"},
+ {\"RSSI\":\"$endc_lte_rssi\", \"full_name\":\"Received Signal Strength Indicator\"},
+ {\"SINR\":\"$endc_lte_sinr\", \"full_name\":\"Signal to Interference plus Noise Ratio Bandwidth\"},
+ {\"RSSNR\":\"$endc_lte_rssnr\", \"full_name\":\"Radio Signal Strength Noise Ratio\"},
+ {\"CQI\":\"$endc_lte_cql\", \"full_name\":\"Channel Quality Indicator\"},
+ {\"TX Power\":\"$endc_lte_tx_power\", \"full_name\":\"TX Power\"},
+ {\"RxLev\":\"$endc_lte_rxlev\", \"full_name\":\"Received Signal Level\"}
+ ]
+ },
+
+ {\"NR5G-NSA\":[
+ {\"MCC\":\"$endc_nr_mcc\", \"full_name\":\"Mobile Country Code\"},
+ {\"MNC\":\"$endc_nr_mnc\", \"full_name\":\"Mobile Network Code\"},
+ {\"Physical Cell ID\":\"$endc_nr_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
+ {\"ARFCN\":\"$endc_nr_arfcn\", \"full_name\":\"Absolute Radio-Frequency Channel Number\"},
+ {\"Band\":\"$endc_nr_band\", \"full_name\":\"Band\"},
+ {\"DL Bandwidth\":\"$endc_nr_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
+ {\"RSRP\":\"$endc_nr_rsrp\", \"full_name\":\"Reference Signal Received Power\"},
+ {\"RSRQ\":\"$endc_nr_rsrq\", \"full_name\":\"Reference Signal Received Quality\"},
+ {\"SINR\":\"$endc_nr_sinr\", \"full_name\":\"Signal to Interference plus Noise Ratio Bandwidth\"},
+ {\"SCS\":\"$endc_nr_scs\", \"full_name\":\"SCS\"}
+ ]
+ }
+ ]
+ }"
+ elif [ "$network_mode" = "LTE Mode" ]; then
+ cell_info="\"cell_info\":{
+ \"LTE Mode\":[
+ {\"MCC\":\"$lte_mcc\", \"full_name\":\"Mobile Country Code\"},
+ {\"MNC\":\"$lte_mnc\", \"full_name\":\"Mobile Network Code\"},
+ {\"Duplex Mode\":\"$lte_duplex_mode\", \"full_name\":\"Duplex Mode\"},
+ {\"Cell ID\":\"$lte_cell_id\", \"full_name\":\"Cell ID\"},
+ {\"Physical Cell ID\":\"$lte_physical_cell_id\", \"full_name\":\"Physical Cell ID\"},
+ {\"EARFCN\":\"$lte_earfcn\", \"full_name\":\"E-UTRA Absolute Radio Frequency Channel Number\"},
+ {\"Freq band indicator\":\"$lte_freq_band_ind\", \"full_name\":\"Freq band indicator\"},
+ {\"UL Bandwidth\":\"$lte_ul_bandwidth\", \"full_name\":\"UL Bandwidth\"},
+ {\"DL Bandwidth\":\"$lte_dl_bandwidth\", \"full_name\":\"DL Bandwidth\"},
+ {\"TAC\":\"$lte_tac\", \"full_name\":\"Tracking area code of cell servedby neighbor Enb\"},
+ {\"RSRP\":\"$lte_rsrp\", \"full_name\":\"Reference Signal Received Power\"},
+ {\"RSRQ\":\"$lte_rsrq\", \"full_name\":\"Reference Signal Received Quality\"},
+ {\"RSSI\":\"$lte_rssi\", \"full_name\":\"Received Signal Strength Indicator\"},
+ {\"SINR\":\"$lte_sinr\", \"full_name\":\"Signal to Interference plus Noise Ratio Bandwidth\"},
+ {\"RSSNR\":\"$lte_rssnr\", \"full_name\":\"Radio Signal Strength Noise Ratio\"},
+ {\"CQI\":\"$lte_cql\", \"full_name\":\"Channel Quality Indicator\"},
+ {\"TX Power\":\"$lte_tx_power\", \"full_name\":\"TX Power\"},
+ {\"RxLev\":\"$lte_rxlev\", \"full_name\":\"RxLev\"}
+ ]
+ }"
+ elif [ "$network_mode" = "WCDMA Mode" ]; then
+ cell_info="\"cell_info\":{
+ \"WCDMA Mode\":[
+ {\"MCC\":\"$wcdma_mcc\", \"full_name\":\"Mobile Country Code\"},
+ {\"MNC\":\"$wcdma_mnc\", \"full_name\":\"Mobile Network Code\"},
+ {\"LAC\":\"$wcdma_lac\", \"full_name\":\"Location Area Code\"},
+ {\"Cell ID\":\"$wcdma_cell_id\", \"full_name\":\"Cell ID\"},
+ {\"UARFCN\":\"$wcdma_uarfcn\", \"full_name\":\"UTRA Absolute Radio Frequency Channel Number\"},
+ {\"PSC\":\"$wcdma_psc\", \"full_name\":\"Primary Scrambling Code\"},
+ {\"RAC\":\"$wcdma_rac\", \"full_name\":\"Routing Area Code\"},
+ {\"RSCP\":\"$wcdma_rscp\", \"full_name\":\"Received Signal Code Power\"},
+ {\"Ec/Io\":\"$wcdma_ecio\", \"full_name\":\"Ec/Io\"},
+ {\"Ec/No\":\"$wcdma_ecno\", \"full_name\":\"Ec/No\"},
+ {\"Physical Channel\":\"$wcdma_phych\", \"full_name\":\"Physical Channel\"},
+ {\"Spreading Factor\":\"$wcdma_sf\", \"full_name\":\"Spreading Factor\"},
+ {\"Slot\":\"$wcdma_slot\", \"full_name\":\"Slot\"},
+ {\"Speech Code\":\"$wcdma_speech_code\", \"full_name\":\"Speech Code\"},
+ {\"Compression Mode\":\"$wcdma_com_mod\", \"full_name\":\"Compression Mode\"},
+ {\"RxLev\":\"$wcdma_rxlev\", \"full_name\":\"RxLev\"}
+ ]
+ }"
+ fi
+}
+
+#以Json格式保存模组信息
+info_to_json()
+{
+ base_info="\"base_info\":{},"
+ sim_info="\"sim_info\":{},"
+ network_info="\"network_info\":{},"
+ cell_info="\"cell_info\":{}"
+
+ #获取基本信息
+ get_base_info
+
+ if [ "$sim_status" = "ready" ];then
+ #获取SIM卡信息
+ get_sim_info
+ #获取网络信息
+ get_network_info
+ #获取小区信息
+ get_cell_info
+ fi
+
+ #拼接所有信息(不要漏掉最后一个})
+ modem_info="{$base_info$modem_info$sim_info$network_info$cell_info}"
}
# echo $ECIO #参考信号接收质量 RSRQ ecio
# echo $ECIO1 #参考信号接收质量 RSRQ ecio1
# echo $RSCP #参考信号接收功率 RSRP rscp0
# echo $RSCP1 #参考信号接收功率 RSRP rscp1
# echo $SINR #信噪比 SINR rv["sinr"]
- # echo $NETMODE #连接状态监控 rv["netmode"]
- # echo '---------------------------------'
+
# #基站信息
# echo $COPS_MCC #MCC
# echo $$COPS_MNC #MNC
@@ -89,7 +312,7 @@ info_to_json()
# echo $CID
# echo '' #CID_NUM
# echo $LBAND
- # echo $CHANNEL
+ # echo $channel
# echo $PCI
# echo $MODTYPE
# echo $QTEMP
@@ -99,37 +322,20 @@ get_modem_info()
{
update_time=$(date +"%Y-%m-%d %H:%M:%S")
- debug "检查模块的AT串口"
+ debug "检查模组的AT串口"
#获取模块AT串口
if [ -z "$at_port" ]; then
- debug "模块0没有找到AT串口"
+ debug "模组没有AT串口"
return
fi
- debug "检查SIM状态"
- local sim_status=$(echo `sh $current_dir/modem_at.sh $at_port "AT+CPIN?"`)
- local sim_error=$(echo "$sim_status" | grep "ERROR")
- if [ -n "$sim_error" ]; then
- debug "未插入SIM卡"
- sleep 1s
- return
- fi
- local sim_ready=$(echo "$sim_status" | grep "READY")
- if [ -n "$sim_ready" ]; then
- debug "SIM卡正常"
- else
- debug "SIM卡被锁定"
- sleep 1s
- return
- fi
-
- debug "根据模块类型开始采集数据"
+ debug "根据模组的制造商获取信息"
#更多信息获取
case $manufacturer in
"quectel") get_quectel_info $at_port ;;
"fibocom") get_fibocom_info $at_port ;;
"simcom") get_simcom_info $at_port ;;
- "*") debug "未适配该模块" ;;
+ *) debug "未适配该模组" ;;
esac
#获取更新时间
diff --git a/luci-app-modem/root/usr/share/modem/modem_scan.sh b/luci-app-modem/root/usr/share/modem/modem_scan.sh
index 85f0131..0275cba 100755
--- a/luci-app-modem/root/usr/share/modem/modem_scan.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_scan.sh
@@ -126,11 +126,19 @@ setModemInfoConfig()
if [ "$data_interface" = "$data_interface_info" ]; then
#获取模块名
local modem_name=$(echo "$line_context" | cut -d ";" -f 2)
- #获取AT命令返回的内容
- local at_result=$(echo `sh $current_dir/modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
+
+ local at_result
+ if [ "$modem_name" != "unknown" ]; then
+ #获取AT命令返回的内容
+ at_result=$(echo `sh $current_dir/modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
+ else
+ #数据库中没有此模块的信息,使用默认值
+ at_result="unknown"
+ fi
+
if [[ "$at_result" = *"$modem_name"* ]]; then
#设置模块名
- uci set modem.modem$1.name="$modem_name"
+ uci set modem.modem$1.name="$modem_name"
#设置制造商
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
@@ -152,22 +160,22 @@ setModemInfoConfig()
break
fi
- #数据库中没有此模块的信息,使用默认值
- if [ $i -ge $(($line_count-1)) ]; then
+ # #数据库中没有此模块的信息,使用默认值
+ # if [ $i -ge $(($line_count-1)) ]; then
- #设置模块名
- uci set modem.modem$1.name="$modem_name"
- #设置制造商
- local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
- uci set modem.modem$1.manufacturer="$manufacturer"
- #删除原来的拨号模式列表
- uci -q del modem.modem$1.modes
- #添加新的拨号模式列表
- for mode in $modes; do
- uci add_list modem.modem$1.modes="$mode"
- done
- break
- fi
+ # #设置模块名
+ # uci set modem.modem$1.name="$modem_name"
+ # #设置制造商
+ # local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
+ # uci set modem.modem$1.manufacturer="$manufacturer"
+ # #删除原来的拨号模式列表
+ # uci -q del modem.modem$1.modes
+ # #添加新的拨号模式列表
+ # for mode in $modes; do
+ # uci add_list modem.modem$1.modes="$mode"
+ # done
+ # break
+ # fi
fi
done
}
diff --git a/luci-app-modem/root/usr/share/modem/modem_support b/luci-app-modem/root/usr/share/modem/modem_support
index 9a5e4f3..2634b1c 100644
--- a/luci-app-modem/root/usr/share/modem/modem_support
+++ b/luci-app-modem/root/usr/share/modem/modem_support
@@ -7,4 +7,4 @@ fibocom;fm150-ae;usb;qmi,gobinet,ecm,mbim,rndis,ncm
fibocom;fm150-ae;pcie;qmi
fibocom;fm160-cn;usb;qmi,gobinet,ecm,mbim,rndis,ncm
unknown;unknown;usb;qmi,gobinet,ecm,mbim,rndis,ncm
-unknown;unknown;pcie;qmi,gobinet,mbim
\ No newline at end of file
+unknown;unknown;pcie;qmi,gobinet,mbim
diff --git a/luci-app-modem/root/usr/share/modem/modem_usb_network.sh b/luci-app-modem/root/usr/share/modem/modem_usb_network.sh
index b66c14a..1f8ab92 100755
--- a/luci-app-modem/root/usr/share/modem/modem_usb_network.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_usb_network.sh
@@ -65,7 +65,7 @@ modem_network_task()
case "$4" in
"ecm") ecm_dial $at_port $3 ;;
"gobinet") gobinet_dial $at_port $3 ;;
- "*") ecm_dial $at_port $3 ;;
+ *) ecm_dial $at_port $3 ;;
esac
fi
debug "结束网络连接检查任务"
diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh
index 1aa1dd6..f8a640f 100755
--- a/luci-app-modem/root/usr/share/modem/quectel.sh
+++ b/luci-app-modem/root/usr/share/modem/quectel.sh
@@ -17,11 +17,37 @@ get_quectel_mode()
"2") mode="mbim" ;;
"3") mode="rndis" ;;
"5") mode='ncm' ;;
- "*") mode="$mode_num" ;;
+ *) mode="$mode_num" ;;
esac
echo "$mode"
}
+#获取SIM卡状态
+get_quectel_sim_status()
+{
+ debug "检查SIM状态"
+ local sim_status
+
+ local at_command="AT+CPIN?"
+ local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ local sim_error=$(echo "$response" | grep "ERROR")
+ if [ -n "$sim_error" ]; then
+ debug "未插入SIM卡"
+ sim_status="miss"
+ return
+ fi
+ local sim_ready=$(echo "$response" | grep "READY")
+ if [ -n "$sim_ready" ]; then
+ debug "SIM卡正常"
+ sim_status="ready"
+ else
+ debug "SIM卡被锁定"
+ sim_status="locked"
+ return
+ fi
+ echo "$sim_status"
+}
+
#基本信息
quectel_base_info()
{
@@ -70,15 +96,15 @@ quectel_sim_info()
#ISP(互联网服务提供商)
local at_command="AT+COPS?"
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" = "CUCC" ] || [ "$isp" = "46001" ]; then
- isp="中国联通"
- # elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
- elif [ "$isp" = "CHN-TELECOM" ] || [ "$isp" = "CTCC" ] || [ "$isp" = "46011" ]; then
- isp="中国电信"
- fi
+ # if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
+ # isp="中国移动"
+ # # 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-TELECOM" ] || [ "$isp" = "CTCC" ] || [ "$isp" = "46011" ]; then
+ # isp="中国电信"
+ # fi
#IMEI
at_command="AT+CGSN"
@@ -94,21 +120,21 @@ quectel_sim_info()
#SIM卡号码(手机号)
at_command="AT+CNUM"
- phone=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
+ sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
}
#网络信息
-quectel_net_info()
+quectel_network_info()
{
- debug "Quectel net info"
+ debug "Quectel network info"
#Network Type(网络类型)
# local at_command="AT+COPS?"
local at_command="AT+QNWINFO"
- net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
+ network_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
#CSQ
- local at_command="AT+CSQ"
+ 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=""
@@ -125,31 +151,345 @@ quectel_net_info()
fi
}
-#quectel
-lte_bw() {
- BW=$(echo $BW | grep -o "[0-5]\{1\}")
- case $BW in
- "0")
- BW="1.4" ;;
- "1")
- BW="3" ;;
- "2"|"3"|"4"|"5")
- BW=$((($(echo $BW) - 1) * 5)) ;;
+#UL_bandwidth
+# $1:上行带宽数字
+get_lte_ul_bandwidth()
+{
+ local ul_bandwidth
+ case $1 in
+ "0") ul_bandwidth="1.4" ;;
+ "1") ul_bandwidth="3" ;;
+ "2"|"3"|"4"|"5") ul_bandwidth=$((($1 - 1) * 5)) ;;
esac
+ echo "$ul_bandwidth"
}
-#quectel
-nr_bw() {
- BW=$(echo $BW | grep -o "[0-9]\{1,2\}")
- case $BW in
- "0"|"1"|"2"|"3"|"4"|"5")
- BW=$((($(echo $BW) + 1) * 5)) ;;
- "6"|"7"|"8"|"9"|"10"|"11"|"12")
- BW=$((($(echo $BW) - 2) * 10)) ;;
- "13")
- BW="200" ;;
- "14")
- BW="400" ;;
+
+#DL_bandwidth
+# $1:下行带宽数字
+get_lte_dl_bandwidth()
+{
+ local dl_bandwidth
+ case $1 in
+ "0") dl_bandwidth="1.4" ;;
+ "1") dl_bandwidth="3" ;;
+ "2"|"3"|"4"|"5") dl_bandwidth=$((($1 - 1) * 5)) ;;
esac
+ echo "$dl_bandwidth"
+}
+
+#NR_DL_bandwidth
+# $1:下行带宽数字
+get_nr_dl_bandwidth()
+{
+ local nr_dl_bandwidth
+ case $1 in
+ "0"|"1"|"2"|"3"|"4"|"5") nr_dl_bandwidth=$((($1 + 1) * 5)) ;;
+ "6"|"7"|"8"|"9"|"10"|"11"|"12") nr_dl_bandwidth=$((($1 - 2) * 10)) ;;
+ "13") nr_dl_bandwidth="200" ;;
+ "14") nr_dl_bandwidth="400" ;;
+ esac
+ echo "$nr_dl_bandwidth"
+}
+
+#scs
+# $1:NR子载波间隔数字
+get_scs()
+{
+ local scs
+ case $1 in
+ "0") scs="15" ;;
+ "1") scs="30" ;;
+ "2") scs="60" ;;
+ "3") scs="120" ;;
+ "4") scs="240" ;;
+ esac
+ echo "$scs"
+}
+
+#小区信息
+quectel_cell_info()
+{
+ debug "Quectel cell info"
+
+ local at_command='AT+QENG="servingcell"'
+ local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+
+ local lte=$(echo "$response" | grep "+QENG: \"LTE\"")
+ local nr5g_nsa=$(echo "$response" | grep "+QENG: \"NR5G-NSA\"")
+ if [ -n "$lte" ] && [ -n "$nr5g_nsa" ] ; then
+ #EN-DC模式
+ network_mode="EN-DC Mode"
+ #LTE
+ endc_lte_duplex_mode=$(echo "$lte" | awk -F',' '{print $2}' | sed 's/"//g')
+ endc_lte_mcc=$(echo "$lte" | awk -F',' '{print $3}')
+ endc_lte_mnc=$(echo "$lte" | awk -F',' '{print $4}')
+ endc_lte_cell_id=$(echo "$lte" | awk -F',' '{print $5}')
+ endc_lte_physical_cell_id=$(echo "$lte" | awk -F',' '{print $6}')
+ endc_lte_earfcn=$(echo "$lte" | awk -F',' '{print $7}')
+ endc_lte_freq_band_ind=$(echo "$lte" | awk -F',' '{print $8}')
+ ul_bandwidth_num=$(echo "$lte" | awk -F',' '{print $9}')
+ endc_lte_ul_bandwidth=$(get_lte_ul_bandwidth $ul_bandwidth_num)
+ dl_bandwidth_num=$(echo "$lte" | awk -F',' '{print $10}')
+ endc_lte_dl_bandwidth=$(get_lte_dl_bandwidth $dl_bandwidth_num)
+ endc_lte_tac=$(echo "$lte" | awk -F',' '{print $11}')
+ endc_lte_rsrp=$(echo "$lte" | awk -F',' '{print $12}')
+ endc_lte_rsrq=$(echo "$lte" | awk -F',' '{print $13}')
+ endc_lte_rssi=$(echo "$lte" | awk -F',' '{print $14}')
+ endc_lte_sinr=$(echo "$lte" | awk -F',' '{print $15}')
+ endc_lte_cql=$(echo "$lte" | awk -F',' '{print $16}')
+ endc_lte_tx_power=$(echo "$lte" | awk -F',' '{print $17}')
+ endc_lte_rxlev=$(echo "$lte" | awk -F',' '{print $18}')
+ #NR5G-NSA
+ endc_nr_mcc=$(echo "$nr5g_nsa" | awk -F',' '{print $2}')
+ endc_nr_mnc=$(echo "$nr5g_nsa" | awk -F',' '{print $3}')
+ endc_nr_physical_cell_id=$(echo "$nr5g_nsa" | awk -F',' '{print $4}')
+ endc_nr_rsrp=$(echo "$nr5g_nsa" | awk -F',' '{print $5}')
+ endc_nr_sinr=$(echo "$nr5g_nsa" | awk -F',' '{print $6}')
+ endc_nr_rsrq=$(echo "$nr5g_nsa" | awk -F',' '{print $7}')
+ endc_nr_arfcn=$(echo "$nr5g_nsa" | awk -F',' '{print $8}')
+ endc_nr_band=$(echo "$nr5g_nsa" | awk -F',' '{print $9}')
+ nr_dl_bandwidth_num=$(echo "$nr5g_nsa" | awk -F',' '{print $10}')
+ endc_nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ scs_num=$(echo "$nr5g_nsa" | awk -F',' '{print $16}')
+ endc_nr_scs=$(get_scs $scs_num)
+ else
+ #SA,LTE,WCDMA模式
+ response=$(echo "$response" | grep "+QENG:")
+ local rat=$(echo "$response" | awk -F',' '{print $3}' | sed 's/"//g')
+ case $rat in
+ "NR5G-SA")
+ network_mode="NR5G-SA Mode"
+ nr_duplex_mode=$(echo "$response" | awk -F',' '{print $4}' | sed 's/"//g')
+ nr_mcc=$(echo "$response" | awk -F',' '{print $5}')
+ nr_mnc=$(echo "$response" | awk -F',' '{print $6}')
+ nr_cell_id=$(echo "$response" | awk -F',' '{print $7}')
+ nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ nr_tac=$(echo "$response" | awk -F',' '{print $9}')
+ nr_arfcn=$(echo "$response" | awk -F',' '{print $10}')
+ nr_band=$(echo "$response" | awk -F',' '{print $11}')
+ nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $12}')
+ nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
+ nr_rsrp=$(echo "$response" | awk -F',' '{print $13}')
+ nr_rsrq=$(echo "$response" | awk -F',' '{print $14}')
+ nr_sinr=$(echo "$response" | awk -F',' '{print $15}')
+ nr_scs=$(echo "$response" | awk -F',' '{print $16}')
+ nr_rxlev=$(echo "$response" | awk -F',' '{print $17}')
+ ;;
+ "LTE"|"CAT-M"|"CAT-NB")
+ network_mode="LTE Mode"
+ lte_duplex_mode=$(echo "$response" | awk -F',' '{print $4}' | sed 's/"//g')
+ lte_mcc=$(echo "$response" | awk -F',' '{print $5}')
+ lte_mnc=$(echo "$response" | awk -F',' '{print $6}')
+ lte_cell_id=$(echo "$response" | awk -F',' '{print $7}')
+ lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
+ lte_earfcn=$(echo "$response" | awk -F',' '{print $9}')
+ lte_freq_band_ind=$(echo "$response" | awk -F',' '{print $10}')
+ ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $11}')
+ lte_ul_bandwidth=$(get_lte_ul_bandwidth $ul_bandwidth_num)
+ dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $12}')
+ lte_dl_bandwidth=$(get_lte_dl_bandwidth $dl_bandwidth_num)
+ lte_tac=$(echo "$response" | awk -F',' '{print $13}')
+ lte_rsrp=$(echo "$response" | awk -F',' '{print $14}')
+ lte_rsrq=$(echo "$response" | awk -F',' '{print $15}')
+ lte_rssi=$(echo "$response" | awk -F',' '{print $16}')
+ lte_sinr=$(echo "$response" | awk -F',' '{print $17}')
+ lte_cql=$(echo "$response" | awk -F',' '{print $18}')
+ lte_tx_power=$(echo "$response" | awk -F',' '{print $19}')
+ lte_rxlev=$(echo "$response" | awk -F',' '{print $20}')
+ ;;
+ "WCDMA")
+ network_mode="WCDMA Mode"
+ wcdma_mcc=$(echo "$response" | awk -F',' '{print $4}')
+ wcdma_mnc=$(echo "$response" | awk -F',' '{print $5}')
+ wcdma_lac=$(echo "$response" | awk -F',' '{print $6}')
+ wcdma_cell_id=$(echo "$response" | awk -F',' '{print $7}')
+ wcdma_uarfcn=$(echo "$response" | awk -F',' '{print $8}')
+ wcdma_psc=$(echo "$response" | awk -F',' '{print $9}')
+ wcdma_rac=$(echo "$response" | awk -F',' '{print $10}')
+ wcdma_rscp=$(echo "$response" | awk -F',' '{print $11}')
+ wcdma_ecio=$(echo "$response" | awk -F',' '{print $12}')
+ wcdma_phych=$(echo "$response" | awk -F',' '{print $13}')
+ wcdma_sf=$(echo "$response" | awk -F',' '{print $14}')
+ wcdma_slot=$(echo "$response" | awk -F',' '{print $15}')
+ wcdma_speech_code=$(echo "$response" | awk -F',' '{print $16}')
+ wcdma_com_mod=$(echo "$response" | awk -F',' '{print $17}')
+ ;;
+ esac
+ fi
+
+ return
+
+ NR_NSA=$(echo $response | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",")
+ NR_SA=$(echo $response | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",")
+ if [ -n "$NR_NSA" ]; then
+ QENG=",,"$(echo $response" " | grep -o -i "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",")
+ QENG5=$(echo $response | 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 $response | 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 $response | 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\}")
+ else
+ QENG=$(echo $response" " | grep -o -i "+QENG: [^ ]\+ " | tr " " ",")
+ fi
+
+ RAT=$(echo $QENG | cut -d, -f4 | grep -o "[-A-Z5]\{3,7\}")
+ case $RAT in
+ "GSM")
+ # MODE="GSM"
+ ;;
+ "WCDMA")
+ channel=$(echo $QENG | cut -d, -f9)
+ rscp="-"$(echo $QENG | cut -d, -f12 | grep -o "[0-9]\{1,3\}")
+ ecio=$(echo $QENG | cut -d, -f13)
+ ecio="-"$(echo $ecio | grep -o "[0-9]\{1,3\}")
+ ;;
+ "LTE"|"CAT-M"|"CAT-NB")
+ PCI=$(echo $QENG | cut -d, -f9)
+ channel=$(echo $QENG | cut -d, -f10)
+ LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}")
+ BW=$(echo $QENG | cut -d, -f12)
+ lte_bw
+ BWU=$BW
+ BW=$(echo $QENG | cut -d, -f13)
+ lte_bw
+ BWD=$BW
+ if [ -z "$BWD" ]; then
+ BWD="unknown"
+ fi
+ if [ -z "$BWU" ]; then
+ BWU="unknown"
+ fi
+ if [ -n "$LBAND" ]; then
+ LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)"
+ fi
+ RSRP=$(echo $QENG | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$RSRP" ]; then
+ RSCP="-"$RSRP
+ RSRPLTE=$RSCP
+ fi
+ rsrq=$(echo $QENG | cut -d, -f16 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$rsrq" ]; then
+ ecio="-"$rsrq
+ fi
+ rssi=$(echo $QENG | cut -d, -f17 | grep -o "\-[0-9]\{1,3\}")
+ if [ -n "$rssi" ]; then
+ CSQ_RSSI=$rssi" dBm"
+ fi
+ sinrr=$(echo $QENG | cut -d, -f18 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$sinrr" ]; then
+ if [ $sinrr -le 25 ]; then
+ sinrr=$((($(echo $sinrr) * 2) -20))" dB"
+ fi
+ fi
+
+ if [ -n "$NR_NSA" ]; then
+ if [ -n "$QENG5" ] && [ -n "$LBAND" ] && [ "$RSCP" != "-" ] && [ "$ecio" != "-" ]; then
+ PCI="$PCI, "$(echo $QENG5 | cut -d, -f4)
+ SCHV=$(echo $QENG5 | cut -d, -f8)
+ SLBV=$(echo $QENG5 | cut -d, -f9)
+ BW=$(echo $QENG5 | cut -d, -f10 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$SLBV" ]; then
+ LBAND=$LBAND"
n"$SLBV
+ if [ -n "$BW" ]; then
+ nr_bw
+ LBAND=$LBAND" (Bandwidth $BW MHz)"
+ fi
+ if [ "$SCHV" -ge 123400 ]; then
+ channel=$channel", "$SCHV
+ else
+ channel=$channel", -"
+ fi
+ else
+ LBAND=$LBAND"
nxx (unknown NR5G band)"
+ channel=$channel", -"
+ fi
+ RSCP=$RSCP" dBm
"$(echo $QENG5 | cut -d, -f5)
+ sinrr=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$sinrr" ]; then
+ if [ $sinrr -le 30 ]; then
+ SINR=$SINR"
"$((($(echo $sinrr) * 2) -20))" dB"
+ fi
+ fi
+ ecio=$ecio" (4G) dB
"$(echo $QENG5 | cut -d, -f7)" (5G) "
+ fi
+ fi
+ if [ -z "$LBAND" ]; then
+ LBAND="-"
+ else
+ if [ -n "$QCA" ]; then
+ QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+")
+ for QCAL in $(echo "$QCA"); do
+ if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then
+ SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+")
+ SRATP="B"
+ if [ -n "$SCHV" ]; then
+ channel="$channel, $SCHV"
+ if [ "$SCHV" -gt 123400 ]; then
+ SRATP="n"
+ fi
+ fi
+ SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}")
+ if [ -n "$SLBV" ]; then
+ LBAND=$LBAND"
"$SRATP$SLBV
+ BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$BWD" ]; then
+ UPDOWN=$(echo $QCAL | cut -d, -f13)
+ case "$UPDOWN" in
+ "UL" )
+ CATYPE="CA"$(printf "\xe2\x86\x91") ;;
+ "DL" )
+ CATYPE="CA"$(printf "\xe2\x86\x93") ;;
+ * )
+ CATYPE="CA" ;;
+ esac
+ if [ $BWD -gt 14 ]; then
+ LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)"
+ else
+ LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)"
+ fi
+ fi
+ LBAND=$LBAND
+ fi
+ PCI="$PCI, "$(echo $QCAL | cut -d, -f8)
+ fi
+ done
+ fi
+ fi
+ if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then
+ LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)"
+ fi
+ ;;
+ "NR5G-SA")
+ if [ -n "$QENG5" ]; then
+ #AT+qnwcfg="NR5G_AMBR" #查询速度
+ PCI=$(echo $QENG5 | cut -d, -f8)
+ channel=$(echo $QENG5 | cut -d, -f10)
+ LBAND=$(echo $QENG5 | cut -d, -f11)
+ BW=$(echo $QENG5 | cut -d, -f12)
+ nr_bw
+ LBAND="n"$LBAND" (Bandwidth $BW MHz)"
+ RSCP=$(echo $QENG5 | cut -d, -f13)
+ ecio=$(echo $QENG5 | cut -d, -f14)
+ if [ "$CSQ_PER" = "-" ]; then
+ RSSI=$(rsrp2rssi $RSCP $BW)
+ CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%"
+ CSQ=$((($RSSI + 113) / 2))
+ CSQ_RSSI=$RSSI" dBm"
+ fi
+ SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
+ if [ -n "$SINRR" ]; then
+ if [ $SINRR -le 30 ]; then
+ SINR=$((($(echo $SINRR) * 2) -20))" dB"
+ fi
+ fi
+ fi
+ ;;
+ esac
}
# SIMCOM获取基站信息
@@ -290,205 +630,24 @@ get_quectel_info()
#基本信息
quectel_base_info
+
+ #获取SIM状态
+ sim_status=$(get_quectel_sim_status)
+ if [ "$sim_status" != "ready" ];then
+ return
+ fi
+
#SIM卡信息
quectel_sim_info
#网络信息
- quectel_net_info
+ quectel_network_info
+ #小区信息
+ quectel_cell_info
return
# Quectel_Cellinfo
- #
- OX=$( sh modem_at.sh $at_port 'AT+QENG="servingcell"' | grep "+QENG:" )
- 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
- 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\}")
- else
- QENG=$(echo $OX" " | grep -o -i "+QENG: [^ ]\+ " | tr " " ",")
- fi
-
-
- # debug "$QENG"
- # debug "$QENG5"
-
- RAT=$(echo $QENG | cut -d, -f4 | grep -o "[-A-Z5]\{3,7\}")
- case $RAT in
- "GSM")
- MODE="GSM"
- ;;
- "WCDMA")
- MODE="WCDMA"
- CHANNEL=$(echo $QENG | cut -d, -f9)
- RSCP=$(echo $QENG | cut -d, -f12)
- RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}")
- ECIO=$(echo $QENG | cut -d, -f13)
- ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}")
- ;;
- "LTE"|"CAT-M"|"CAT-NB")
- MODE=$(echo $QENG | cut -d, -f5 | grep -o "[DFT]\{3\}")
- if [ -n "$MODE" ]; then
- MODE="$RAT $MODE"
- else
- MODE="$RAT"
- fi
- PCI=$(echo $QENG | cut -d, -f9)
- CHANNEL=$(echo $QENG | cut -d, -f10)
- LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}")
- BW=$(echo $QENG | cut -d, -f12)
- lte_bw
- BWU=$BW
- BW=$(echo $QENG | cut -d, -f13)
- lte_bw
- BWD=$BW
- if [ -z "$BWD" ]; then
- BWD="unknown"
- fi
- if [ -z "$BWU" ]; then
- BWU="unknown"
- fi
- if [ -n "$LBAND" ]; then
- LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)"
- fi
- RSRP=$(echo $QENG | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
- if [ -n "$RSRP" ]; then
- RSCP="-"$RSRP
- RSRPLTE=$RSCP
- fi
- RSRQ=$(echo $QENG | cut -d, -f16 | grep -o "[0-9]\{1,3\}")
- if [ -n "$RSRQ" ]; then
- ECIO="-"$RSRQ
- fi
- RSSI=$(echo $QENG | cut -d, -f17 | grep -o "\-[0-9]\{1,3\}")
- if [ -n "$RSSI" ]; then
- CSQ_RSSI=$RSSI" dBm"
- fi
- SINRR=$(echo $QENG | cut -d, -f18 | grep -o "[0-9]\{1,3\}")
- if [ -n "$SINRR" ]; then
- if [ $SINRR -le 25 ]; then
- SINR=$((($(echo $SINRR) * 2) -20))" dB"
- fi
- fi
-
- if [ -n "$NR_NSA" ]; then
- MODE="LTE/NR EN-DC"
- echo "0" > /tmp/modnetwork
- if [ -n "$QENG5" ] && [ -n "$LBAND" ] && [ "$RSCP" != "-" ] && [ "$ECIO" != "-" ]; then
- PCI="$PCI, "$(echo $QENG5 | cut -d, -f4)
- SCHV=$(echo $QENG5 | cut -d, -f8)
- SLBV=$(echo $QENG5 | cut -d, -f9)
- BW=$(echo $QENG5 | cut -d, -f10 | grep -o "[0-9]\{1,3\}")
- if [ -n "$SLBV" ]; then
- LBAND=$LBAND"
n"$SLBV
- if [ -n "$BW" ]; then
- nr_bw
- LBAND=$LBAND" (Bandwidth $BW MHz)"
- fi
- if [ "$SCHV" -ge 123400 ]; then
- CHANNEL=$CHANNEL", "$SCHV
- else
- CHANNEL=$CHANNEL", -"
- fi
- else
- LBAND=$LBAND"
nxx (unknown NR5G band)"
- CHANNEL=$CHANNEL", -"
- fi
- RSCP=$RSCP" dBm
"$(echo $QENG5 | cut -d, -f5)
- SINRR=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}")
- if [ -n "$SINRR" ]; then
- if [ $SINRR -le 30 ]; then
- SINR=$SINR"
"$((($(echo $SINRR) * 2) -20))" dB"
- fi
- fi
- ECIO=$ECIO" (4G) dB
"$(echo $QENG5 | cut -d, -f7)" (5G) "
- fi
- fi
- if [ -z "$LBAND" ]; then
- LBAND="-"
- else
- if [ -n "$QCA" ]; then
- QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+")
- for QCAL in $(echo "$QCA"); do
- if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then
- SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+")
- SRATP="B"
- if [ -n "$SCHV" ]; then
- CHANNEL="$CHANNEL, $SCHV"
- if [ "$SCHV" -gt 123400 ]; then
- SRATP="n"
- fi
- fi
- SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}")
- if [ -n "$SLBV" ]; then
- LBAND=$LBAND"
"$SRATP$SLBV
- BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}")
- if [ -n "$BWD" ]; then
- UPDOWN=$(echo $QCAL | cut -d, -f13)
- case "$UPDOWN" in
- "UL" )
- CATYPE="CA"$(printf "\xe2\x86\x91") ;;
- "DL" )
- CATYPE="CA"$(printf "\xe2\x86\x93") ;;
- * )
- CATYPE="CA" ;;
- esac
- if [ $BWD -gt 14 ]; then
- LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)"
- else
- LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)"
- fi
- fi
- LBAND=$LBAND
- fi
- PCI="$PCI, "$(echo $QCAL | cut -d, -f8)
- fi
- done
- fi
- fi
- if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then
- LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)"
- fi
- ;;
- "NR5G-SA")
- MODE="NR5G-SA"
- if [ -n "$QENG5" ]; then
- #AT+qnwcfg="NR5G_AMBR" #查询速度
- MODE="$RAT $(echo $QENG5 | cut -d, -f4)"
- PCI=$(echo $QENG5 | cut -d, -f8)
- CHANNEL=$(echo $QENG5 | cut -d, -f10)
- LBAND=$(echo $QENG5 | cut -d, -f11)
- BW=$(echo $QENG5 | cut -d, -f12)
- nr_bw
- LBAND="n"$LBAND" (Bandwidth $BW MHz)"
- RSCP=$(echo $QENG5 | cut -d, -f13)
- ECIO=$(echo $QENG5 | cut -d, -f14)
- if [ "$CSQ_PER" = "-" ]; then
- RSSI=$(rsrp2rssi $RSCP $BW)
- CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%"
- CSQ=$((($RSSI + 113) / 2))
- CSQ_RSSI=$RSSI" dBm"
- fi
- SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
- if [ -n "$SINRR" ]; then
- if [ $SINRR -le 30 ]; then
- SINR=$((($(echo $SINRR) * 2) -20))" dB"
- fi
- fi
- fi
- ;;
- esac
-
#
OX=$( sh modem_at.sh $at_port "AT+QCAINFO" | grep "+QCAINFO:" )
QCA=$(echo $OX" " | grep -o -i "+QCAINFO: \"S[CS]\{2\}\".\+NWSCANMODE" | tr " " ",")