优化模块信息扫描
This commit is contained in:
parent
b16811a70f
commit
8c9c819a1c
@ -34,6 +34,9 @@ function index()
|
|||||||
|
|
||||||
--AT命令旧界面
|
--AT命令旧界面
|
||||||
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
|
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
|
||||||
|
|
||||||
|
--AT快捷命令配置
|
||||||
|
--entry({"admin", "network", "modem", "quick_commands_config"},cbi("modem/quick_commands_config"),translate("自定义快捷命令配置"),40).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -148,38 +151,40 @@ function getModemInfo()
|
|||||||
--设置翻译
|
--设置翻译
|
||||||
local translation={}
|
local translation={}
|
||||||
--设备信息翻译
|
--设备信息翻译
|
||||||
if modem_device_info then
|
-- if modem_device_info then
|
||||||
-- local name=modem_device_info["name"]
|
-- local name=modem_device_info["name"]
|
||||||
-- translation[name]=luci.i18n.translate(name)
|
-- translation[name]=luci.i18n.translate(name)
|
||||||
-- local manufacturer=modem_device_info["manufacturer"]
|
-- local manufacturer=modem_device_info["manufacturer"]
|
||||||
-- translation[manufacturer]=luci.i18n.translate(manufacturer)
|
-- translation[manufacturer]=luci.i18n.translate(manufacturer)
|
||||||
-- local mode=modem_device_info["mode"]
|
-- local mode=modem_device_info["mode"]
|
||||||
-- translation[mode]=luci.i18n.translate(mode)
|
-- translation[mode]=luci.i18n.translate(mode)
|
||||||
local data_interface=modem_device_info["data_interface"]
|
-- local data_interface=modem_device_info["data_interface"]
|
||||||
translation[data_interface]=luci.i18n.translate(data_interface)
|
-- translation[data_interface]=luci.i18n.translate(data_interface)
|
||||||
local network=modem_device_info["network"]
|
-- local network=modem_device_info["network"]
|
||||||
translation[network]=luci.i18n.translate(network)
|
-- translation[network]=luci.i18n.translate(network)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
--基本信息翻译
|
--基本信息翻译
|
||||||
if modem_more_info["base_info"] then
|
-- if modem_more_info["base_info"] then
|
||||||
for key in pairs(modem_more_info["base_info"]) do
|
-- for key in pairs(modem_more_info["base_info"]) do
|
||||||
local value=modem_more_info["base_info"][key]
|
-- local value=modem_more_info["base_info"][key]
|
||||||
--翻译值
|
-- --翻译值
|
||||||
translation[value]=luci.i18n.translate(value)
|
-- translation[value]=luci.i18n.translate(value)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
--SIM卡信息翻译
|
--SIM卡信息翻译
|
||||||
if modem_more_info["sim_info"] then
|
if modem_more_info["sim_info"] then
|
||||||
local sim_info=modem_more_info["sim_info"]
|
local sim_info=modem_more_info["sim_info"]
|
||||||
for i = 1, #sim_info do
|
for i = 1, #sim_info do
|
||||||
local info = sim_info[i]
|
local info = sim_info[i]
|
||||||
for key in pairs(info) do
|
for key in pairs(info) do
|
||||||
|
--翻译键
|
||||||
translation[key]=luci.i18n.translate(key)
|
translation[key]=luci.i18n.translate(key)
|
||||||
local value=info[key]
|
-- local value=info[key]
|
||||||
if hasLetters(value) then
|
-- if hasLetters(value) then
|
||||||
translation[value]=luci.i18n.translate(value)
|
-- --翻译值
|
||||||
end
|
-- translation[value]=luci.i18n.translate(value)
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -188,11 +193,11 @@ function getModemInfo()
|
|||||||
for key in pairs(modem_more_info["network_info"]) do
|
for key in pairs(modem_more_info["network_info"]) do
|
||||||
--翻译键
|
--翻译键
|
||||||
translation[key]=luci.i18n.translate(key)
|
translation[key]=luci.i18n.translate(key)
|
||||||
local value=modem_more_info["network_info"][key]
|
-- local value=modem_more_info["network_info"][key]
|
||||||
if hasLetters(value) then
|
-- if hasLetters(value) then
|
||||||
--翻译值
|
-- --翻译值
|
||||||
translation[value]=luci.i18n.translate(value)
|
-- translation[value]=luci.i18n.translate(value)
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--小区信息翻译
|
--小区信息翻译
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
-- Copyright 2020-2021 Rafa<66> Wabik (IceG) - From eko.one.pl forum
|
||||||
|
-- Licensed to the GNU General Public License v3.0.
|
||||||
|
|
||||||
|
local dispatcher = require "luci.dispatcher"
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
local http = require "luci.http"
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
|
|
||||||
|
local AT_FILE_PATH = "/etc/modem/custom_at_commands.json"
|
||||||
|
|
||||||
|
m = Map("sms_tool")
|
||||||
|
m.title = translate("Configuration sms-tool")
|
||||||
|
m.description = translate("Configuration panel for sms_tool and gui application.")
|
||||||
|
|
||||||
|
-- 自定义命令 --
|
||||||
|
s = m:section(TypedSection, "custom_at_commands", translate("Custom AT Commands"))
|
||||||
|
s.anonymous = true
|
||||||
|
s.addremove = true
|
||||||
|
s.template = "cbi/tblsection"
|
||||||
|
|
||||||
|
description = s:option(Value, "description", translate("Description"))
|
||||||
|
description.placeholder = ""
|
||||||
|
description.rmempty = false
|
||||||
|
description.optional = false
|
||||||
|
|
||||||
|
command = s:option(Value, "command", translate("Command"))
|
||||||
|
-- command.placeholder = ""
|
||||||
|
command.rmempty = false
|
||||||
|
-- command.optional = false
|
||||||
|
|
||||||
|
function command.cfgvalue(self, section)
|
||||||
|
local custom_commands=fs.readfile(AT_FILE_PATH)
|
||||||
|
return "模组信息 > ATI"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- RAW File --
|
||||||
|
s = m:section(NamedSection, 'general' , "sms_tool" , translate(""))
|
||||||
|
s.anonymous = true
|
||||||
|
|
||||||
|
local tat = s:option(TextValue, "user_at", translate("User AT Commands"), translate("Each line must have the following format: 'AT Command name;AT Command'. Save to file '/etc/config/atcmds.user'."))
|
||||||
|
tat.rows = 20
|
||||||
|
tat.rmempty = true
|
||||||
|
|
||||||
|
function tat.cfgvalue(self, section)
|
||||||
|
return fs.readfile(AT_FILE_PATH)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tat.write(self, section, value)
|
||||||
|
value = value:gsub("\r\n", "\n")
|
||||||
|
fs.writefile(AT_FILE_PATH, value)
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
@ -176,14 +176,14 @@ end
|
|||||||
}
|
}
|
||||||
|
|
||||||
//显示信息
|
//显示信息
|
||||||
function set_info(info,translation)
|
function set_info(info)
|
||||||
{
|
{
|
||||||
for (var key in info)
|
for (var key in info)
|
||||||
{
|
{
|
||||||
var info_Element=document.getElementById(key);
|
var info_Element=document.getElementById(key);
|
||||||
if (info_Element!=null)
|
if (info_Element!=null)
|
||||||
{
|
{
|
||||||
info_Element.innerHTML=translation[info[key]];
|
info_Element.innerHTML=info[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,13 +305,13 @@ end
|
|||||||
|
|
||||||
// 设备信息
|
// 设备信息
|
||||||
var device_info=modem_info["device_info"];
|
var device_info=modem_info["device_info"];
|
||||||
set_info(device_info,translation);
|
set_info(device_info);
|
||||||
|
|
||||||
// 更多信息
|
// 更多信息
|
||||||
var more_info=modem_info["more_info"];
|
var more_info=modem_info["more_info"];
|
||||||
//基本信息
|
//基本信息
|
||||||
var base_info=more_info["base_info"];
|
var base_info=more_info["base_info"];
|
||||||
set_info(base_info,translation);
|
set_info(base_info);
|
||||||
|
|
||||||
//基本信息界面控制
|
//基本信息界面控制
|
||||||
base_info_view(base_info["manufacturer"]);
|
base_info_view(base_info["manufacturer"]);
|
||||||
@ -334,7 +334,7 @@ end
|
|||||||
|
|
||||||
//网络信息
|
//网络信息
|
||||||
var network_info=more_info["network_info"];
|
var network_info=more_info["network_info"];
|
||||||
set_info(network_info,translation);
|
set_info(network_info);
|
||||||
|
|
||||||
//小区信息
|
//小区信息
|
||||||
var cell_info=more_info["cell_info"];
|
var cell_info=more_info["cell_info"];
|
||||||
|
@ -106,70 +106,60 @@ setPortConfig()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#设置模块信息(名称、制造商、拨号模式)
|
#设置模组信息(名称、制造商、拨号模式)
|
||||||
# $modem_count:模块计数
|
# $modem_count:模组计数
|
||||||
# $1:模块序号
|
# $1:模组序号
|
||||||
# $2:AT串口
|
# $2:AT串口
|
||||||
setModemInfoConfig()
|
setModemInfoConfig()
|
||||||
{
|
{
|
||||||
#获取数据接口
|
#获取数据接口
|
||||||
local data_interface=$(uci -q get modem.modem$1.data_interface)
|
local data_interface=$(uci -q get modem.modem$1.data_interface)
|
||||||
|
|
||||||
#遍历模块信息文件
|
#获取支持的模组
|
||||||
local line_count=$(wc -l < "$modem_support_file")
|
local modem_support=$(cat $current_dir/modem_support.json)
|
||||||
local line_context
|
|
||||||
for i in $(seq 1 $(($line_count))); do
|
|
||||||
|
|
||||||
#获取一行的内容
|
#获取模组名
|
||||||
local line_context=$(sed -n $i'p' "$modem_support_file")
|
local at_response=$(sh $current_dir/modem_at.sh $2 "AT+CGMM" | sed -n '2p' | sed 's/\r//g' | tr 'A-Z' 'a-z')
|
||||||
#获取数据接口内容
|
|
||||||
local data_interface_info=$(echo "$line_context" | cut -d ";" -f 4)
|
|
||||||
if [ "$data_interface" = "$data_interface_info" ]; then
|
|
||||||
#获取模块名
|
|
||||||
local modem_name=$(echo "$line_context" | cut -d ";" -f 2)
|
|
||||||
|
|
||||||
local at_result
|
#获取模组信息
|
||||||
if [ "$modem_name" != "unknown" ]; then
|
local modem_info=$(echo $modem_support | jq '.modem_support.'$data_interface'."'$at_response'"')
|
||||||
#获取AT命令返回的内容
|
|
||||||
at_result=$(echo `sh $current_dir/modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
|
|
||||||
else
|
|
||||||
#数据库中没有此模块的信息,使用默认值
|
|
||||||
at_result="unknown"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$at_result" = *"$modem_name"* ]]; then
|
local modem_name
|
||||||
#设置模块名
|
local manufacturer
|
||||||
uci set modem.modem$1.name="$modem_name"
|
local platform
|
||||||
|
local mode
|
||||||
|
local modes
|
||||||
|
if [ "$modem_info" = "null" ]; then
|
||||||
|
modem_name="unknown"
|
||||||
|
manufacturer="unknown"
|
||||||
|
platform="unknown"
|
||||||
|
mode="unknown"
|
||||||
|
modes="qmi gobinet ecm mbim rndis ncm"
|
||||||
|
else
|
||||||
|
#获取模组名
|
||||||
|
modem_name="$at_response"
|
||||||
|
#获取制造商
|
||||||
|
manufacturer=$(echo $modem_info | jq -r '.manufacturer')
|
||||||
|
#获取平台
|
||||||
|
platform=$(echo $modem_info | jq -r '.platform')
|
||||||
|
#获取当前的拨号模式
|
||||||
|
mode=$(source $current_dir/$manufacturer.sh && get_mode $2 $platform)
|
||||||
|
#获取支持的拨号模式
|
||||||
|
modes=$(echo $modem_info | jq -r '.modes[]')
|
||||||
|
fi
|
||||||
|
|
||||||
#设置制造商
|
#设置模组名
|
||||||
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
uci set modem.modem$1.name="$modem_name"
|
||||||
uci set modem.modem$1.manufacturer="$manufacturer"
|
#设置制造商
|
||||||
|
uci set modem.modem$1.manufacturer="$manufacturer"
|
||||||
#设置平台
|
#设置平台
|
||||||
local platform=$(echo "$line_context" | cut -d ";" -f 3)
|
uci set modem.modem$1.platform="$platform"
|
||||||
uci set modem.modem$1.platform="$platform"
|
#设置当前的拨号模式
|
||||||
|
uci set modem.modem$1.mode="$mode"
|
||||||
#设置当前的拨号模式
|
#设置支持的拨号模式
|
||||||
local mode
|
uci -q del modem.modem$1.modes #删除原来的拨号模式列表
|
||||||
if [ "$manufacturer" = "unknown" ]; then
|
for mode in $modes; do
|
||||||
mode="unknown"
|
uci add_list modem.modem$1.modes="$mode"
|
||||||
else
|
|
||||||
mode=$(source $current_dir/$manufacturer.sh && get_mode $2 $platform)
|
|
||||||
fi
|
|
||||||
uci set modem.modem$1.mode="$mode"
|
|
||||||
|
|
||||||
#设置支持的拨号模式
|
|
||||||
local modes=$(echo "$line_context" | cut -d ";" -f 5 | tr ',' ' ')
|
|
||||||
|
|
||||||
#删除原来的拨号模式列表
|
|
||||||
uci -q del modem.modem$1.modes
|
|
||||||
#添加新的拨号模式列表
|
|
||||||
for mode in $modes; do
|
|
||||||
uci add_list modem.modem$1.modes="$mode"
|
|
||||||
done
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
quectel;rg200u-cn;unisoc;usb;ecm,mbim,rndis,ncm
|
|
||||||
quectel;rm500u-cn;unisoc;usb;ecm,mbim,rndis,ncm
|
|
||||||
quectel;rm500q-gl;qualcomm;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
|
||||||
quectel;rm500q-gl;qualcomm;pcie;qmi,gobinet,mbim
|
|
||||||
quectel;rm502q-gl;qualcomm;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
|
||||||
quectel;rm502q-gl;qualcomm;pcie;qmi,gobinet,mbim
|
|
||||||
fibocom;fm650-cn;unisoc;usb;ecm,mbim,rndis,ncm
|
|
||||||
fibocom;fm150-ae;qualcomm;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
|
||||||
fibocom;fm150-ae;qualcomm;pcie;qmi
|
|
||||||
fibocom;fm160-cn;qualcomm;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
|
||||||
unknown;unknown;unknown;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
|
||||||
unknown;unknown;unknown;pcie;qmi,gobinet,mbim
|
|
68
luci-app-modem/root/usr/share/modem/modem_support.json
Normal file
68
luci-app-modem/root/usr/share/modem/modem_support.json
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"modem_support":{
|
||||||
|
"usb":{
|
||||||
|
"rg200u-cn":{
|
||||||
|
"manufacturer":"quectel",
|
||||||
|
"platform":"unisoc",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"rm500u-cn":{
|
||||||
|
"manufacturer":"quectel",
|
||||||
|
"platform":"unisoc",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"rm500q-gl":{
|
||||||
|
"manufacturer":"quectel",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["qmi","gobinet","ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"rm502q-gl":{
|
||||||
|
"manufacturer":"quectel",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["qmi","gobinet","ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"fm650-cn":{
|
||||||
|
"manufacturer":"fibocom",
|
||||||
|
"platform":"unisoc",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"fm150-ae":{
|
||||||
|
"manufacturer":"fibocom",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["qmi","gobinet","ecm","mbim","rndis","ncm"]
|
||||||
|
},
|
||||||
|
"fm160-cn":{
|
||||||
|
"manufacturer":"fibocom",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"usb",
|
||||||
|
"modes":["qmi","gobinet","ecm","mbim","rndis","ncm"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pcie":{
|
||||||
|
"rm500q-gl":{
|
||||||
|
"manufacturer":"quectel",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"pcie",
|
||||||
|
"modes":["qmi","gobinet","mbim"]
|
||||||
|
},
|
||||||
|
"rm502q-gl":{
|
||||||
|
"manufacturer":"fibocom",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"pcie",
|
||||||
|
"modes":["qmi","gobinet","mbim"]
|
||||||
|
},
|
||||||
|
"fm150-ae":{
|
||||||
|
"manufacturer":"fibocom",
|
||||||
|
"platform":"qualcomm",
|
||||||
|
"network_interface":"pcie",
|
||||||
|
"modes":["qmi"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user