From b16811a70f88fefb1de082d39dfd8ed80f85cae3 Mon Sep 17 00:00:00 2001
From: ling <1042585959@qq.com>
Date: Thu, 22 Feb 2024 16:54:49 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSIM=E7=8A=B6=E6=80=81?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
luci-app-modem/luasrc/controller/modem.lua | 3 --
.../luasrc/model/cbi/modem/index.lua | 2 +-
.../luasrc/view/modem/modem_info.htm | 48 +++++++++++--------
luci-app-modem/po/zh-cn/modem.po | 12 +++--
.../root/usr/share/modem/fibocom.sh | 27 ++++++++---
.../root/usr/share/modem/modem_info.sh | 29 +++++++----
.../root/usr/share/modem/modem_scan.sh | 4 +-
.../root/usr/share/modem/quectel.sh | 27 ++++++++---
8 files changed, 100 insertions(+), 52 deletions(-)
diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua
index 982d5c4..c96fd8e 100644
--- a/luci-app-modem/luasrc/controller/modem.lua
+++ b/luci-app-modem/luasrc/controller/modem.lua
@@ -34,9 +34,6 @@ function index()
--AT命令旧界面
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
-
- --AT快捷命令配置
- --entry({"admin", "network", "modem", "quick_commands_config"},cbi("modem/quick_commands_config"),translate("自定义快捷命令配置"),40).leaf = true
end
--[[
diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua
index a099907..81d9edc 100644
--- a/luci-app-modem/luasrc/model/cbi/modem/index.lua
+++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua
@@ -55,7 +55,7 @@ o.cfgvalue = function(t, n)
if odp ~= "0" then
return network
else
- return "The network device was not found"
+ return translate("The network device was not found")
end
end
diff --git a/luci-app-modem/luasrc/view/modem/modem_info.htm b/luci-app-modem/luasrc/view/modem/modem_info.htm
index c8ccf94..500e6b3 100644
--- a/luci-app-modem/luasrc/view/modem/modem_info.htm
+++ b/luci-app-modem/luasrc/view/modem/modem_info.htm
@@ -71,13 +71,9 @@ end
}
//写入视图(不显示空的信息)
var value=info[key];
- if (key!="full_name"&&value!="-"&&value!="")
+ if (key!="full_name"&&value!="-"&&value!=""&&value!="ready")
{
- if (key=="SIM Status") {
- if (value!="ready") {
- value=translation[value];
- }
- }
+ // value=translation[value]; //是否翻译
sim_info_view+='
'+translation[key]+' | '+value+' |
';
break;
}
@@ -222,8 +218,18 @@ end
//SIM卡信息界面
function sim_info_view(sim_status,connect_status)
{
+ //SIM卡状态未知
+ if (sim_status=="unknown")
+ {
+ // 更新提示信息
+ document.getElementById("info_message").innerHTML="<%:Unknown SIM card status%>";
+ // 显示提示信息
+ document.getElementById("cbi-info").style.display="block";
+ // 显示SIM卡信息
+ document.getElementById("cbi-siminfo").style.display="block";
+ }
//未插入SIM卡
- if (sim_status=="miss")
+ else if (sim_status=="miss")
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<%:SIM card not inserted%>";
@@ -232,27 +238,27 @@ end
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
- //SIM卡被锁定
- else if (sim_status=="locked")
- {
- // 更新提示信息
- document.getElementById("info_message").innerHTML="<%:SIM card locked%>";
- // 显示提示信息
- document.getElementById("cbi-info").style.display="block";
- // 显示SIM卡信息
- document.getElementById("cbi-siminfo").style.display="block";
- }
- //SIM卡已准备
- else
+ //SIM卡就绪
+ else if (sim_status=="ready")
{
// 隐藏提示信息
document.getElementById("cbi-info").style.display="none";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
+ //SIM卡其他状态(锁定等)
+ else
+ {
+ // 更新提示信息
+ document.getElementById("info_message").innerHTML=""+sim_status+"";
+ // 显示提示信息
+ document.getElementById("cbi-info").style.display="block";
+ // 显示SIM卡信息
+ document.getElementById("cbi-siminfo").style.display="block";
+ }
//SIM卡未准备或网络未连接
- if (sim_status!=null||connect_status!="connect")
+ if (sim_status!="ready"||connect_status!="connect")
{
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
@@ -322,7 +328,7 @@ end
var sim_status=sim_info[0]["SIM Status"];
sim_info_view(sim_status,device_info["connect_status"]);
//SIM卡未插入或SIM卡被锁定
- if (sim_status!=null||device_info["connect_status"]!="connect") {
+ if (sim_status!="ready"||device_info["connect_status"]!="connect") {
return
}
diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po
index a42aefb..22d698f 100644
--- a/luci-app-modem/po/zh-cn/modem.po
+++ b/luci-app-modem/po/zh-cn/modem.po
@@ -217,12 +217,15 @@ msgstr "更新时间"
msgid "SIM Information"
msgstr "SIM卡信息"
+msgid "Unknown SIM card status"
+msgstr "未知SIM卡状态"
+
+msgid "SIM card not inserted"
+msgstr "SIM卡未插入"
+
msgid "ISP"
msgstr "运营商"
-msgid "SIM Slot"
-msgstr "SIM卡卡槽"
-
msgid "SIM Status"
msgstr "SIM卡状态"
@@ -232,6 +235,9 @@ msgstr "未插入"
msgid "locked"
msgstr "锁定"
+msgid "SIM Slot"
+msgstr "SIM卡卡槽"
+
msgid "SIM Number"
msgstr "SIM卡号码"
diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh
index 3007056..695c677 100755
--- a/luci-app-modem/root/usr/share/modem/fibocom.sh
+++ b/luci-app-modem/root/usr/share/modem/fibocom.sh
@@ -275,13 +275,26 @@ fibocom_sim_info()
#SIM Status(SIM状态)
at_command="AT+CPIN?"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
- if [[ "$response" = *"READY"* ]]; then
- sim_status="ready"
- elif [[ "$response" = *"ERROR"* ]]; then
- sim_status="miss"
- else
- sim_status="locked"
- fi
+ case "$response" in
+ *"ERROR"*) sim_status="miss" ;;
+ *"READY"*) sim_status="ready" ;;
+ *"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
+ *"SIM PUK"*) sim_status="MT is waiting SIM PUK to be given" ;;
+ *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-SIM card password to be given" ;;
+ *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-very first SIM card password to be given" ;;
+ *"PH-FSIM PUK"*) sim_status="MT is waiting phone-to-very first SIM card unblocking password to be given" ;;
+ *"SIM PIN2"*) sim_status="MT is waiting SIM PIN2 to be given" ;;
+ *"SIM PUK2"*) sim_status="MT is waiting SIM PUK2 to be given" ;;
+ *"PH-NET PIN"*) sim_status="MT is waiting network personalization password to be given" ;;
+ *"PH-NET PUK"*) sim_status="MT is waiting network personalization unblocking password to be given" ;;
+ *"PH-NETSUB PIN"*) sim_status="MT is waiting network subset personalization password to be given" ;;
+ *"PH-NETSUB PUK"*) sim_status="MT is waiting network subset personalization unblocking password to be given" ;;
+ *"PH-SP PIN"*) sim_status="MT is waiting service provider personalization password to be given" ;;
+ *"PH-SP PUK"*) sim_status="MT is waiting service provider personalization unblocking password to be given" ;;
+ *"PH-CORP PIN"*) sim_status="MT is waiting corporate personalization password to be given" ;;
+ *"PH-CORP PUK"*) sim_status="MT is waiting corporate personalization unblocking password to be given" ;;
+ *) sim_status="unknown" ;;
+ esac
if [ "$sim_status" != "ready" ]; then
return
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 08b8b7f..d0f3f3b 100755
--- a/luci-app-modem/root/usr/share/modem/modem_info.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_info.sh
@@ -18,13 +18,13 @@ init_modem_info()
update_time='-' #更新时间
#SIM卡信息
- sim_status="miss" #SIM卡状态
- sim_slot="-" #SIM卡卡槽
- isp="-" #运营商(互联网服务提供商)
- sim_number='-' #SIM卡号码(手机号)
- imei='-' #IMEI
- imsi='-' #IMSI
- iccid='-' #ICCID
+ sim_status="unknown" #SIM卡状态
+ sim_slot="-" #SIM卡卡槽
+ isp="-" #运营商(互联网服务提供商)
+ sim_number='-' #SIM卡号码(手机号)
+ imei='-' #IMEI
+ imsi='-' #IMSI
+ iccid='-' #ICCID
#网络信息
connect_status="disconnect" #SIM卡状态
@@ -151,6 +151,7 @@ set_sim_info()
{
if [ "$sim_status" = "ready" ]; then
sim_info="\"sim_info\":[
+ {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"ISP\":\"$isp\", \"full_name\":\"Internet Service Provider\"},
{\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
{\"SIM Number\":\"$sim_number\", \"full_name\":\"SIM Number\"},
@@ -163,7 +164,11 @@ set_sim_info()
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"}
],"
- elif [ "$sim_status" = "locked" ]; then
+ elif [ "$sim_status" = "unknown" ]; then
+ sim_info="\"sim_info\":[
+ {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"}
+ ],"
+ else
sim_info="\"sim_info\":[
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
@@ -355,6 +360,14 @@ get_modem_info()
return
fi
+ #检查模块状态(是否处于重启,重置,串口异常状态)
+ local at_command="ATI"
+ local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
+ if [[ "$response" = *"failed"* ]] || [[ "$response" = *"$at_port"* ]]; then
+ debug "模组AT串口未就绪"
+ return
+ fi
+
debug "根据模组的制造商获取信息"
#更多信息获取
case $manufacturer in
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 418f975..738d07a 100755
--- a/luci-app-modem/root/usr/share/modem/modem_scan.sh
+++ b/luci-app-modem/root/usr/share/modem/modem_scan.sh
@@ -93,10 +93,10 @@ setPortConfig()
#添加新的串口
uci add_list modem.modem$i.ports="$2"
#判断是不是AT串口
- local result=$(sh $current_dir/modem_at.sh $2 "ATI")
+ local response=$(sh $current_dir/modem_at.sh $2 "ATI")
local str1="No" #No response from modem.
local str2="failed"
- if [[ "$result" != *"$str1"* ]] && [[ "$result" != *"$str2"* ]]; then
+ if [[ "$response" != *"$str1"* ]] && [[ "$response" != *"$str2"* ]]; then
#原先的AT串口会被覆盖掉(是否需要加判断)
uci set modem.modem$i.at_port="$2"
setModemInfoConfig $i $2
diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh
index b6f85e7..6b06c24 100755
--- a/luci-app-modem/root/usr/share/modem/quectel.sh
+++ b/luci-app-modem/root/usr/share/modem/quectel.sh
@@ -266,13 +266,26 @@ quectel_sim_info()
#SIM Status(SIM状态)
at_command="AT+CPIN?"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
- if [[ "$response" = *"READY"* ]]; then
- sim_status="ready"
- elif [ "$response" = "" ]; then
- sim_status="miss"
- else
- sim_status="locked"
- fi
+ case "$response" in
+ "") sim_status="miss" ;;
+ *"READY"*) sim_status="ready" ;;
+ *"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
+ *"SIM PUK"*) sim_status="MT is waiting SIM PUK to be given" ;;
+ *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-SIM card password to be given" ;;
+ *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-very first SIM card password to be given" ;;
+ *"PH-FSIM PUK"*) sim_status="MT is waiting phone-to-very first SIM card unblocking password to be given" ;;
+ *"SIM PIN2"*) sim_status="MT is waiting SIM PIN2 to be given" ;;
+ *"SIM PUK2"*) sim_status="MT is waiting SIM PUK2 to be given" ;;
+ *"PH-NET PIN"*) sim_status="MT is waiting network personalization password to be given" ;;
+ *"PH-NET PUK"*) sim_status="MT is waiting network personalization unblocking password to be given" ;;
+ *"PH-NETSUB PIN"*) sim_status="MT is waiting network subset personalization password to be given" ;;
+ *"PH-NETSUB PUK"*) sim_status="MT is waiting network subset personalization unblocking password to be given" ;;
+ *"PH-SP PIN"*) sim_status="MT is waiting service provider personalization password to be given" ;;
+ *"PH-SP PUK"*) sim_status="MT is waiting service provider personalization unblocking password to be given" ;;
+ *"PH-CORP PIN"*) sim_status="MT is waiting corporate personalization password to be given" ;;
+ *"PH-CORP PUK"*) sim_status="MT is waiting corporate personalization unblocking password to be given" ;;
+ *) sim_status="unknown" ;;
+ esac
if [ "$sim_status" != "ready" ]; then
return