添加未适配模块的异常处理

This commit is contained in:
ling 2024-01-07 13:26:03 +08:00
parent 7924809511
commit 9ab2b17033
9 changed files with 676 additions and 526 deletions

View File

@ -24,16 +24,19 @@ function index()
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
--AT命令 --AT命令
-- local modem_number=uci:get('modem','@global[0]','modem_number') entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).leaf = true
-- if modem_number ~= "0" or modem_number == nil then
entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).leaf = true
-- end
entry({"admin", "network", "modem", "mode_info"}, call("modeInfo"), nil).leaf = true entry({"admin", "network", "modem", "mode_info"}, call("modeInfo"), nil).leaf = true
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "user_at_command"}, call("userATCommand"), nil).leaf = true entry({"admin", "network", "modem", "user_at_command"}, call("userATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "get_at_port"}, call("getATPort"), nil).leaf = true entry({"admin", "network", "modem", "get_at_port"}, call("getATPort"), nil).leaf = true
end end
-- 判断字符串是否含有字母
function hasLetters(str)
local pattern = "%a" -- 匹配字母的正则表达式
return string.find(str, pattern) ~= nil
end
-- AT命令 -- AT命令
function at(at_port,at_command) function at(at_port,at_command)
-- local odpall = io.popen("sh modem_at.sh "..at_port.." '"..at_command.."'") -- local odpall = io.popen("sh modem_at.sh "..at_port.." '"..at_command.."'")
@ -49,7 +52,7 @@ function getModemConnectStatus(at_port,manufacturer)
local connect_status="unknown" local connect_status="unknown"
if at_port and manufacturer then if at_port and manufacturer then
local odpall = io.popen("cd /usr/share/modem && source $(dirname \"$0\")/"..manufacturer..".sh && get_connect_status "..at_port) local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && get_connect_status "..at_port)
connect_status = odpall:read("*a") connect_status = odpall:read("*a")
connect_status=string.gsub(connect_status, "\n", "") connect_status=string.gsub(connect_status, "\n", "")
odpall:close() odpall:close()
@ -59,8 +62,8 @@ function getModemConnectStatus(at_port,manufacturer)
end end
-- 获取模组基本信息 -- 获取模组基本信息
function getModemBaseInfo(at_port) function getModemDeviceInfo(at_port)
local modem_base_info={} local modem_device_info={}
uci:foreach("modem", "modem-device", function (modem_device) uci:foreach("modem", "modem-device", function (modem_device)
if at_port == modem_device["at_port"] then if at_port == modem_device["at_port"] then
@ -70,28 +73,26 @@ function getModemBaseInfo(at_port)
local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"]) local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
--设置值 --设置值
modem_base_info=modem_device modem_device_info=modem_device
modem_base_info["data_interface"]=data_interface modem_device_info["data_interface"]=data_interface
modem_base_info["connect_status"]=connect_status modem_device_info["connect_status"]=connect_status
return true return true
end end
end) end)
return modem_base_info return modem_device_info
end end
-- 获取模组更多信息 -- 获取模组更多信息
function getModemMoreInfo(at_port,manufacturer) function getModemMoreInfo(at_port,manufacturer)
local modem_more_info={}
-- if manufacturer == "unknown" then
-- return modem_more_info
-- end
--获取模组信息
local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer) local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer)
local opd = odpall:read("*a") local opd = odpall:read("*a")
odpall:close() odpall:close()
modem_more_info=json.parse(opd)
--设置值
local modem_more_info=json.parse(opd)
return modem_more_info return modem_more_info
end end
@ -102,34 +103,53 @@ function getModemInfo()
local at_port = http.formvalue("port") local at_port = http.formvalue("port")
--获取信息 --获取信息
local modem_base_info local modem_device_info
local modem_more_info local modem_more_info
if at_port then if at_port then
modem_base_info=getModemBaseInfo(at_port) modem_device_info=getModemDeviceInfo(at_port)
modem_more_info=getModemMoreInfo(at_port,modem_base_info["manufacturer"]) modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"])
end end
--设置信息 --设置信息
local modem_info={} local modem_info={}
modem_info["base_info"]=modem_base_info modem_info["device_info"]=modem_device_info
modem_info["more_info"]=modem_more_info modem_info["more_info"]=modem_more_info
--设置翻译 --设置翻译
local translation={} local translation={}
--SIM卡信息翻译
if modem_more_info["sim_info"] then if modem_more_info["sim_info"] then
for key in pairs(modem_more_info["sim_info"]) do
local key_origin=modem_more_info["sim_info"][key]:upper() local sim_info=modem_more_info["sim_info"]
translation[key_origin]=luci.i18n.translate(key_origin) for i = 1, #sim_info do
local info = sim_info[i]
for key in pairs(info) do
translation[key]=luci.i18n.translate(key)
local value=info[key]
if hasLetters(value) then
translation[value]=luci.i18n.translate(value)
end
end
end end
end end
--网络信息翻译
if modem_more_info["network_info"] then
for key in pairs(modem_more_info["network_info"]) do
translation[key]=luci.i18n.translate(key)
local value=modem_more_info["network_info"][key]
if hasLetters(value) then
translation[value]=luci.i18n.translate(value)
end
end
end
--小区信息翻译
if modem_more_info["cell_info"] then if modem_more_info["cell_info"] then
for key in pairs(modem_more_info["cell_info"]) do for key in pairs(modem_more_info["cell_info"]) do
translation[key]=luci.i18n.translate(key) translation[key]=luci.i18n.translate(key)
local network_mode=modem_more_info["cell_info"][key] local network_mode=modem_more_info["cell_info"][key]
for i = 1, #network_mode do for i = 1, #network_mode do
local value = network_mode[i] local info = network_mode[i]
for key in pairs(value) do for key in pairs(info) do
translation[key]=luci.i18n.translate(key) translation[key]=luci.i18n.translate(key)
end end
end end

View File

@ -5,7 +5,8 @@ m = Map("modem")
m.title = translate("Modem Config") m.title = translate("Modem Config")
m.description = translate("Configuration panel for Modem, Add configuration to all modems on this page") m.description = translate("Configuration panel for Modem, Add configuration to all modems on this page")
s = m:section(NamedSection, "global", "global") --全局配置
s = m:section(NamedSection, "global", "global", translate("Global Config"))
s.anonymous = true s.anonymous = true
s.addremove = false s.addremove = false

View File

@ -1,60 +1,15 @@
<%+header%> <%+header%>
<h2 name="content"><%:AT Commands%></h2>
<div class="cbi-map-descr"><%:Debugging Your Module with AT Command%></div>
<fieldset class="cbi-section" id="cbi-info" style="display: block;"> <style type="text/css">
<h3><%:Message%></h3> #modem_status_view > div {
<table width="550" border="0"> display: inline-block;
<tr> margin: 1rem;
<td width="10%"></td> padding: 1rem;
<td width="60%"> width: 15rem;
<div align="left" id="info_message" style="font-size:1.875em"> float: left;
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle"/> line-height: 125%;
<%:Loading modem%>... }
</div> </style>
</td>
<td width="30%"></td>
</tr>
</table>
</fieldset>
<div id="at_command_view" style="display: none;">
<h4><br/></h4>
<div class="table" width="100%">
<div class="tr">
<div class="td left" width="25%"><%:Modem Select%>:</div>
<div class="td left" style="width:50%;">
<select name="modem_select" id="modem_select" onclick="afunction()"></select>
</div>
<div class="td left" style="width:50%;"></div>
</div>
<div class="tr">
<div class="td left" width="25%"><%:User AT Commands%>:</div>
<div class="td left" style="width:50%;">
<select name="command_choose" id="command_choose" onclick="copyToSend()"></select>
</div>
<div class="td left" style="width:50%;"></div>
</div>
<div class="tr">
<div class="td left" style="width:25%;"><%:Command to send%>:</div>
<div class="td left" ><input type="text" id="at_command" required size="20" ></div>
</div>
</div>
<div class="table" width="100%">
<div class="td left" style="width:25%;"><%:Reply%>:
<p>
<pre id="odp" style="visibility: hidden; width:75%;"></pre></div>
<div class="tr cbi-rowstyle-2">
<div class="td right"><input type="button" style="margin-right: 26%"; id="sendcmd" class="btn cbi-button cbi-button-neutral" value="<%:Send Command%>" /></div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
@ -173,7 +128,6 @@
return false; return false;
} }
document.addEventListener('DOMContentLoaded', function (ev) {var button = document.getElementById("sendcmd"); document.addEventListener('DOMContentLoaded', function (ev) {var button = document.getElementById("sendcmd");
button.addEventListener("click", function () { button.addEventListener("click", function () {
@ -213,5 +167,65 @@
</script> </script>
<h2 name="content"><%:AT Commands%></h2>
<div class="cbi-map-descr"><%:Debugging Your Module with AT Command%></div>
<fieldset class="cbi-section" id="cbi-info" style="display: block;">
<h3><%:Message%></h3>
<table width="550" border="0">
<tr>
<td width="10%"></td>
<td width="60%">
<div align="left" id="info_message" style="font-size:1.875em">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle"/>
<%:Loading modem%>...
</div>
</td>
<td width="30%"></td>
</tr>
</table>
</fieldset>
<div id="at_command_view" style="display: none;">
<h4><br/></h4>
<div class="table" width="100%">
<div class="tr">
<div class="td left" style="width:25%;"><%:Modem Select%>:</div>
<div class="td left" style="width:50%;">
<select name="modem_select" id="modem_select" onclick="afunction()"></select>
</div>
<!-- <div class="td left" style="width:50%;"></div> -->
</div>
<div class="tr">
<div class="td left" style="width:25%;"><%:User AT Commands%>:</div>
<div class="td left" style="width:50%;">
<select name="command_choose" id="command_choose" onclick="copyToSend()"></select>
</div>
<!-- <div class="td left" style="width:50%;"></div> -->
</div>
<div class="tr">
<div class="td left" style="width:25%;"><%:Command to send%>:</div>
<div class="td left" style="width:50%;">
<input type="text" id="at_command" required size="20" >
</div>
<!-- <div class="td left" style="width:50%;"></div> -->
</div>
</div>
<div class="table" width="100%">
<div class="td left" style="width:25%;"><%:Response%>:
<pre id="odp" style="visibility: hidden; width:75%;"></pre>
</div>
<div class="tr cbi-rowstyle-2">
<div class="td right"><input type="button" style="margin-right: 26%"; id="sendcmd" class="btn cbi-button cbi-button-neutral" value="<%:Send Command%>" /></div>
</div>
</div>
</div>
<%+footer%> <%+footer%>

View File

@ -28,8 +28,52 @@ end
}); });
} }
//获取SIM卡信息视图
function get_sim_info_view(sim_info,translation)
{
//初始化视图
var sim_info_view='';
//遍历每一条信息
for (var info of sim_info)
{
//遍历每一条信息里的键
for (var key in info)
{
//获取全名
var full_name=info["full_name"];
if (full_name==null)
{
full_name='';
}
//写入视图(不显示空的信息)
var value=info[key];
if (key!="full_name"&&value!="-"&&value!="")
{
if (key=="SIM Status") {
if (value!="ready") {
value=translation[value];
}
}
sim_info_view+='<tr><td width="20%" title="'+full_name+'">'+translation[key]+' :</td><td id="'+key+'">'+value+'</td><td></td></tr>';
break;
}
}
}
return sim_info_view;
}
//设置SIM卡信息
function set_sim_info(sim_info,translation)
{
//获取SIM卡信息视图
var sim_info_view=get_sim_info_view(sim_info,translation);
//获取SIM卡信息表格
var sim_info_Element=document.getElementById("sim_info");
sim_info_Element.innerHTML=sim_info_view;
}
//获取小区信息视图 //获取小区信息视图
function get_cell_info_view(network_mode_info,translation) function get_cell_info_view(network_mode_info,network_type,translation)
{ {
//初始化视图 //初始化视图
var cell_info_view=''; var cell_info_view='';
@ -39,28 +83,42 @@ end
//遍历每一条信息里的键 //遍历每一条信息里的键
for (var key in info) for (var key in info)
{ {
//获取全名
var full_name=info["full_name"]; var full_name=info["full_name"];
if (full_name==null) if (full_name==null)
{ {
full_name=''; full_name='';
} }
//不显示空的信息 //写入视图(不显示空的信息)
if (key!="full_name"&&info[key]!="") var value=info[key];
if (key!="full_name"&&value!="-"&&value!="")
{ {
//添加单位 //添加单位
if (key=="UL Bandwidth"||key=="DL Bandwidth") { if (key=="Band") {
info[key]=info[key]+" MHz" if (network_type.includes("NR")) {
value="N"+value
}
else if (network_type.includes("LTE")) {
value="B"+value
}
else if (network_type.includes("WCDMA")) {
value="B"+value
}
}
else if (key=="UL Bandwidth"||key=="DL Bandwidth") {
value=value+" MHz"
} }
else if (key=="RSRP"||key=="TX Power"||key=="RxLev") { else if (key=="RSRP"||key=="TX Power"||key=="RxLev") {
info[key]=info[key]+" dBm" value=value+" dBm"
} }
else if (key=="RSRQ"||key=="SINR"||key=="RSSNR"||key=="Ec/Io") { else if (key=="RSRQ"||key=="SINR"||key=="RSSNR"||key=="Ec/Io") {
info[key]=info[key]+" dB" value=value+" dB"
} }
else if (key=="SCS") { else if (key=="SCS") {
info[key]=info[key]+" KHz" value=value+" KHz"
} }
cell_info_view+='<tr><td width="20%" title="'+full_name+'">'+translation[key]+' :</td><td id="'+key+'">'+info[key]+'</td><td></td></tr>'; cell_info_view+='<tr><td width="20%" title="'+full_name+'">'+translation[key]+' :</td><td id="'+key+'">'+value+'</td><td></td></tr>';
break;
} }
} }
} }
@ -68,44 +126,143 @@ end
} }
//获取小区信息 //获取小区信息
function show_cell_info(cell_info,translation) { function set_cell_info(cell_info,translation)
{
//获取网络模式 //获取网络模式
var network_mode=Object.keys(cell_info)[0]; var network_mode=Object.keys(cell_info)[0];
//获取视图
var cell_info_view='<caption>'+translation[network_mode]+'</caption>'; //网络模式视图
//获取网络模式下的信息 //获取网络模式下的信息
var network_mode_info=cell_info[network_mode]; var network_mode_info=cell_info[network_mode];
//获取表格
var cell_info_Element=document.getElementById("cell_info");
//初始化视图
var cell_info_view='<caption>'+translation[network_mode]+'</caption>';
if (network_mode=="EN-DC Mode") if (network_mode=="EN-DC Mode")
{ {
console.log(aaa);
var lte=network_mode_info[0]["LTE"]; var lte=network_mode_info[0]["LTE"];
cell_info_view+='<tr><td colspan="3">LTE</td></tr>'; cell_info_view+='<tr><td colspan="3">LTE</td></tr>';
cell_info_view+=get_cell_info_view(lte,translation); cell_info_view+=get_cell_info_view(lte,"LTE",translation);
var nsa=network_mode_info[1]["NR5G-NSA"]; var nsa=network_mode_info[1]["NR5G-NSA"];
cell_info_view+='<tr><td colspan="3">NR5G-NSA</td></tr>'; cell_info_view+='<tr><td colspan="3">NR5G-NSA</td></tr>';
cell_info_view+=get_cell_info_view(nsa,translation); cell_info_view+=get_cell_info_view(nsa,"NR",translation);
} }
else else
{ {
// cell_info_view+='<tr><td colspan="3">NR5G-NSA</td></tr>'; // cell_info_view+='<tr><td colspan="3">NR5G-NSA</td></tr>';
cell_info_view+=get_cell_info_view(network_mode_info,translation); cell_info_view+=get_cell_info_view(network_mode_info,network_mode,translation);
} }
//获取表格
var cell_info_Element=document.getElementById("cell_info");
cell_info_Element.innerHTML=cell_info_view; cell_info_Element.innerHTML=cell_info_view;
} }
// 更新模组数据 //显示信息
function set_info(info)
{
for (var key in info)
{
var info_Element=document.getElementById(key);
if (info_Element!=null)
{
info_Element.innerHTML=info[key];
}
}
}
//基本信息界面
function base_info_view(manufacturer)
{
if (manufacturer!="unknown")
{
// 隐藏提示信息
document.getElementById("cbi-info").style.display="none";
// 显示基本信息
document.getElementById("cbi-baseinfo").style.display="block";
}
else //未适配模组
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:Not adapted to this modem%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 隐藏SIM卡信息
document.getElementById("cbi-siminfo").style.display="none";
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
// 隐藏小区信息
document.getElementById("cbi-cellinfo").style.display="none";
}
}
//SIM卡信息界面
function sim_info_view(sim_status,connect_status)
{
//未插入SIM卡
if (sim_status=="miss")
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:SIM card not inserted%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
//SIM卡被锁定
else if (sim_status=="locked")
{
// 更新提示信息
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";
// 显示SIM卡信息
document.getElementById("cbi-siminfo").style.display="block";
}
//SIM卡未准备或网络未连接
if (sim_status!=null||connect_status!="connect")
{
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
// 隐藏小区信息
document.getElementById("cbi-cellinfo").style.display="none";
}
}
//网络信息界面和小区信息界面
function network_info_view(connect_status)
{
//已连接
if (connect_status=="connect")
{
// 显示网络信息
document.getElementById("cbi-networkinfo").style.display="block";
// 显示小区信息
document.getElementById("cbi-cellinfo").style.display="block";
}
//未连接
else
{
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
// 隐藏小区信息
document.getElementById("cbi-cellinfo").style.display="none";
}
}
// 更新模组信息
function update() function update()
{ {
// var at_port=""; //获取选中的AT串口
// if (modem_select.options.length!=0) { var at_port=modem_select.options[modem_select.selectedIndex].value;
var at_port=modem_select.options[modem_select.selectedIndex].value;
// }
// else {
// return
// }
//获取模组信息
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_info")%>', {"port":at_port}, XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_info")%>', {"port":at_port},
function(x, data) function(x, data)
{ {
@ -114,204 +271,117 @@ end
var modem_info=data["modem_info"]; var modem_info=data["modem_info"];
var translation=data["translation"]; var translation=data["translation"];
var base_info=modem_info["base_info"]; // 设备信息
var connect_status=base_info["connect_status"]; var device_info=modem_info["device_info"];
for (var key in base_info) set_info(device_info);
{
var base_info_Element=document.getElementById(key);
if (base_info_Element!=null)
{
base_info_Element.innerHTML=base_info[key];
}
}
// 更多信息
var more_info=modem_info["more_info"]; var more_info=modem_info["more_info"];
//基本信息 //基本信息
base_info=more_info["base_info"]; var base_info=more_info["base_info"];
for (var key in base_info) set_info(base_info);
{
var base_info_Element=document.getElementById(key);
if (base_info_Element!=null)
{
base_info_Element.innerHTML=base_info[key];
}
}
// 界面显示控制 //基本信息界面控制
// 隐藏提示信息 base_info_view(base_info["manufacturer"]);
document.getElementById("cbi-info").style.display="none"; //未适配模组
// 显示基本信息 if (base_info["manufacturer"]=="unknown") {
document.getElementById("cbi-baseinfo").style.display="block"; return
}
//SIM卡信息 //SIM卡信息
var sim_info=more_info["sim_info"]; var sim_info=more_info["sim_info"];
for (var key in sim_info) set_sim_info(sim_info,translation);
{
var sim_info_Element=document.getElementById(key);
if (sim_info_Element!=null)
{
sim_info_Element.innerHTML=translation[sim_info[key]];
}
}
// 界面显示控制 //SIM卡信息显示控制
if (base_info["manufacturer"]!="unknown") var sim_status=sim_info[0]["SIM Status"];
{ sim_info_view(sim_status,device_info["connect_status"]);
// 显示SIM卡信息 //SIM卡未插入或SIM卡被锁定
document.getElementById("cbi-siminfo").style.display="block"; if (sim_status!=null||device_info["connect_status"]!="connect") {
}
else
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:Not adapted to this modem%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 隐藏SIM卡信息
document.getElementById("cbi-siminfo").style.display="none";
return return
} }
//网络信息 //网络信息
var network_info=more_info["network_info"]; var network_info=more_info["network_info"];
for (var key in network_info) set_info(network_info);
{
var network_info_Element=document.getElementById(key);
if (network_info_Element!=null)
{
network_info_Element.innerHTML=network_info[key];
}
}
//小区信息 //小区信息
var cell_info=more_info["cell_info"]; var cell_info=more_info["cell_info"];
if (cell_info!=null) set_cell_info(cell_info,translation);
{
show_cell_info(cell_info,translation);
}
// 界面显示控制 //网络信息和小区信息界面显示控制
if (connect_status=="connect") network_info_view(device_info["connect_status"]);
{
// 显示网络信息
document.getElementById("cbi-networkinfo").style.display="block";
// 显示小区信息
document.getElementById("cbi-cellinfo").style.display="block";
}
else
{
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
// 隐藏小区信息
document.getElementById("cbi-cellinfo").style.display="none";
}
} }
); );
} }
//设置AT串口选项
function set_at_port(port)
{
//获取模块选择框元素
var modem_select = document.getElementById('modem_select');
// 记录所选
var selected=modem_select.value;
// 删除原来的选项
modem_select.options.length=0;
// 更新keyAT串口value模块名称
for (var key in port)
{
var option = document.createElement('option');
option.text = port[key].trim();
option.value = key;
modem_select.appendChild(option);
}
// 恢复原来的选择
for (let i = 0; i < modem_select.options.length; i++)
{
if(modem_select.options[i].value == selected)
{
modem_select.selectedIndex=i;
break;
}
}
}
// 定时触发更新AT串口和模组数据 // 定时触发更新AT串口和模组数据
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_at_port")%>', null, XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_at_port")%>', null,
function(x, port) function(x, port)
{ {
//获取模块选择框元素 //设置AT串口选项
var modem_select = document.getElementById('modem_select'); set_at_port(port);
// 记录所选 //更新模组信息
var selected=modem_select.value;
// 删除原来的选项
modem_select.options.length=0;
// 更新keyAT串口value模块名称
for (var key in port)
{
var option = document.createElement('option');
option.text = port[key].trim();
option.value = key;
modem_select.appendChild(option);
}
// 恢复原来的选择
for (let i = 0; i < modem_select.options.length; i++)
{
if(modem_select.options[i].value == selected)
{
modem_select.selectedIndex=i;
break;
}
}
// 界面显示控制
if (Object.keys(port).length==0) if (Object.keys(port).length==0)
{ {
// 更新提示信息 no_modems_view();
document.getElementById("info_message").innerHTML="<strong><%:No modems found%></strong>"; }
// 显示提示信息 else
document.getElementById("cbi-info").style.display="block"; {
// 隐藏基本信息 update();
document.getElementById("cbi-baseinfo").style.display="none";
// 隐藏SIM卡信息
document.getElementById("cbi-siminfo").style.display="none";
// 隐藏网络信息
document.getElementById("cbi-networkinfo").style.display="none";
// 隐藏小区信息
document.getElementById("cbi-cellinfo").style.display="none";
return
} }
update();
} }
); );
modemtype=0; //无模块界面
cell=0; function no_modems_view()
portx="-";
phonenx = "";
hided = 0;
function clear_data()
{ {
document.getElementById('port').innerHTML="<%:Changing Port%>"; // 更新提示信息
document.getElementById('csq').innerHTML="-"; document.getElementById("info_message").innerHTML="<strong><%:No modems found%></strong>";
document.getElementById('per').innerHTML="-"; // 显示提示信息
document.getElementById('rssi').innerHTML="-"; document.getElementById("cbi-info").style.display="block";
// document.getElementById('modem').innerHTML="-"; // 隐藏基本信息
document.getElementById('cops').innerHTML="-"; document.getElementById("cbi-baseinfo").style.display="none";
document.getElementById('net_type').innerHTML="-"; // 隐藏SIM卡信息
document.getElementById('lac').innerHTML="-"; document.getElementById("cbi-siminfo").style.display="none";
document.getElementById('cid').innerHTML="-"; // 隐藏网络信息
document.getElementById('lacn').innerHTML="-"; document.getElementById("cbi-networkinfo").style.display="none";
document.getElementById('cidn').innerHTML="-"; // 隐藏小区信息
document.getElementById('mcc').innerHTML="-"; document.getElementById("cbi-cellinfo").style.display="none";
document.getElementById('mnc').innerHTML="-";
document.getElementById('rnc').innerHTML="-";
document.getElementById('rncn').innerHTML="-";
document.getElementById('down').innerHTML="-";
document.getElementById('up').innerHTML="-";
document.getElementById('ecio').innerHTML="-";
document.getElementById('rscp').innerHTML="-";
document.getElementById('ecio1').innerHTML="-";
document.getElementById('rscp1').innerHTML="-";
document.getElementById('netmode').innerHTML="-";
document.getElementById('manufacturer').innerHTML=" ";
document.getElementById('chan').innerHTML=" ";
document.getElementById('conmon').innerHTML="-";
document.getElementById('phone').value="-";
document.getElementById('imei').innerHTML="-";
document.getElementById('imsi').innerHTML="-";
document.getElementById('iccid').innerHTML="-";
document.getElementById('lband').innerHTML="-";
document.getElementById('pci').innerHTML="-";
<% if havegps == 1 then %>
document.getElementById('lat').innerHTML="-";
document.getElementById('long').innerHTML="-";
<% end %>
// document.getElementById('idvp').innerHTML="-";
// document.getElementById('phonen').value="-";
} }
//]]> //]]>
</script> </script>
<div class="cbi-map" id="cbi-modem"> <div class="cbi-map" id="cbi-modem">
<h2 name="content"><%:Modem Information%></h2> <h2 name="content"><%:Modem Information%></h2>
<div class="cbi-map-descr"><%:%></div> <div class="cbi-map-descr"><%:%></div>
<!-- <fieldset class="cbi-section" id="simwarn" style="display:none;"> <!-- <fieldset class="cbi-section" id="simwarn" style="display:none;">
<legend><%:SIM警告%></legend> <legend><%:SIM警告%></legend>
@ -362,12 +432,14 @@ end
<fieldset class="cbi-section" id="cbi-siminfo" style="display: none;"> <fieldset class="cbi-section" id="cbi-siminfo" style="display: none;">
<h3><%:SIM Information%></h3> <h3><%:SIM Information%></h3>
<table width="100%" cellspacing="10"> <table width="100%" cellspacing="10" id="sim_info">
<!-- <tr><td width="20%"><%:SIM Status%> :</td><td id="sim_status"></td><td></td></tr>
<tr><td width="20%"><%:ISP%> :</td><td id="isp"></td><td></td></tr> <tr><td width="20%"><%:ISP%> :</td><td id="isp"></td><td></td></tr>
<tr><td width="20%"><%:SIM Slot%> :</td><td id="sim_slot"></td><td></td></tr>
<tr><td width="20%"><%:SIM Number%> :</td><td id="sim_number"></td><td></td></tr>
<tr><td width="20%"><%:IMEI%> :</td><td id="imei"></td><td></td></tr> <tr><td width="20%"><%:IMEI%> :</td><td id="imei"></td><td></td></tr>
<tr><td width="20%"><%:IMSI%> :</td><td id="imsi"></td><td></td></tr> <tr><td width="20%"><%:IMSI%> :</td><td id="imsi"></td><td></td></tr>
<tr><td width="20%"><%:ICCID%> :</td><td id="iccid"></td><td></td></tr> <tr><td width="20%"><%:ICCID%> :</td><td id="iccid"></td><td></td></tr> -->
<tr><td width="20%"><%:SIM Number%> :</td><td id="sim_number"></td><td></td></tr>
</table> </table>
</fieldset> </fieldset>

View File

@ -48,7 +48,7 @@
} }
else else
{ {
name=name.toUpperCase(); mode=mode.toUpperCase();
} }
// 获取连接状态 // 获取连接状态

View File

@ -31,6 +31,12 @@ msgstr "正在加载模组状态"
msgid "Loading modem" msgid "Loading modem"
msgstr "正在加载模组" msgstr "正在加载模组"
msgid "Configuration panel for Modem, Add configuration to all modems on this page"
msgstr "通信模组服务配置界面,在此页面给所有模组添加配置"
msgid "Global Config"
msgstr "全局配置"
msgid "connect" msgid "connect"
msgstr "已连接" msgstr "已连接"
@ -52,15 +58,15 @@ msgstr "连接状态"
msgid "Config List" msgid "Config List"
msgstr "配置列表" msgstr "配置列表"
msgid "Configuration panel for Modem, Add configuration to all modems on this page"
msgstr "通信模组服务配置界面,在此页面给所有模组添加配置"
msgid "AT Commands" msgid "AT Commands"
msgstr "AT命令" msgstr "AT命令"
msgid "Debugging Your Module with AT Command" msgid "Debugging Your Module with AT Command"
msgstr "使用AT命令调试你的模组" msgstr "使用AT命令调试你的模组"
msgid "Response"
msgstr "响应"
msgid "Modem Information" msgid "Modem Information"
msgstr "模组信息" msgstr "模组信息"
@ -166,18 +172,30 @@ msgstr "SIM卡信息"
msgid "ISP" msgid "ISP"
msgstr "运营商" msgstr "运营商"
msgid "IMEI" msgid "SIM Slot"
msgstr "IMEI" msgstr "SIM卡卡槽"
msgid "IMSI" msgid "SIM Status"
msgstr "IMSI" msgstr "SIM卡状态"
msgid "ICCID" msgid "miss"
msgstr "ICCID" msgstr "未插入"
msgid "locked"
msgstr "锁定"
msgid "SIM Number" msgid "SIM Number"
msgstr "SIM卡号码" msgstr "SIM卡号码"
msgid "IMEI"
msgstr "国际移动设备识别码"
msgid "IMSI"
msgstr "国际移动用户识别码"
msgid "ICCID"
msgstr "集成电路卡识别码"
msgid "Network Information" msgid "Network Information"
msgstr "网络信息" msgstr "网络信息"

View File

@ -6,7 +6,7 @@ current_dir="$(dirname "$0")"
get_fibocom_mode() get_fibocom_mode()
{ {
local at_port="$1" local at_port="$1"
local at_command="AT+GTUSBMODE?" at_command="AT+GTUSBMODE?"
local mode_num=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+GTUSBMODE: //g' | sed 's/\r//g') local mode_num=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+GTUSBMODE: //g' | sed 's/\r//g')
local mode local mode
@ -32,11 +32,12 @@ get_fibocom_mode()
get_connect_status() get_connect_status()
{ {
local at_port="$1" local at_port="$1"
local at_command="AT+CGDCONT?" at_command="AT+CGDCONT?"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $6}') local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $6}')
local not_ip="0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" local not_ip="0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
local connect_status
if [ "$response" = "$not_ip" ]; then if [ "$response" = "$not_ip" ]; then
connect_status="disconnect" connect_status="disconnect"
else else
@ -46,51 +47,25 @@ get_connect_status()
echo "$connect_status" echo "$connect_status"
} }
#获取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() fibocom_base_info()
{ {
debug "Fibocom base info" debug "Fibocom base info"
local at_command="ATI" at_command="ATI"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command) response=$(sh $current_dir/modem_at.sh $at_port $at_command)
#名称 #Name名称
name=$(echo "$response" | sed -n '3p' | sed 's/Model: //g' | sed 's/\r//g') name=$(echo "$response" | sed -n '3p' | sed 's/Model: //g' | sed 's/\r//g')
#制造商 #Manufacturer制造商
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/Manufacturer: //g' | sed 's/\r//g') manufacturer=$(echo "$response" | sed -n '2p' | sed 's/Manufacturer: //g' | sed 's/\r//g')
#固件版本 #Revision固件版本
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g') revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
#拨号模式 #Mode拨号模式
mode=$(get_fibocom_mode $at_port | tr 'a-z' 'A-Z') mode=$(get_fibocom_mode $at_port | tr 'a-z' 'A-Z')
#温度 #Temperature温度
at_command="AT+MTSM=1,6" at_command="AT+MTSM=1,6"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+MTSM: //g' | sed 's/\r//g') response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+MTSM: //g' | sed 's/\r//g')
if [ -n "$response" ]; then if [ -n "$response" ]; then
@ -103,8 +78,31 @@ fibocom_sim_info()
{ {
debug "Fibocom sim info" debug "Fibocom sim info"
#SIM SlotSIM卡卡槽
at_command="AT+GTDUALSIM"
sim_slot=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}' | sed 's/SUB//g')
#IMEI国际移动设备识别码
at_command="AT+CGSN"
imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#SIM StatusSIM状态
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
if [ "$sim_status" != "ready" ]; then
return
fi
#ISP互联网服务提供商 #ISP互联网服务提供商
local at_command="AT+COPS?" at_command="AT+COPS?"
isp=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}') 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 # if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
# isp="中国移动" # isp="中国移动"
@ -114,21 +112,17 @@ fibocom_sim_info()
# isp="中国电信" # isp="中国电信"
# fi # fi
#IMEI #SIM NumberSIM卡号码手机号
at_command="AT+CGSN" at_command="AT+CNUM?"
imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g') sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
#IMSI #IMSI国际移动用户识别码
at_command="AT+CIMI" at_command="AT+CIMI"
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g') imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#ICCID #ICCID集成电路卡识别码
at_command="AT+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\}") 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?"
sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
} }
#网络信息 #网络信息
@ -136,8 +130,14 @@ fibocom_network_info()
{ {
debug "Fibocom network info" debug "Fibocom network info"
#Connect Status连接状态
connect_status=$(get_connect_status $at_port)
if [ "$connect_status" != "connect" ]; then
return
fi
#Network Type网络类型 #Network Type网络类型
local at_command="AT+PSRAT?" at_command="AT+PSRAT?"
network_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 # #CSQ
@ -165,9 +165,9 @@ get_band()
{ {
local band local band
case $1 in case $1 in
"WCDMA") band="B$2" ;; "WCDMA") band="$2" ;;
"LTE") band="B$(($2-100))" ;; "LTE") band="$(($2-100))" ;;
"NR") band="$2" band="N${band#*50}" ;; "NR") band="$2" band="${band#*50}" ;;
esac esac
echo "$band" echo "$band"
} }
@ -265,119 +265,120 @@ get_ecio()
echo "$ecio" echo "$ecio"
} }
#网络信息 #小区信息
fibocom_cell_info() fibocom_cell_info()
{ {
debug "Fibocom cell info" debug "Fibocom cell info"
#RSRQRSRPSINR #RSRQRSRPSINR
at_command='AT+GTCCINFO?' at_command='AT+GTCCINFO?'
local response=$(sh $current_dir/modem_at.sh $at_port $at_command) response=$(sh $current_dir/modem_at.sh $at_port $at_command)
local rat=$(echo "$response" | grep "service" | awk -F' ' '{print $1}') local rat=$(echo "$response" | grep "service" | awk -F' ' '{print $1}')
response=$(echo "$response" | sed -n '4p') response=$(echo "$response" | sed -n '4p')
case $rat in case $rat in
"NR") "NR")
network_mode="NR5G-SA Mode" network_mode="NR5G-SA Mode"
nr_mcc=$(echo "$response" | awk -F',' '{print $3}') nr_mcc=$(echo "$response" | awk -F',' '{print $3}')
nr_mnc=$(echo "$response" | awk -F',' '{print $4}') nr_mnc=$(echo "$response" | awk -F',' '{print $4}')
nr_tac=$(echo "$response" | awk -F',' '{print $5}') nr_tac=$(echo "$response" | awk -F',' '{print $5}')
nr_cell_id=$(echo "$response" | awk -F',' '{print $6}') nr_cell_id=$(echo "$response" | awk -F',' '{print $6}')
nr_arfcn=$(echo "$response" | awk -F',' '{print $7}') nr_arfcn=$(echo "$response" | awk -F',' '{print $7}')
nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}') nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
nr_band_num=$(echo "$response" | awk -F',' '{print $9}') nr_band_num=$(echo "$response" | awk -F',' '{print $9}')
nr_band=$(get_band "NR" $nr_band_num) nr_band=$(get_band "NR" $nr_band_num)
nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}') nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num) nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num)
nr_sinr=$(echo "$response" | awk -F',' '{print $11}') nr_sinr=$(echo "$response" | awk -F',' '{print $11}')
nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}') nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
nr_rxlev=$(get_rxlev "NR" $nr_rxlev_num) nr_rxlev=$(get_rxlev "NR" $nr_rxlev_num)
nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}') nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
nr_rsrp=$(get_rsrp "NR" $nr_rsrp_num) nr_rsrp=$(get_rsrp "NR" $nr_rsrp_num)
nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g') nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
nr_rsrq=$(get_rsrq "NR" $nr_rsrq_num) 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_num=$(echo "$response" | awk -F',' '{print $9}')
endc_lte_band=$(get_band "LTE" $endc_lte_band_num)
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_num=$(echo "$response" | awk -F',' '{print $9}')
endc_nr_band=$(get_band "NR" $endc_nr_band_num)
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-NR") "LTE"|"eMTC"|"NB-IoT")
network_mode="EN-DC Mode" network_mode="LTE Mode"
#LTE lte_mcc=$(echo "$response" | awk -F',' '{print $3}')
endc_lte_mcc=$(echo "$response" | awk -F',' '{print $3}') lte_mnc=$(echo "$response" | awk -F',' '{print $4}')
endc_lte_mnc=$(echo "$response" | awk -F',' '{print $4}') lte_tac=$(echo "$response" | awk -F',' '{print $5}')
endc_lte_tac=$(echo "$response" | awk -F',' '{print $5}') lte_cell_id=$(echo "$response" | awk -F',' '{print $6}')
endc_lte_cell_id=$(echo "$response" | awk -F',' '{print $6}') lte_earfcn=$(echo "$response" | awk -F',' '{print $7}')
endc_lte_earfcn=$(echo "$response" | awk -F',' '{print $7}') lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}')
endc_lte_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}') lte_band_num=$(echo "$response" | awk -F',' '{print $9}')
endc_lte_band_num=$(echo "$response" | awk -F',' '{print $9}') lte_band=$(get_band "LTE" $lte_band_num)
endc_lte_band=$(get_band "LTE" $endc_lte_band_num) ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}')
ul_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}') lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num)
endc_lte_ul_bandwidth=$(get_ul_bandwidth $ul_bandwidth_num) lte_dl_bandwidth="$lte_ul_bandwidth"
endc_lte_dl_bandwidth="$endc_lte_ul_bandwidth" lte_rssnr=$(echo "$response" | awk -F',' '{print $11}')
endc_lte_rssnr_num=$(echo "$response" | awk -F',' '{print $11}') lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}')
endc_lte_rssnr=$(get_rssnr $endc_lte_rssnr_num) lte_rxlev=$(get_rxlev "LTE" $lte_rxlev_num)
endc_lte_rxlev_num=$(echo "$response" | awk -F',' '{print $12}') lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}')
endc_lte_rxlev=$(get_rxlev "LTE" $endc_lte_rxlev_num) lte_rsrp=$(get_rsrp "LTE" $lte_rsrp_num)
endc_lte_rsrp_num=$(echo "$response" | awk -F',' '{print $13}') lte_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g')
endc_lte_rsrp=$(get_rsrp "LTE" $endc_lte_rsrp_num) lte_rsrq=$(get_rsrq "LTE" $lte_rsrq_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) "WCDMA"|"UMTS")
#NR5G-NSA network_mode="WCDMA Mode"
endc_nr_mcc=$(echo "$response" | awk -F',' '{print $3}') wcdma_mcc=$(echo "$response" | awk -F',' '{print $3}')
endc_nr_mnc=$(echo "$response" | awk -F',' '{print $4}') wcdma_mnc=$(echo "$response" | awk -F',' '{print $4}')
endc_nr_tac=$(echo "$response" | awk -F',' '{print $5}') wcdma_lac=$(echo "$response" | awk -F',' '{print $5}')
endc_nr_cell_id=$(echo "$response" | awk -F',' '{print $6}') wcdma_cell_id=$(echo "$response" | awk -F',' '{print $6}')
endc_nr_arfcn=$(echo "$response" | awk -F',' '{print $7}') wcdma_uarfcn=$(echo "$response" | awk -F',' '{print $7}')
endc_nr_physical_cell_id=$(echo "$response" | awk -F',' '{print $8}') wcdma_psc=$(echo "$response" | awk -F',' '{print $8}')
endc_nr_band_num=$(echo "$response" | awk -F',' '{print $9}') wcdma_band_num=$(echo "$response" | awk -F',' '{print $9}')
endc_nr_band=$(get_band "NR" $endc_nr_band_num) wcdma_band=$(get_band "WCDMA" $wcdma_band_num)
nr_dl_bandwidth_num=$(echo "$response" | awk -F',' '{print $10}') wcdma_ecno=$(echo "$response" | awk -F',' '{print $10}')
endc_nr_dl_bandwidth=$(get_nr_dl_bandwidth $nr_dl_bandwidth_num) wcdma_rscp=$(echo "$response" | awk -F',' '{print $11}')
endc_nr_sinr=$(echo "$response" | awk -F',' '{print $11}') wcdma_rac=$(echo "$response" | awk -F',' '{print $12}')
endc_nr_rxlev_num=$(echo "$response" | awk -F',' '{print $12}') wcdma_rxlev_num=$(echo "$response" | awk -F',' '{print $13}')
endc_nr_rxlev=$(get_rxlev "NR" $endc_nr_rxlev_num) wcdma_rxlev=$(get_rxlev "WCDMA" $wcdma_rxlev_num)
endc_nr_rsrp_num=$(echo "$response" | awk -F',' '{print $13}') wcdma_reserved=$(echo "$response" | awk -F',' '{print $14}')
endc_nr_rsrp=$(get_rsrp "NR" $endc_nr_rsrp_num) wcdma_ecio_num=$(echo "$response" | awk -F',' '{print $15}' | sed 's/\r//g')
endc_nr_rsrq_num=$(echo "$response" | awk -F',' '{print $14}' | sed 's/\r//g') wcdma_ecio=$(get_ecio $wcdma_ecio_num)
endc_nr_rsrq=$(get_rsrq "NR" $endc_nr_rsrq_num) ;;
;; esac
"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_num=$(echo "$response" | awk -F',' '{print $9}')
lte_band=$(get_band "LTE" $lte_band_num)
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_num=$(echo "$response" | awk -F',' '{print $9}')
wcdma_band=$(get_band "WCDMA" $wcdma_band_num)
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_num=$(echo "$response" | awk -F',' '{print $15}' | sed 's/\r//g')
wcdma_ecio=$(get_ecio $wcdma_ecio_num)
;;
esac
} }
@ -523,20 +524,23 @@ get_fibocom_info()
#基本信息 #基本信息
fibocom_base_info fibocom_base_info
#获取SIM状态 #SIM卡信息
sim_status=$(get_fibocom_sim_status) fibocom_sim_info
if [ "$sim_status" != "ready" ];then if [ "$sim_status" != "ready" ]; then
return return
fi fi
#SIM卡信息
fibocom_sim_info
#网络信息 #网络信息
fibocom_network_info fibocom_network_info
if [ "$connect_status" != "connect" ]; then
return
fi
#小区信息 #小区信息
fibocom_cell_info fibocom_cell_info
return return
# Fibocom_Cellinfo # Fibocom_Cellinfo
#基站信息 #基站信息

View File

@ -15,17 +15,19 @@ init_modem_info()
at_port='-' #AT串口 at_port='-' #AT串口
mode='unknown' #拨号模式 mode='unknown' #拨号模式
temperature="NaN $(printf "\xc2\xb0")C" #温度 temperature="NaN $(printf "\xc2\xb0")C" #温度
update_time='' #更新时间 update_time='-' #更新时间
#SIM卡信息 #SIM卡信息
sim_status="miss" #SIM卡状态 sim_status="miss" #SIM卡状态
sim_slot="-" #SIM卡卡槽
isp="-" #运营商(互联网服务提供商) isp="-" #运营商(互联网服务提供商)
sim_number='-' #SIM卡号码手机号
imei='-' #IMEI imei='-' #IMEI
imsi='-' #IMSI imsi='-' #IMSI
iccid='-' #ICCID iccid='-' #ICCID
sim_number='-' #SIM卡号码手机号
#网络信息 #网络信息
connect_status="disconnect" #SIM卡状态
network_type="-" #蜂窝网络类型 network_type="-" #蜂窝网络类型
#小区信息 #小区信息
@ -131,8 +133,8 @@ init_modem_info()
qos="" #最大Qos级别 qos="" #最大Qos级别
} }
#获取基本信息 #设置基本信息
get_base_info() set_base_info()
{ {
base_info="\"base_info\":{ base_info="\"base_info\":{
\"manufacturer\":\"$manufacturer\", \"manufacturer\":\"$manufacturer\",
@ -144,28 +146,44 @@ get_base_info()
}," },"
} }
#获取SIM卡信息 #设置SIM卡信息
get_sim_info() set_sim_info()
{ {
sim_info="\"sim_info\":{ if [ "$sim_status" = "ready" ]; then
\"isp\":\"$isp\", sim_info="\"sim_info\":[
\"imei\":\"$imei\", {\"ISP\":\"$isp\", \"full_name\":\"Internet Service Provider\"},
\"imsi\":\"$imsi\", {\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
\"iccid\":\"$iccid\", {\"SIM Number\":\"$sim_number\", \"full_name\":\"SIM Number\"},
\"sim_number\":\"$sim_number\" {\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"},
}," {\"IMSI\":\"$imsi\", \"full_name\":\"International Mobile Subscriber Identity\"},
{\"ICCID\":\"$iccid\", \"full_name\":\"Integrate Circuit Card Identity\"}
],"
elif [ "$sim_status" = "miss" ]; then
sim_info="\"sim_info\":[
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"}
],"
elif [ "$sim_status" = "locked" ]; then
sim_info="\"sim_info\":[
{\"SIM Status\":\"$sim_status\", \"full_name\":\"SIM Status\"},
{\"SIM Slot\":\"$sim_slot\", \"full_name\":\"SIM Slot\"},
{\"IMEI\":\"$imei\", \"full_name\":\"International Mobile Equipment Identity\"},
{\"IMSI\":\"$imsi\", \"full_name\":\"International Mobile Subscriber Identity\"},
{\"ICCID\":\"$iccid\", \"full_name\":\"Integrate Circuit Card Identity\"}
],"
fi
} }
#获取网络信息 #设置网络信息
get_network_info() set_network_info()
{ {
network_info="\"network_info\":{ network_info="\"network_info\":{
\"network_type\":\"$network_type\" \"network_type\":\"$network_type\"
}," },"
} }
#获取信号信息 #设置信号信息
get_cell_info() set_cell_info()
{ {
if [ "$network_mode" = "NR5G-SA Mode" ]; then if [ "$network_mode" = "NR5G-SA Mode" ]; then
cell_info="\"cell_info\":{ cell_info="\"cell_info\":{
@ -284,16 +302,17 @@ info_to_json()
network_info="\"network_info\":{}," network_info="\"network_info\":{},"
cell_info="\"cell_info\":{}" cell_info="\"cell_info\":{}"
#获取基本信息 #设置基本信息
get_base_info set_base_info
if [ "$sim_status" = "ready" ];then #设置SIM卡信息
#获取SIM卡信息 set_sim_info
get_sim_info
#获取网络信息 if [ "$sim_status" = "ready" ] && [ "$connect_status" = "connect" ]; then
get_network_info #设置网络信息
#获取小区信息 set_network_info
get_cell_info #设置小区信息
set_cell_info
fi fi
#拼接所有信息(不要漏掉最后一个} #拼接所有信息(不要漏掉最后一个}

View File

@ -6,7 +6,7 @@ current_dir="$(dirname "$0")"
get_quectel_mode() get_quectel_mode()
{ {
local at_port="$1" local at_port="$1"
local at_command='AT+QCFG="usbnet"' at_command='AT+QCFG="usbnet"'
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_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 local mode
@ -27,10 +27,11 @@ get_quectel_mode()
get_connect_status() get_connect_status()
{ {
local at_port="$1" local at_port="$1"
local at_command="AT+QNWINFO" at_command="AT+QNWINFO"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p') local response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
local connect_status
if [[ "$response" = *"No Service"* ]]; then if [[ "$response" = *"No Service"* ]]; then
connect_status="disconnect" connect_status="disconnect"
else else
@ -40,51 +41,25 @@ get_connect_status()
echo "$connect_status" echo "$connect_status"
} }
#获取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() quectel_base_info()
{ {
debug "Quectel base info" debug "Quectel base info"
local at_command="ATI" at_command="ATI"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command) response=$(sh $current_dir/modem_at.sh $at_port $at_command)
#名称 #Name名称
name=$(echo "$response" | sed -n '3p' | sed 's/\r//g') name=$(echo "$response" | sed -n '3p' | sed 's/\r//g')
#制造商 #Manufacturer制造商
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/\r//g') manufacturer=$(echo "$response" | sed -n '2p' | sed 's/\r//g')
#固件版本 #Revision固件版本
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g') revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
#拨号模式 #Mode拨号模式
mode=$(get_quectel_mode $at_port | tr 'a-z' 'A-Z') mode=$(get_quectel_mode $at_port | tr 'a-z' 'A-Z')
#温度 #Temperature温度
at_command="AT+QTEMP" at_command="AT+QTEMP"
response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}') response=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
if [ -n "$response" ]; then if [ -n "$response" ]; then
@ -111,8 +86,31 @@ quectel_sim_info()
{ {
debug "Quectel sim info" debug "Quectel sim info"
#SIM SlotSIM卡卡槽
at_command="AT+QUIMSLOT?"
sim_slot=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F' ' '{print $2}' | sed 's/\r//g')
#IMEI国际移动设备识别码
at_command="AT+CGSN"
imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#SIM StatusSIM状态
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
if [ "$sim_status" != "ready" ]; then
return
fi
#ISP互联网服务提供商 #ISP互联网服务提供商
local at_command="AT+COPS?" at_command="AT+COPS?"
isp=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}') 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 # if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
# isp="中国移动" # isp="中国移动"
@ -124,21 +122,17 @@ quectel_sim_info()
# isp="中国电信" # isp="中国电信"
# fi # fi
#IMEI #SIM NumberSIM卡号码手机号
at_command="AT+CGSN" at_command="AT+CNUM"
imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g') sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
#IMSI #IMSI国际移动用户识别码
at_command="AT+CIMI" at_command="AT+CIMI"
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g') imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#ICCID #ICCID(集成电路卡识别码)
at_command="AT+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\}") # 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"
sim_number=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
} }
#网络信息 #网络信息
@ -146,9 +140,15 @@ quectel_network_info()
{ {
debug "Quectel network info" debug "Quectel network info"
#Connect Status连接状态
connect_status=$(get_connect_status $at_port)
if [ "$connect_status" != "connect" ]; then
return
fi
#Network Type网络类型 #Network Type网络类型
# local at_command="AT+COPS?" # at_command="AT+COPS?"
local at_command="AT+QNWINFO" at_command="AT+QNWINFO"
network_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 #CSQ
@ -176,9 +176,9 @@ get_band()
{ {
local band local band
case $1 in case $1 in
"WCDMA") band="B$2" ;; "WCDMA") band="$2" ;;
"LTE") band="B$2" ;; "LTE") band="$2" ;;
"NR") band="N$2" ;; "NR") band="$2" ;;
esac esac
echo "$band" echo "$band"
} }
@ -280,8 +280,8 @@ quectel_cell_info()
{ {
debug "Quectel cell info" debug "Quectel cell info"
local at_command='AT+QENG="servingcell"' at_command='AT+QENG="servingcell"'
local response=$(sh $current_dir/modem_at.sh $at_port $at_command) response=$(sh $current_dir/modem_at.sh $at_port $at_command)
local lte=$(echo "$response" | grep "+QENG: \"LTE\"") local lte=$(echo "$response" | grep "+QENG: \"LTE\"")
local nr5g_nsa=$(echo "$response" | grep "+QENG: \"NR5G-NSA\"") local nr5g_nsa=$(echo "$response" | grep "+QENG: \"NR5G-NSA\"")
@ -708,16 +708,18 @@ get_quectel_info()
#基本信息 #基本信息
quectel_base_info quectel_base_info
#获取SIM状态 #SIM卡信息
sim_status=$(get_quectel_sim_status) quectel_sim_info
if [ "$sim_status" != "ready" ];then if [ "$sim_status" != "ready" ]; then
return return
fi fi
#SIM卡信息
quectel_sim_info
#网络信息 #网络信息
quectel_network_info quectel_network_info
if [ "$connect_status" != "connect" ]; then
return
fi
#小区信息 #小区信息
quectel_cell_info quectel_cell_info