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

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
--AT命令
-- local modem_number=uci:get('modem','@global[0]','modem_number')
-- 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", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).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", "user_at_command"}, call("userATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "get_at_port"}, call("getATPort"), nil).leaf = true
end
-- 判断字符串是否含有字母
function hasLetters(str)
local pattern = "%a" -- 匹配字母的正则表达式
return string.find(str, pattern) ~= nil
end
-- AT命令
function at(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"
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=string.gsub(connect_status, "\n", "")
odpall:close()
@ -59,8 +62,8 @@ function getModemConnectStatus(at_port,manufacturer)
end
-- 获取模组基本信息
function getModemBaseInfo(at_port)
local modem_base_info={}
function getModemDeviceInfo(at_port)
local modem_device_info={}
uci:foreach("modem", "modem-device", function (modem_device)
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"])
--设置值
modem_base_info=modem_device
modem_base_info["data_interface"]=data_interface
modem_base_info["connect_status"]=connect_status
modem_device_info=modem_device
modem_device_info["data_interface"]=data_interface
modem_device_info["connect_status"]=connect_status
return true
end
end)
return modem_base_info
return modem_device_info
end
-- 获取模组更多信息
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 opd = odpall:read("*a")
odpall:close()
modem_more_info=json.parse(opd)
--设置值
local modem_more_info=json.parse(opd)
return modem_more_info
end
@ -102,34 +103,53 @@ function getModemInfo()
local at_port = http.formvalue("port")
--获取信息
local modem_base_info
local modem_device_info
local modem_more_info
if at_port then
modem_base_info=getModemBaseInfo(at_port)
modem_more_info=getModemMoreInfo(at_port,modem_base_info["manufacturer"])
modem_device_info=getModemDeviceInfo(at_port)
modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"])
end
--设置信息
local modem_info={}
modem_info["base_info"]=modem_base_info
modem_info["device_info"]=modem_device_info
modem_info["more_info"]=modem_more_info
--设置翻译
local translation={}
--SIM卡信息翻译
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()
translation[key_origin]=luci.i18n.translate(key_origin)
local sim_info=modem_more_info["sim_info"]
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
--网络信息翻译
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
for key in pairs(modem_more_info["cell_info"]) do
translation[key]=luci.i18n.translate(key)
local network_mode=modem_more_info["cell_info"][key]
for i = 1, #network_mode do
local value = network_mode[i]
for key in pairs(value) do
local info = network_mode[i]
for key in pairs(info) do
translation[key]=luci.i18n.translate(key)
end
end

View File

@ -5,7 +5,8 @@ m = Map("modem")
m.title = translate("Modem Config")
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.addremove = false

View File

@ -1,60 +1,15 @@
<%+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;">
<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" 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>
<style type="text/css">
#modem_status_view > div {
display: inline-block;
margin: 1rem;
padding: 1rem;
width: 15rem;
float: left;
line-height: 125%;
}
</style>
<script type="text/javascript">
@ -173,7 +128,6 @@
return false;
}
document.addEventListener('DOMContentLoaded', function (ev) {var button = document.getElementById("sendcmd");
button.addEventListener("click", function () {
@ -213,5 +167,65 @@
</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%>

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='';
@ -39,28 +83,42 @@ end
//遍历每一条信息里的键
for (var key in info)
{
//获取全名
var full_name=info["full_name"];
if (full_name==null)
{
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") {
info[key]=info[key]+" MHz"
if (key=="Band") {
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") {
info[key]=info[key]+" dBm"
value=value+" dBm"
}
else if (key=="RSRQ"||key=="SINR"||key=="RSSNR"||key=="Ec/Io") {
info[key]=info[key]+" dB"
value=value+" dB"
}
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 cell_info_view='<caption>'+translation[network_mode]+'</caption>'; //网络模式视图
//获取网络模式下的信息
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")
{
console.log(aaa);
var lte=network_mode_info[0]["LTE"];
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"];
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
{
// 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;
}
// 更新模组数据
//显示信息
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()
{
// var at_port="";
// if (modem_select.options.length!=0) {
var at_port=modem_select.options[modem_select.selectedIndex].value;
// }
// else {
// return
// }
//获取选中的AT串口
var at_port=modem_select.options[modem_select.selectedIndex].value;
//获取模组信息
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_info")%>', {"port":at_port},
function(x, data)
{
@ -114,204 +271,117 @@ end
var modem_info=data["modem_info"];
var translation=data["translation"];
var base_info=modem_info["base_info"];
var connect_status=base_info["connect_status"];
for (var key in base_info)
{
var base_info_Element=document.getElementById(key);
if (base_info_Element!=null)
{
base_info_Element.innerHTML=base_info[key];
}
}
// 设备信息
var device_info=modem_info["device_info"];
set_info(device_info);
// 更多信息
var more_info=modem_info["more_info"];
//基本信息
base_info=more_info["base_info"];
for (var key in base_info)
{
var base_info_Element=document.getElementById(key);
if (base_info_Element!=null)
{
base_info_Element.innerHTML=base_info[key];
}
}
var base_info=more_info["base_info"];
set_info(base_info);
// 界面显示控制
// 隐藏提示信息
document.getElementById("cbi-info").style.display="none";
// 显示基本信息
document.getElementById("cbi-baseinfo").style.display="block";
//基本信息界面控制
base_info_view(base_info["manufacturer"]);
//未适配模组
if (base_info["manufacturer"]=="unknown") {
return
}
//SIM卡信息
var sim_info=more_info["sim_info"];
for (var key in sim_info)
{
var sim_info_Element=document.getElementById(key);
if (sim_info_Element!=null)
{
sim_info_Element.innerHTML=translation[sim_info[key]];
}
}
set_sim_info(sim_info,translation);
// 界面显示控制
if (base_info["manufacturer"]!="unknown")
{
// 显示SIM卡信息
document.getElementById("cbi-siminfo").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";
//SIM卡信息显示控制
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") {
return
}
//网络信息
var network_info=more_info["network_info"];
for (var key in network_info)
{
var network_info_Element=document.getElementById(key);
if (network_info_Element!=null)
{
network_info_Element.innerHTML=network_info[key];
}
}
set_info(network_info);
//小区信息
var cell_info=more_info["cell_info"];
if (cell_info!=null)
{
show_cell_info(cell_info,translation);
}
set_cell_info(cell_info,translation);
// 界面显示控制
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";
}
//网络信息和小区信息界面显示控制
network_info_view(device_info["connect_status"]);
}
);
}
//设置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串口和模组数据
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_at_port")%>', null,
function(x, 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串口选项
set_at_port(port);
//更新模组信息
if (Object.keys(port).length==0)
{
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:No modems found%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 隐藏基本信息
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
no_modems_view();
}
else
{
update();
}
update();
}
);
modemtype=0;
cell=0;
portx="-";
phonenx = "";
hided = 0;
function clear_data()
//无模块界面
function no_modems_view()
{
document.getElementById('port').innerHTML="<%:Changing Port%>";
document.getElementById('csq').innerHTML="-";
document.getElementById('per').innerHTML="-";
document.getElementById('rssi').innerHTML="-";
// document.getElementById('modem').innerHTML="-";
document.getElementById('cops').innerHTML="-";
document.getElementById('net_type').innerHTML="-";
document.getElementById('lac').innerHTML="-";
document.getElementById('cid').innerHTML="-";
document.getElementById('lacn').innerHTML="-";
document.getElementById('cidn').innerHTML="-";
document.getElementById('mcc').innerHTML="-";
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="-";
// 更新提示信息
document.getElementById("info_message").innerHTML="<strong><%:No modems found%></strong>";
// 显示提示信息
document.getElementById("cbi-info").style.display="block";
// 隐藏基本信息
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";
}
//]]>
</script>
<div class="cbi-map" id="cbi-modem">
<h2 name="content"><%:Modem Information%></h2>
<div class="cbi-map-descr"><%:%></div>
<h2 name="content"><%:Modem Information%></h2>
<div class="cbi-map-descr"><%:%></div>
<!-- <fieldset class="cbi-section" id="simwarn" style="display:none;">
<legend><%:SIM警告%></legend>
@ -362,12 +432,14 @@ end
<fieldset class="cbi-section" id="cbi-siminfo" style="display: none;">
<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%"><%: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%"><%: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%"><%:SIM Number%> :</td><td id="sim_number"></td><td></td></tr>
<tr><td width="20%"><%:ICCID%> :</td><td id="iccid"></td><td></td></tr> -->
</table>
</fieldset>

View File

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

View File

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

View File

@ -6,7 +6,7 @@ current_dir="$(dirname "$0")"
get_fibocom_mode()
{
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
@ -32,11 +32,12 @@ get_fibocom_mode()
get_connect_status()
{
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 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
connect_status="disconnect"
else
@ -46,51 +47,25 @@ get_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()
{
debug "Fibocom base info"
local at_command="ATI"
local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
at_command="ATI"
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')
#制造商
#Manufacturer制造商
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')
#拨号模式
#Mode拨号模式
mode=$(get_fibocom_mode $at_port | tr 'a-z' 'A-Z')
#温度
#Temperature温度
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')
if [ -n "$response" ]; then
@ -103,8 +78,31 @@ 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互联网服务提供商
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}')
# if [ "$isp" = "CHN-CMCC" ] || [ "$isp" = "CMCC" ]|| [ "$isp" = "46000" ]; then
# isp="中国移动"
@ -114,21 +112,17 @@ fibocom_sim_info()
# isp="中国电信"
# fi
#IMEI
at_command="AT+CGSN"
imei=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#SIM NumberSIM卡号码手机号
at_command="AT+CNUM?"
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"
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
#ICCID
#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?"
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"
#Connect Status连接状态
connect_status=$(get_connect_status $at_port)
if [ "$connect_status" != "connect" ]; then
return
fi
#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')
# #CSQ
@ -165,9 +165,9 @@ get_band()
{
local band
case $1 in
"WCDMA") band="B$2" ;;
"LTE") band="B$(($2-100))" ;;
"NR") band="$2" band="N${band#*50}" ;;
"WCDMA") band="$2" ;;
"LTE") band="$(($2-100))" ;;
"NR") band="$2" band="${band#*50}" ;;
esac
echo "$band"
}
@ -265,119 +265,120 @@ get_ecio()
echo "$ecio"
}
#网络信息
#小区信息
fibocom_cell_info()
{
debug "Fibocom cell info"
#RSRQRSRPSINR
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}')
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_num=$(echo "$response" | awk -F',' '{print $9}')
nr_band=$(get_band "NR" $nr_band_num)
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)
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_num=$(echo "$response" | awk -F',' '{print $9}')
nr_band=$(get_band "NR" $nr_band_num)
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_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")
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"|"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
"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
#获取SIM状态
sim_status=$(get_fibocom_sim_status)
if [ "$sim_status" != "ready" ];then
#SIM卡信息
fibocom_sim_info
if [ "$sim_status" != "ready" ]; then
return
fi
#SIM卡信息
fibocom_sim_info
#网络信息
fibocom_network_info
if [ "$connect_status" != "connect" ]; then
return
fi
#小区信息
fibocom_cell_info
return
# Fibocom_Cellinfo
#基站信息

View File

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

View File

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