修复SIM状态问题

This commit is contained in:
ling 2024-02-22 16:54:49 +08:00
parent f8c560ded4
commit b16811a70f
8 changed files with 100 additions and 52 deletions

View File

@ -34,9 +34,6 @@ function index()
--AT命令旧界面 --AT命令旧界面
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true 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 end
--[[ --[[

View File

@ -55,7 +55,7 @@ o.cfgvalue = function(t, n)
if odp ~= "0" then if odp ~= "0" then
return network return network
else else
return "The network device was not found" return translate("The network device was not found")
end end
end end

View File

@ -71,13 +71,9 @@ end
} }
//写入视图(不显示空的信息) //写入视图(不显示空的信息)
var value=info[key]; var value=info[key];
if (key!="full_name"&&value!="-"&&value!="") if (key!="full_name"&&value!="-"&&value!=""&&value!="ready")
{ {
if (key=="SIM Status") { // value=translation[value]; //是否翻译
if (value!="ready") {
value=translation[value];
}
}
sim_info_view+='<tr class="tr"><td class="td left" title="'+full_name+'">'+translation[key]+'</td><td class="td left" id="'+key+'">'+value+'</td></tr>'; sim_info_view+='<tr class="tr"><td class="td left" title="'+full_name+'">'+translation[key]+'</td><td class="td left" id="'+key+'">'+value+'</td></tr>';
break; break;
} }
@ -222,8 +218,18 @@ end
//SIM卡信息界面 //SIM卡信息界面
function sim_info_view(sim_status,connect_status) function sim_info_view(sim_status,connect_status)
{ {
//SIM卡状态未知
if (sim_status=="unknown")
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:Unknown SIM card status%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
//未插入SIM卡 //未插入SIM卡
if (sim_status=="miss") else if (sim_status=="miss")
{ {
// 更新提示信息 // 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:SIM card not inserted%></strong>"; document.getElementById("info_message").innerHTML="<strong><%:SIM card not inserted%></strong>";
@ -232,27 +238,27 @@ end
// 显示SIM卡信息 // 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block"; document.getElementById("cbi-siminfo").style.display="block";
} }
//SIM卡被锁定 //SIM卡就绪
else if (sim_status=="locked") else if (sim_status=="ready")
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:SIM card locked%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
//SIM卡已准备
else
{ {
// 隐藏提示信息 // 隐藏提示信息
document.getElementById("cbi-info").style.display="none"; document.getElementById("cbi-info").style.display="none";
// 显示SIM卡信息 // 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block"; document.getElementById("cbi-siminfo").style.display="block";
} }
//SIM卡其他状态锁定等
else
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong>"+sim_status+"</strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
//SIM卡未准备或网络未连接 //SIM卡未准备或网络未连接
if (sim_status!=null||connect_status!="connect") if (sim_status!="ready"||connect_status!="connect")
{ {
// 隐藏网络信息 // 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none"; document.getElementById("cbi-networkinfo").style.display="none";
@ -322,7 +328,7 @@ end
var sim_status=sim_info[0]["SIM Status"]; var sim_status=sim_info[0]["SIM Status"];
sim_info_view(sim_status,device_info["connect_status"]); sim_info_view(sim_status,device_info["connect_status"]);
//SIM卡未插入或SIM卡被锁定 //SIM卡未插入或SIM卡被锁定
if (sim_status!=null||device_info["connect_status"]!="connect") { if (sim_status!="ready"||device_info["connect_status"]!="connect") {
return return
} }

View File

@ -217,12 +217,15 @@ msgstr "更新时间"
msgid "SIM Information" msgid "SIM Information"
msgstr "SIM卡信息" msgstr "SIM卡信息"
msgid "Unknown SIM card status"
msgstr "未知SIM卡状态"
msgid "SIM card not inserted"
msgstr "SIM卡未插入"
msgid "ISP" msgid "ISP"
msgstr "运营商" msgstr "运营商"
msgid "SIM Slot"
msgstr "SIM卡卡槽"
msgid "SIM Status" msgid "SIM Status"
msgstr "SIM卡状态" msgstr "SIM卡状态"
@ -232,6 +235,9 @@ msgstr "未插入"
msgid "locked" msgid "locked"
msgstr "锁定" msgstr "锁定"
msgid "SIM Slot"
msgstr "SIM卡卡槽"
msgid "SIM Number" msgid "SIM Number"
msgstr "SIM卡号码" msgstr "SIM卡号码"

View File

@ -275,13 +275,26 @@ fibocom_sim_info()
#SIM StatusSIM状态 #SIM StatusSIM状态
at_command="AT+CPIN?" at_command="AT+CPIN?"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p') response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
if [[ "$response" = *"READY"* ]]; then case "$response" in
sim_status="ready" *"ERROR"*) sim_status="miss" ;;
elif [[ "$response" = *"ERROR"* ]]; then *"READY"*) sim_status="ready" ;;
sim_status="miss" *"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
else *"SIM PUK"*) sim_status="MT is waiting SIM PUK to be given" ;;
sim_status="locked" *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-SIM card password to be given" ;;
fi *"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 if [ "$sim_status" != "ready" ]; then
return return

View File

@ -18,13 +18,13 @@ init_modem_info()
update_time='-' #更新时间 update_time='-' #更新时间
#SIM卡信息 #SIM卡信息
sim_status="miss" #SIM卡状态 sim_status="unknown" #SIM卡状态
sim_slot="-" #SIM卡卡槽 sim_slot="-" #SIM卡卡槽
isp="-" #运营商(互联网服务提供商) isp="-" #运营商(互联网服务提供商)
sim_number='-' #SIM卡号码手机号 sim_number='-' #SIM卡号码手机号
imei='-' #IMEI imei='-' #IMEI
imsi='-' #IMSI imsi='-' #IMSI
iccid='-' #ICCID iccid='-' #ICCID
#网络信息 #网络信息
connect_status="disconnect" #SIM卡状态 connect_status="disconnect" #SIM卡状态
@ -151,6 +151,7 @@ set_sim_info()
{ {
if [ "$sim_status" = "ready" ]; then if [ "$sim_status" = "ready" ]; then
sim_info="\"sim_info\":[ sim_info="\"sim_info\":[
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"ISP\":\"$isp\", \"full_name\":\"Internet Service Provider\"}, {\"ISP\":\"$isp\", \"full_name\":\"Internet Service Provider\"},
{\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"}, {\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
{\"SIM Number\":\"$sim_number\", \"full_name\":\"SIM Number\"}, {\"SIM Number\":\"$sim_number\", \"full_name\":\"SIM Number\"},
@ -163,7 +164,11 @@ set_sim_info()
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"}, {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"} {\"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_info="\"sim_info\":[
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"}, {\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"}, {\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
@ -355,6 +360,14 @@ get_modem_info()
return return
fi 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 "根据模组的制造商获取信息" debug "根据模组的制造商获取信息"
#更多信息获取 #更多信息获取
case $manufacturer in case $manufacturer in

View File

@ -93,10 +93,10 @@ setPortConfig()
#添加新的串口 #添加新的串口
uci add_list modem.modem$i.ports="$2" uci add_list modem.modem$i.ports="$2"
#判断是不是AT串口 #判断是不是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 str1="No" #No response from modem.
local str2="failed" local str2="failed"
if [[ "$result" != *"$str1"* ]] && [[ "$result" != *"$str2"* ]]; then if [[ "$response" != *"$str1"* ]] && [[ "$response" != *"$str2"* ]]; then
#原先的AT串口会被覆盖掉是否需要加判断 #原先的AT串口会被覆盖掉是否需要加判断
uci set modem.modem$i.at_port="$2" uci set modem.modem$i.at_port="$2"
setModemInfoConfig $i $2 setModemInfoConfig $i $2

View File

@ -266,13 +266,26 @@ quectel_sim_info()
#SIM StatusSIM状态 #SIM StatusSIM状态
at_command="AT+CPIN?" at_command="AT+CPIN?"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p') response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
if [[ "$response" = *"READY"* ]]; then case "$response" in
sim_status="ready" "") sim_status="miss" ;;
elif [ "$response" = "" ]; then *"READY"*) sim_status="ready" ;;
sim_status="miss" *"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
else *"SIM PUK"*) sim_status="MT is waiting SIM PUK to be given" ;;
sim_status="locked" *"PH-FSIM PIN"*) sim_status="MT is waiting phone-to-SIM card password to be given" ;;
fi *"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 if [ "$sim_status" != "ready" ]; then
return return