修复bug
This commit is contained in:
parent
e46fdce5ac
commit
29d41d1dd0
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
### 拨号
|
### 拨号
|
||||||
|
|
||||||
- luci-app-modem(暂未完成)
|
- luci-app-modem(beta)
|
||||||
|
|
||||||
- luci-app-hypermodem(新)
|
- luci-app-hypermodem(新)
|
||||||
- luci-app-usbmodem
|
- luci-app-usbmodem
|
||||||
|
49
luci-app-modem/.gitignore
vendored
Normal file
49
luci-app-modem/.gitignore
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
@ -1,24 +1,152 @@
|
|||||||
-- Copyright 2020 Lienol <lawlienol@gmail.com>
|
-- Copyright 2020 Lienol <lawlienol@gmail.com>
|
||||||
module("luci.controller.modem", package.seeall)
|
module("luci.controller.modem", package.seeall)
|
||||||
|
local http = require "luci.http"
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
local json = require("luci.jsonc")
|
||||||
|
uci = luci.model.uci.cursor()
|
||||||
|
local script_path="/usr/share/modem/"
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
if not nixio.fs.access("/etc/config/modem") then
|
if not nixio.fs.access("/etc/config/modem") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
entry({"admin", "network", "modem"}, alias("admin", "network", "modem", "index"), translate("Modem"), 100).dependent = true
|
|
||||||
entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Modem Config"),10).leaf = true
|
entry({"admin", "network", "modem"}, alias("admin", "network", "modem", "modem_info"), translate("Modem"), 100).dependent = true
|
||||||
entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),20).leaf = true
|
|
||||||
entry({"admin", "network", "modem", "config"}, cbi("modem/config")).leaf = true
|
|
||||||
entry({"admin", "network", "modem", "modem_info"}, template("modem/modem_info"), translate("Modem Info"),30).leaf = true
|
|
||||||
|
|
||||||
--模块状态
|
--模块状态
|
||||||
entry({"admin", "network", "modem", "get_csq"}, call("action_get_csq"))
|
entry({"admin", "network", "modem", "modem_info"}, template("modem/modem_info"), translate("Modem Info"),10).leaf = true
|
||||||
|
entry({"admin", "network", "modem", "get_modem_info"}, call("getModemInfo"))
|
||||||
|
|
||||||
|
--模块设置
|
||||||
|
entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Modem Config"),20).leaf = true
|
||||||
|
entry({"admin", "network", "modem", "config"}, cbi("modem/config")).leaf = true
|
||||||
|
entry({"admin", "network", "modem", "get_modems"}, call("getModems"), nil).leaf = true
|
||||||
|
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
|
||||||
|
|
||||||
--AT命令
|
--AT命令
|
||||||
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
|
-- local modem_number=uci:get('modem','@global[0]','modem_number')
|
||||||
entry({"admin", "network", "modem", "run_at"}, call("at"), nil).leaf = true
|
-- if modem_number ~= "0" or modem_number == nil then
|
||||||
entry({"admin", "network", "modem", "user_atc"}, call("useratc"), nil).leaf = true
|
entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),30).leaf = true
|
||||||
entry({"admin", "network", "modem", "at_port_select"}, call("modemSelect"), nil).leaf = true
|
-- end
|
||||||
|
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
|
||||||
|
|
||||||
|
-- AT命令
|
||||||
|
function at(at_port,at_command)
|
||||||
|
-- local odpall = io.popen("sh modem_at.sh "..at_port.." '"..at_command.."'")
|
||||||
|
local odpall = io.popen("sms_tool -d " .. at_port .. " at " ..at_command:gsub("[$]", "\\\$"):gsub("\"", "\\\"").." 2>&1")
|
||||||
|
local odp = odpall:read("*a")
|
||||||
|
odpall:close()
|
||||||
|
return odp
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取模组连接状态
|
||||||
|
function getModemConnectStatus(at_port)
|
||||||
|
local at_command="AT+CGDCONT?"
|
||||||
|
local response=at(at_port,at_command)
|
||||||
|
|
||||||
|
-- 第六个引号的索引
|
||||||
|
local sixth_index=1
|
||||||
|
for i = 1, 5 do
|
||||||
|
sixth_index=string.find(response,'"',sixth_index)+1
|
||||||
|
end
|
||||||
|
-- 第七个引号的索引
|
||||||
|
local seven_index=string.find(response,'"',sixth_index+1)
|
||||||
|
|
||||||
|
-- 获取IPv4和IPv6
|
||||||
|
local ip=string.sub(response,sixth_index,seven_index-1)
|
||||||
|
|
||||||
|
local not_ip="0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
|
||||||
|
if string.find(ip,not_ip) then
|
||||||
|
return "disconnect"
|
||||||
|
else
|
||||||
|
return "connect"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取模组基本信息
|
||||||
|
function getModemBaseInfo(at_port)
|
||||||
|
local modem_base_info={}
|
||||||
|
|
||||||
|
uci:foreach("modem", "modem-device", function (modem_device)
|
||||||
|
if at_port == modem_device["at_port"] then
|
||||||
|
--获取数据接口
|
||||||
|
local data_interface=modem_device["data_interface"]:upper()
|
||||||
|
--获取连接状态
|
||||||
|
local connect_status
|
||||||
|
if modem_device["at_port"] then
|
||||||
|
connect_status=getModemConnectStatus(modem_device["at_port"])
|
||||||
|
end
|
||||||
|
|
||||||
|
--设置值
|
||||||
|
modem_base_info=modem_device
|
||||||
|
modem_base_info["data_interface"]=data_interface
|
||||||
|
modem_base_info["connect_status"]=connect_status
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return modem_base_info
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取模组更多信息
|
||||||
|
function getModemMoreInfo(at_port,manufacturer)
|
||||||
|
local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer)
|
||||||
|
local opd = odpall:read("*a")
|
||||||
|
odpall:close()
|
||||||
|
local modem_more_info=json.parse(opd)
|
||||||
|
return modem_more_info
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 模块状态获取
|
||||||
|
function getModemInfo()
|
||||||
|
|
||||||
|
--获取AT串口
|
||||||
|
local at_port = http.formvalue("port")
|
||||||
|
|
||||||
|
--获取值
|
||||||
|
local modem_base_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"])
|
||||||
|
end
|
||||||
|
|
||||||
|
--设置值
|
||||||
|
local modem_info={}
|
||||||
|
modem_info["base_info"]=modem_base_info
|
||||||
|
modem_info["more_info"]=modem_more_info
|
||||||
|
|
||||||
|
-- 写入Web界面
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(modem_info)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取模组信息
|
||||||
|
function getModems()
|
||||||
|
|
||||||
|
local modems={}
|
||||||
|
|
||||||
|
-- 获取所有模组
|
||||||
|
uci:foreach("modem", "modem-device", function (modem_device)
|
||||||
|
--获取连接状态
|
||||||
|
local connect_status
|
||||||
|
if modem_device["at_port"] then
|
||||||
|
connect_status=getModemConnectStatus(modem_device["at_port"])
|
||||||
|
end
|
||||||
|
|
||||||
|
--设置值
|
||||||
|
local modem=modem_device
|
||||||
|
modem["connect_status"]=connect_status
|
||||||
|
modems[modem_device[".name"]]=modem
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- 写入Web界面
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(modems)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 模块列表状态函数
|
-- 模块列表状态函数
|
||||||
@ -30,185 +158,102 @@ function act_status()
|
|||||||
luci.http.write_json(e)
|
luci.http.write_json(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 模块状态获取
|
-- 模式信息
|
||||||
function action_get_csq()
|
function modeInfo()
|
||||||
local file
|
-- 设置默认值
|
||||||
stat = "/tmp/modem_cell.file"
|
local modes={"qmi","gobinet","ecm","mbim","rndis","ncm"}
|
||||||
file = io.open(stat, "r")
|
-- 获取移动网络
|
||||||
local rv ={}
|
local network = http.formvalue("network")
|
||||||
|
|
||||||
-- echo 'RM520N-GL'
|
local modem_number=uci:get('modem','global','modem_number')
|
||||||
-- echo 'manufacturer'
|
for i=0,modem_number-1 do
|
||||||
-- echo '1e0e:9001'
|
local modem_network = uci:get('modem','modem'..i,'network')
|
||||||
-- echo $COPS #运营商
|
if network == modem_network then
|
||||||
-- echo '' #端口
|
-- 清空表
|
||||||
-- echo '' #温度
|
modes={}
|
||||||
-- echo '' #拨号模式
|
-- 把找到的模块存入表中
|
||||||
rv["modem"] = file:read("*line")
|
local modes_arr = uci:get_list('modem','modem'..i,'modes')
|
||||||
rv["manufacturer"] = file:read("*line")
|
for i in ipairs(modes_arr) do
|
||||||
rv["modid"] = file:read("*line")
|
modes[i]=modes_arr[i]
|
||||||
rv["cops"] = file:read("*line")
|
|
||||||
rv["port"] = file:read("*line")
|
|
||||||
rv["tempur"] = file:read("*line")
|
|
||||||
rv["proto"] = file:read("*line")
|
|
||||||
rv["mode"] = file:read("*line")
|
|
||||||
|
|
||||||
|
|
||||||
-- echo $IMEI #imei
|
|
||||||
-- echo $IMSI #imsi
|
|
||||||
-- echo $ICCID #iccid
|
|
||||||
-- echo $phone #phone
|
|
||||||
rv["imei"] = file:read("*line")
|
|
||||||
rv["imsi"] = file:read("*line")
|
|
||||||
rv["iccid"] =file:read("*line")
|
|
||||||
rv["phone"] = file:read("*line")
|
|
||||||
file:read("*line")
|
|
||||||
|
|
||||||
|
|
||||||
-- echo $net_type
|
|
||||||
-- echo $CSQ
|
|
||||||
-- echo $CSQ_PER
|
|
||||||
-- echo $CSQ_RSSI
|
|
||||||
-- echo '' #参考信号接收质量 RSRQ ecio
|
|
||||||
-- echo '' #参考信号接收质量 RSRQ ecio1
|
|
||||||
-- echo '' #参考信号接收功率 RSRP rscp
|
|
||||||
-- echo '' #参考信号接收功率 RSRP rscp1
|
|
||||||
-- echo '' #信噪比 SINR rv["sinr"]
|
|
||||||
-- echo '' #连接状态监控 rv["netmode"]
|
|
||||||
rv["net_type"] = file:read("*line")
|
|
||||||
rv["csq"] = file:read("*line")
|
|
||||||
rv["per"] = file:read("*line")
|
|
||||||
rv["rssi"] = file:read("*line")
|
|
||||||
rv["ecio"] = file:read("*line")
|
|
||||||
rv["ecio1"] = file:read("*line")
|
|
||||||
rv["rscp"] = file:read("*line")
|
|
||||||
rv["rscp1"] = file:read("*line")
|
|
||||||
rv["sinr"] = file:read("*line")
|
|
||||||
rv["netmode"] = file:read("*line")
|
|
||||||
file:read("*line")
|
|
||||||
|
|
||||||
rssi = rv["rssi"]
|
|
||||||
ecio = rv["ecio"]
|
|
||||||
rscp = rv["rscp"]
|
|
||||||
ecio1 = rv["ecio1"]
|
|
||||||
rscp1 = rv["rscp1"]
|
|
||||||
if ecio == nil then
|
|
||||||
ecio = "-"
|
|
||||||
end
|
end
|
||||||
if ecio1 == nil then
|
|
||||||
ecio1 = "-"
|
|
||||||
end
|
end
|
||||||
if rscp == nil then
|
|
||||||
rscp = "-"
|
|
||||||
end
|
end
|
||||||
if rscp1 == nil then
|
-- 写入Web界面
|
||||||
rscp1 = "-"
|
|
||||||
end
|
|
||||||
|
|
||||||
if ecio ~= "-" then
|
|
||||||
rv["ecio"] = ecio .. " dB"
|
|
||||||
end
|
|
||||||
if rscp ~= "-" then
|
|
||||||
rv["rscp"] = rscp .. " dBm"
|
|
||||||
end
|
|
||||||
if ecio1 ~= " " then
|
|
||||||
rv["ecio1"] = " (" .. ecio1 .. " dB)"
|
|
||||||
end
|
|
||||||
if rscp1 ~= " " then
|
|
||||||
rv["rscp1"] = " (" .. rscp1 .. " dBm)"
|
|
||||||
end
|
|
||||||
|
|
||||||
rv["mcc"] = file:read("*line")
|
|
||||||
rv["mnc"] = file:read("*line")
|
|
||||||
rv["rnc"] = file:read("*line")
|
|
||||||
rv["rncn"] = file:read("*line")
|
|
||||||
rv["lac"] = file:read("*line")
|
|
||||||
rv["lacn"] = file:read("*line")
|
|
||||||
rv["cid"] = file:read("*line")
|
|
||||||
rv["cidn"] = file:read("*line")
|
|
||||||
rv["lband"] = file:read("*line")
|
|
||||||
rv["channel"] = file:read("*line")
|
|
||||||
rv["pci"] = file:read("*line")
|
|
||||||
|
|
||||||
rv["date"] = file:read("*line")
|
|
||||||
|
|
||||||
-- rv["phonen"] = file:read("*line")
|
|
||||||
--rv["host"] = "0"
|
|
||||||
|
|
||||||
-- rv["simerr"] = "0"
|
|
||||||
|
|
||||||
-- rv["down"] = file:read("*line")
|
|
||||||
-- rv["up"] = file:read("*line")
|
|
||||||
|
|
||||||
-- rv["cell"] = file:read("*line")
|
|
||||||
-- rv["modtype"] = file:read("*line")
|
|
||||||
|
|
||||||
-- rv["lat"] = "-"
|
|
||||||
-- rv["long"] = "-"
|
|
||||||
|
|
||||||
rv["crate"] = translate("快速(每10秒更新一次)")
|
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(rv)
|
luci.http.write_json(modes)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- at页面命令函数
|
-- 发送AT命令
|
||||||
function at()
|
function sendATCommand()
|
||||||
local devv = tostring(uci:get("modem", "general", "atport"))
|
local at_port = http.formvalue("port")
|
||||||
|
local at_command = http.formvalue("command")
|
||||||
|
|
||||||
local at_code = http.formvalue("code")
|
local response
|
||||||
if at_code then
|
if at_port and at_command then
|
||||||
local odpall = io.popen("sms_tool -d " .. devv .. " at " ..at_code:gsub("[$]", "\\\$"):gsub("\"", "\\\"").." 2>&1")
|
response=at(at_port,at_command)
|
||||||
local odp = odpall:read("*a")
|
http.write(tostring(response))
|
||||||
odpall:close()
|
|
||||||
http.write(tostring(odp))
|
|
||||||
else
|
else
|
||||||
http.write_json(http.formvalue())
|
http.write_json(http.formvalue())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- AT界面模块选择
|
-- 用户AT命令
|
||||||
function modemSelect()
|
function userATCommand()
|
||||||
|
local at_commands={}
|
||||||
local at_ports={}
|
-- 获取模块AT命令
|
||||||
local at={}
|
local command_file
|
||||||
local modem_number=uci:get('modem','global','modem_number')
|
if nixio.fs.access("/etc/config/modem_command.user") then
|
||||||
for i=0,modem_number do
|
command_file=io.popen("cat /etc/config/modem_command.user")
|
||||||
local at_port = uci:get('modem','modem'..i,'at_port')
|
|
||||||
at_ports[#at_ports+1]=at_port
|
|
||||||
-- table.insert(at_ports,at_port)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 遍历查找AT串口
|
|
||||||
-- uci:foreach("modem", "modem-device", function (modem_device)
|
|
||||||
-- at_port = modem_device["at_port"]
|
|
||||||
-- at_ports[#at_ports+1]=at_port
|
|
||||||
-- end)
|
|
||||||
luci.http.prepare_content("application/json")
|
|
||||||
luci.http.write_json(at_ports)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 用户AT命令读取
|
|
||||||
function uat(rv)
|
|
||||||
local command_file = nixio.fs.access("/etc/config/atcmds.user") and
|
|
||||||
io.popen("cat /etc/config/atcmds.user")
|
|
||||||
|
|
||||||
if command_file then
|
if command_file then
|
||||||
|
local i=0
|
||||||
for line in command_file:lines() do
|
for line in command_file:lines() do
|
||||||
local i = line
|
if line then
|
||||||
if i then
|
-- 分割为{key,value}
|
||||||
rv[#rv + 1] = {
|
local command_table=string.split(line, ";")
|
||||||
atu = i
|
-- 整合为{0:{key:value},1:{key:value}}
|
||||||
}
|
local at_command={}
|
||||||
|
at_command[command_table[1]]=command_table[2]
|
||||||
|
at_commands[tostring(i)]=at_command
|
||||||
|
i=i+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
command_file:close()
|
command_file:close()
|
||||||
end
|
end
|
||||||
|
-- 写入Web界面
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(at_commands)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 用户AT命令写入函数
|
-- 获取模组的备注
|
||||||
function useratc()
|
-- @Param network 移动网络
|
||||||
local atu = { }
|
function getModemRemarks(network)
|
||||||
uat(atu)
|
local remarks=""
|
||||||
luci.http.prepare_content("application/json")
|
uci:foreach("modem", "config", function (config)
|
||||||
luci.http.write_json(atu)
|
---配置启用,且备注存在
|
||||||
|
if network == config["network"] and config["enable"] == "1" then
|
||||||
|
if config["remarks"] then
|
||||||
|
remarks=" ("..config["remarks"]..")" --" (备注)"
|
||||||
|
return true --跳出循环
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return remarks
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取AT串口
|
||||||
|
function getATPort()
|
||||||
|
local at_ports={}
|
||||||
|
uci:foreach("modem", "modem-device", function (modem_device)
|
||||||
|
--获取模块的备注
|
||||||
|
local network=modem_device["network"]
|
||||||
|
local remarks=getModemRemarks(network)
|
||||||
|
|
||||||
|
local name=modem_device["name"]:upper()..remarks
|
||||||
|
local at_port = modem_device["at_port"]
|
||||||
|
at_ports[at_port]=name
|
||||||
|
end)
|
||||||
|
-- 写入Web界面
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(at_ports)
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
local d = require "luci.dispatcher"
|
local d = require "luci.dispatcher"
|
||||||
local uci = require "luci.model.uci".cursor()
|
local uci = require "luci.model.uci".cursor()
|
||||||
|
local http = require "luci.http"
|
||||||
|
|
||||||
m = Map("modem", translate("Modem Config"))
|
m = Map("modem", translate("Modem Config"))
|
||||||
m.redirect = d.build_url("admin", "network", "modem")
|
m.redirect = d.build_url("admin", "network", "modem","index")
|
||||||
|
|
||||||
s = m:section(NamedSection, arg[1], "config", "")
|
s = m:section(NamedSection, arg[1], "config", "")
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
@ -17,59 +18,53 @@ enable = s:taboption("general", Flag, "enable", translate("Enable"))
|
|||||||
enable.default = "0"
|
enable.default = "0"
|
||||||
enable.rmempty = false
|
enable.rmempty = false
|
||||||
|
|
||||||
|
-- 配置ID
|
||||||
|
uci:set('modem',arg[1],'id',arg[1])
|
||||||
|
|
||||||
-- 备注
|
-- 备注
|
||||||
remarks = s:taboption("general", Value, "remarks", translate("Remarks"))
|
remarks = s:taboption("general", Value, "remarks", translate("Remarks"))
|
||||||
remarks.rmempty = true
|
remarks.rmempty = true
|
||||||
|
|
||||||
-- 移动网络
|
-- 移动网络
|
||||||
-- moblie_net = s:taboption("general", Value, "moblie_net", translate("Moblie Network"))
|
-- network = s:taboption("general", Value, "network", translate("Moblie Network"))
|
||||||
moblie_net = s:taboption("general", ListValue, "moblie_net", translate("Moblie Network"))
|
network = s:taboption("general", ListValue, "network", translate("Moblie Network"))
|
||||||
-- moblie_net.default = ""
|
-- network.default = ""
|
||||||
moblie_net.rmempty = false
|
network.rmempty = false
|
||||||
|
|
||||||
|
-- 获取移动网络,并显示设备名
|
||||||
|
function getMoblieNetwork()
|
||||||
|
local modem_number=uci:get('modem','global','modem_number')
|
||||||
|
if modem_number == "0" then
|
||||||
|
network:value("",translate("Mobile network not found"))
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=0,modem_number-1 do
|
||||||
|
--获取模块名
|
||||||
|
local modem_name = uci:get('modem','modem'..i,'name')
|
||||||
|
if modem_name == nil then
|
||||||
|
modem_name = "unknown"
|
||||||
|
end
|
||||||
|
--设置网络
|
||||||
|
modem_network = uci:get('modem','modem'..i,'network')
|
||||||
|
if modem_network ~= nil then
|
||||||
|
network:value(modem_network,modem_network.." ("..translate(modem_name:upper())..")")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
getMoblieNetwork()
|
||||||
|
|
||||||
-- 拨号模式
|
-- 拨号模式
|
||||||
-- mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
-- mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
||||||
-- mode.rmempty = false
|
-- mode.rmempty = false
|
||||||
|
-- mode.description = translate("Only display the modes available for the adaptation modem")
|
||||||
-- 根据调制解调器节点获取模块名
|
-- local modes = {"qmi","gobinet","ecm","mbim","rndis","ncm"}
|
||||||
-- function getDeviceName(device_node)
|
-- for i in ipairs(modes) do
|
||||||
-- local deviceName
|
-- mode:value(modes[i],string.upper(modes[i]))
|
||||||
-- uci:foreach("modem", "modem-device", function (modem_device)
|
|
||||||
-- if device_node == modem_device["device_node"] then
|
|
||||||
-- deviceName = modem_device["name"]
|
|
||||||
-- end
|
|
||||||
-- end)
|
|
||||||
-- return string.upper(deviceName)
|
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- 显示设备通用信息(网络,拨号模式)(有bug)
|
-- 添加获取拨号模式信息
|
||||||
function devicesGeneralInfo()
|
-- m:append(Template("modem/mode_info"))
|
||||||
local modem_number=uci:get('modem','global','modem_number')
|
|
||||||
for i=0,modem_number do
|
|
||||||
--获取模块名
|
|
||||||
local deviceName = uci:get('modem','modem'..i,'name')
|
|
||||||
if deviceName == nil then
|
|
||||||
deviceName = "unknown"
|
|
||||||
end
|
|
||||||
--设置网络
|
|
||||||
local net = uci:get('modem','modem'..i,'net')
|
|
||||||
if net ~= nil then
|
|
||||||
moblie_net:value(net,net.." ("..translate(deviceName:upper())..")")
|
|
||||||
|
|
||||||
--设置拨号模式
|
|
||||||
local mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
|
||||||
mode.rmempty = false
|
|
||||||
|
|
||||||
local modes = uci:get_list('modem','modem'..tostring(i),'modes')
|
|
||||||
for i in ipairs(modes) do
|
|
||||||
mode:value(modes[i],string.upper(modes[i]))
|
|
||||||
end
|
|
||||||
mode:depends("moblie_net", net)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
devicesGeneralInfo()
|
|
||||||
|
|
||||||
--------advanced--------
|
--------advanced--------
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
local d = require "luci.dispatcher"
|
local d = require "luci.dispatcher"
|
||||||
local e = luci.model.uci.cursor()
|
local uci = luci.model.uci.cursor()
|
||||||
|
|
||||||
m = Map("modem")
|
m = Map("modem")
|
||||||
m.title = translate("Modem Config")
|
m.title = translate("Modem Config")
|
||||||
m.description = translate("Configuration panel for Modem, Add and configure all modules 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")
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
@ -11,23 +11,27 @@ s.addremove = false
|
|||||||
|
|
||||||
o = s:option(Flag, "enable", translate("Enable"))
|
o = s:option(Flag, "enable", translate("Enable"))
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
o.description = translate("Check to enable all configurations")
|
||||||
|
|
||||||
s = m:section(TypedSection, "config", translate("Modem List"))
|
-- 添加模块状态
|
||||||
|
m:append(Template("modem/modem_status"))
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "config", translate("Config List"))
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
s.addremove = true
|
s.addremove = true
|
||||||
s.template = "cbi/tblsection"
|
s.template = "cbi/tblsection"
|
||||||
s.extedit = d.build_url("admin", "network", "modem", "config", "%s")
|
s.extedit = d.build_url("admin", "network", "modem", "config", "%s")
|
||||||
|
|
||||||
function s.create(e, t)
|
function s.create(uci, t)
|
||||||
local uuid = string.gsub(luci.sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)"), "-", "")
|
local uuid = string.gsub(luci.sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)"), "-", "")
|
||||||
t = uuid
|
t = uuid
|
||||||
TypedSection.create(e, t)
|
TypedSection.create(uci, t)
|
||||||
luci.http.redirect(e.extedit:format(t))
|
luci.http.redirect(uci.extedit:format(t))
|
||||||
end
|
end
|
||||||
function s.remove(e, t)
|
function s.remove(uci, t)
|
||||||
e.map.proceed = true
|
uci.map.proceed = true
|
||||||
e.map:del(t)
|
uci.map:del(t)
|
||||||
luci.http.redirect(d.build_url("admin", "network", "modem"))
|
luci.http.redirect(d.build_url("admin", "network", "modem","index"))
|
||||||
end
|
end
|
||||||
|
|
||||||
o = s:option(Flag, "enable", translate("Enable"))
|
o = s:option(Flag, "enable", translate("Enable"))
|
||||||
@ -40,24 +44,27 @@ o.rmempty = false
|
|||||||
|
|
||||||
o = s:option(DummyValue, "remarks", translate("Remarks"))
|
o = s:option(DummyValue, "remarks", translate("Remarks"))
|
||||||
|
|
||||||
o = s:option(DummyValue, "moblie_net", translate("Moblie Network"))
|
o = s:option(DummyValue, "network", translate("Moblie Network"))
|
||||||
o.cfgvalue = function(t, n)
|
o.cfgvalue = function(t, n)
|
||||||
-- 检测移动网络设备是否存在
|
-- 检测移动网络是否存在
|
||||||
local moblie_net = (Value.cfgvalue(t, n) or "")
|
local network = (Value.cfgvalue(t, n) or "")
|
||||||
local odpall = io.popen("ls /sys/class/net/ | grep -w "..moblie_net.." | wc -l")
|
local odpall = io.popen("ls /sys/class/net/ | grep -w "..network.." | wc -l")
|
||||||
local odp = odpall:read("*a"):gsub("\n","")
|
local odp = odpall:read("*a"):gsub("\n","")
|
||||||
odpall:close()
|
odpall:close()
|
||||||
if odp ~= "0" then
|
if odp ~= "0" then
|
||||||
return moblie_net
|
return network
|
||||||
else
|
else
|
||||||
return "The network device was not found"
|
return "The network device was not found"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
o = s:option(DummyValue, "mode", translate("Mode"))
|
o = s:option(DummyValue, "dial_tool", translate("Dial Tool"))
|
||||||
o.cfgvalue = function(t, n)
|
o.cfgvalue = function(t, n)
|
||||||
local mode = (Value.cfgvalue(t, n) or ""):upper()
|
local dial_tool = (Value.cfgvalue(t, n) or ""):upper()
|
||||||
return mode
|
if dial_tool == "" then
|
||||||
|
dial_tool=translate("Auto Choose")
|
||||||
|
end
|
||||||
|
return dial_tool
|
||||||
end
|
end
|
||||||
|
|
||||||
o = s:option(DummyValue, "pdp_type", translate("PDP Type"))
|
o = s:option(DummyValue, "pdp_type", translate("PDP Type"))
|
||||||
@ -66,6 +73,15 @@ o.cfgvalue = function(t, n)
|
|||||||
return pdp_type
|
return pdp_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
o = s:option(DummyValue, "apn", translate("APN"))
|
||||||
|
o.cfgvalue = function(t, n)
|
||||||
|
local apn = (Value.cfgvalue(t, n) or ""):gsub("_","/"):upper():gsub("V","v")
|
||||||
|
if apn == "" then
|
||||||
|
apn=translate("Auto Choose")
|
||||||
|
end
|
||||||
|
return apn
|
||||||
|
end
|
||||||
|
|
||||||
-- m:append(Template("modem/list_status"))
|
-- m:append(Template("modem/list_status"))
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -1,38 +1,69 @@
|
|||||||
<%+header%>
|
<%+header%>
|
||||||
|
|
||||||
<!--
|
<%
|
||||||
-- Copyright 2020-2021 Rafał Wabik (IceG) - From eko.one.pl forum
|
local uci = luci.model.uci.cursor()
|
||||||
-- Licensed to the GNU General Public License v3.0.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
-- 获取模组的备注
|
||||||
|
-- @Param network 移动网络
|
||||||
|
function getModemRemarks(network)
|
||||||
|
local remarks=""
|
||||||
|
uci:foreach("modem", "config", function (config)
|
||||||
|
---配置启用,且备注存在
|
||||||
|
if network == config["network"] and config["enable"] == "1" then
|
||||||
|
if config["remarks"] then
|
||||||
|
remarks=" ("..config["remarks"]..")" --" (备注)"
|
||||||
|
return true --跳出循环
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return remarks
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取AT串口
|
||||||
|
function getATPort()
|
||||||
|
local at_ports={}
|
||||||
|
uci:foreach("modem", "modem-device", function (modem_device)
|
||||||
|
--获取模块的备注
|
||||||
|
local network=modem_device["network"]
|
||||||
|
local remarks=getModemRemarks(network)
|
||||||
|
|
||||||
|
local name=modem_device["name"]:upper()..remarks
|
||||||
|
local at_port = modem_device["at_port"]
|
||||||
|
at_ports[at_port]=name
|
||||||
|
end)
|
||||||
|
return at_ports
|
||||||
|
end
|
||||||
|
%>
|
||||||
<h2 name="content"><%:AT Commands%></h2>
|
<h2 name="content"><%:AT Commands%></h2>
|
||||||
<div class="cbi-map-descr"><%:Web UI for handling AT commands via sms_tool.%></div>
|
<div class="cbi-map-descr"><%:Debugging Your Module with AT Command%></div>
|
||||||
<p></p>
|
<p></p>
|
||||||
<h4><br/></h4>
|
<h4><br/></h4>
|
||||||
<div class="table" width="100%">
|
<div class="table" width="100%">
|
||||||
|
|
||||||
<div class="tr">
|
<div class="tr">
|
||||||
<div class="td left" width="25%"><%:Modem Select%>:</div>
|
<div class="td left" width="25%"><%:Modem Select%>:</div>
|
||||||
|
|
||||||
<div class="td left" style="width:50%;">
|
<div class="td left" style="width:50%;">
|
||||||
<select name="at_port" id="at_port" onclick="copyFunction()"></select>
|
<select name="modem_select" id="modem_select" onclick="afunction()">
|
||||||
|
<% at_ports=getATPort() %>
|
||||||
|
<% for key in pairs(at_ports) do %>
|
||||||
|
<option value="<%= key %>"><%= at_ports[key] %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="td left" style="width:50%;"></div>
|
<div class="td left" style="width:50%;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tr">
|
<div class="tr">
|
||||||
<div class="td left" width="25%"><%:User AT Commands%>:</div>
|
<div class="td left" width="25%"><%:User AT Commands%>:</div>
|
||||||
|
|
||||||
<div class="td left" style="width:50%;">
|
<div class="td left" style="width:50%;">
|
||||||
<select name="ussd" id="pl" onclick="copyFunction()"></select>
|
<select name="command_choose" id="command_choose" onclick="copyToSend()"></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="td left" style="width:50%;"></div>
|
<div class="td left" style="width:50%;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tr">
|
<div class="tr">
|
||||||
<div class="td left" style="width:25%;"><%:Command to send%>:</div>
|
<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 class="td left" ><input type="text" id="code" required size="20" ></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -50,71 +81,83 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
// 读取AT串口
|
window.onload = function readData()
|
||||||
window.onload = function readATPort()
|
|
||||||
{
|
{
|
||||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "at_port_select")%>', null,
|
// 选择AT命令
|
||||||
|
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "user_at_command")%>', null,
|
||||||
function(x, json)
|
function(x, json)
|
||||||
{
|
{
|
||||||
select = document.getElementById('at_port');
|
select = document.getElementById('command_choose');
|
||||||
var count = Object.keys(json).length;
|
// 遍历序号
|
||||||
for(var d=0;d<=count;d++)
|
for (var command in json) {
|
||||||
{
|
// 遍历AT命令
|
||||||
var opt = document.createElement('option');
|
for (var key in json[command]) {
|
||||||
console.log("hello")
|
var option = document.createElement('option');
|
||||||
console.log(json)
|
option.text = key;
|
||||||
var s = json[d].at_ports;
|
option.value = json[command][key].trim();
|
||||||
// var fields = s.split(/;/);
|
option.innerHTML = key;
|
||||||
// var name = fields[0];
|
select.appendChild(option);
|
||||||
// var port = fields[1];
|
}
|
||||||
var name = s;
|
|
||||||
var port = s;
|
|
||||||
opt.text = name;
|
|
||||||
opt.value = port.trim();
|
|
||||||
opt.innerHTML = name;
|
|
||||||
select.appendChild(opt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 定时触发更新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;
|
||||||
|
// 更新(key:AT串口,value:模块名称)
|
||||||
|
for (var key in port)
|
||||||
|
{
|
||||||
|
var option = document.createElement('option');
|
||||||
|
option.text = port[key].trim();
|
||||||
|
option.value = key;
|
||||||
|
modem_select.appendChild(option);
|
||||||
}
|
}
|
||||||
|
// 恢复原来的选择
|
||||||
window.onload = function readUSER()
|
for (let i = 0; i < modem_select.options.length; i++)
|
||||||
{
|
{
|
||||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "user_atc")%>', null,
|
if(modem_select.options[i].value == selected)
|
||||||
function(x, json)
|
|
||||||
{
|
{
|
||||||
select = document.getElementById('pl');
|
modem_select.selectedIndex=i;
|
||||||
var count = Object.keys(json).length;
|
break;
|
||||||
for(var d=0;d<=count;d++)
|
}
|
||||||
{
|
|
||||||
var opt = document.createElement('option');
|
|
||||||
|
|
||||||
var s = json[d].atu;
|
|
||||||
var fields = s.split(/;/);
|
|
||||||
var name = fields[0];
|
|
||||||
var code = fields[1];
|
|
||||||
opt.text = name;
|
|
||||||
opt.value = code.trim();
|
|
||||||
opt.innerHTML = name;
|
|
||||||
select.appendChild(opt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据所选的模组改变AT命令
|
||||||
|
function afunction()
|
||||||
|
{
|
||||||
|
// var node = document.getElementById('odp');
|
||||||
|
// node.style.visibility = 'hidden';
|
||||||
|
|
||||||
|
// var x = document.getElementById("at_command").value;
|
||||||
|
// document.getElementById("code").value = x;
|
||||||
|
// document.getElementById("odp").innerHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyFunction() {
|
//自动填写到命令输入框
|
||||||
|
function copyToSend()
|
||||||
|
{
|
||||||
var node = document.getElementById('odp');
|
var node = document.getElementById('odp');
|
||||||
node.style.visibility = 'hidden';
|
node.style.visibility = 'hidden';
|
||||||
|
|
||||||
var x = document.getElementById("pl").value;
|
var command_choose = document.getElementById("command_choose").value;
|
||||||
document.getElementById("code").value = x;
|
document.getElementById("at_command").value = command_choose;
|
||||||
document.getElementById("odp").innerHTML = "";
|
document.getElementById("odp").innerHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function postcmd(cmd) {
|
function postCommand(at_port,at_command) {
|
||||||
(new XHR()).post("<%=luci.dispatcher.build_url("admin", "network", "modem", "run_at")%>", {"code":cmd}, function(x) {
|
(new XHR()).post('<%=luci.dispatcher.build_url("admin", "network", "modem", "send_at_command")%>', {"port":at_port,"command":at_command}, function(x) {
|
||||||
console.log(x.response)
|
console.log(x.response)
|
||||||
console.log(x)
|
console.log(x)
|
||||||
|
|
||||||
@ -132,18 +175,27 @@ function postcmd(cmd) {
|
|||||||
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 () {
|
||||||
|
|
||||||
|
//获取AT串口
|
||||||
|
var at_port = document.getElementById("modem_select").value;
|
||||||
|
if ( at_port.length == 0 )
|
||||||
|
{
|
||||||
|
document.getElementById("odp").innerHTML = "";
|
||||||
|
alert("<%:Please choose a Modem%>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var s = document.getElementById("code").value;
|
//获取AT命令
|
||||||
if ( s.length == 0 )
|
var at_command = document.getElementById("at_command").value;
|
||||||
|
if ( at_command.length == 0 )
|
||||||
{
|
{
|
||||||
document.getElementById("odp").innerHTML = "";
|
document.getElementById("odp").innerHTML = "";
|
||||||
alert("<%:Please enter a AT Command%>");
|
alert("<%:Please enter a AT Command%>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmd = document.getElementById("code");
|
//发送AT命令
|
||||||
postcmd(cmd.value);
|
postCommand(at_port,at_command);
|
||||||
cmd.value = "";
|
at_command = "";
|
||||||
|
|
||||||
var node = document.getElementById('odp');
|
var node = document.getElementById('odp');
|
||||||
if (node.style.visibility=='visible') {
|
if (node.style.visibility=='visible') {
|
||||||
|
51
luci-app-modem/luasrc/view/modem/mode_info.htm
Normal file
51
luci-app-modem/luasrc/view/modem/mode_info.htm
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
window.onload=function()
|
||||||
|
{
|
||||||
|
var url=window.location.pathname
|
||||||
|
var lastSlashIndex = url.lastIndexOf("/");
|
||||||
|
var uuid = url.substring(lastSlashIndex + 1);
|
||||||
|
|
||||||
|
// 查询network元素
|
||||||
|
var network = document.getElementById("widget.cbid.modem."+uuid+".network");
|
||||||
|
if (network===null)
|
||||||
|
{
|
||||||
|
// 查询所有以.network结尾的元素
|
||||||
|
var elements = document.querySelectorAll('[id$=".network"]');
|
||||||
|
network=elements[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//页面加载完成时触发
|
||||||
|
getMode(network,uuid);
|
||||||
|
|
||||||
|
// 更换移动网络时触发
|
||||||
|
network.addEventListener('change', function() {
|
||||||
|
// 获取对应的拨号模式,并设置到页面选项中
|
||||||
|
getMode(network,uuid);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取对应的拨号模式,并设置到页面选项中
|
||||||
|
function getMode(network,uuid)
|
||||||
|
{
|
||||||
|
// 获取当前选中的值
|
||||||
|
var selected=network.options[network.selectedIndex].value;
|
||||||
|
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "mode_info")%>', {"network":selected},
|
||||||
|
function(x, json)
|
||||||
|
{
|
||||||
|
modeSelect = document.getElementById("widget.cbid.modem."+uuid+".mode");
|
||||||
|
if (modeSelect===null)
|
||||||
|
{
|
||||||
|
// 查询所有以.network结尾的元素
|
||||||
|
var elements = document.querySelectorAll('[id$=".mode"]');
|
||||||
|
modeSelect=elements[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除原来的选项
|
||||||
|
modeSelect.options.length=0;
|
||||||
|
for (var key in json) {
|
||||||
|
modeSelect.add(new Option(json[key].toUpperCase(),json[key]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,6 +1,8 @@
|
|||||||
<%+header%>
|
<%+header%>
|
||||||
<%
|
<%
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
local uci = luci.model.uci.cursor()
|
||||||
|
|
||||||
nosms = 1
|
nosms = 1
|
||||||
if not fs.stat("/etc/nosim") then
|
if not fs.stat("/etc/nosim") then
|
||||||
nosms = 0
|
nosms = 0
|
||||||
@ -9,148 +11,270 @@ havegps = 0
|
|||||||
if fs.stat("/etc/havegps") then
|
if fs.stat("/etc/havegps") then
|
||||||
havegps = 1
|
havegps = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 获取模组的备注
|
||||||
|
-- @Param network 移动网络
|
||||||
|
function getModemRemarks(network)
|
||||||
|
local remarks=""
|
||||||
|
uci:foreach("modem", "config", function (config)
|
||||||
|
---配置启用,且备注存在
|
||||||
|
if network == config["network"] and config["enable"] == "1" then
|
||||||
|
if config["remarks"] then
|
||||||
|
remarks=" ("..config["remarks"]..")" --" (备注)"
|
||||||
|
return true --跳出循环
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return remarks
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取AT串口
|
||||||
|
function getATPort()
|
||||||
|
local at_ports={}
|
||||||
|
uci:foreach("modem", "modem-device", function (modem_device)
|
||||||
|
--获取模块的备注
|
||||||
|
local network=modem_device["network"]
|
||||||
|
local remarks=getModemRemarks(network)
|
||||||
|
|
||||||
|
local name=modem_device["name"]:upper()..remarks
|
||||||
|
local at_port = modem_device["at_port"]
|
||||||
|
at_ports[at_port]=name
|
||||||
|
end)
|
||||||
|
return at_ports
|
||||||
|
end
|
||||||
%>
|
%>
|
||||||
<style>g {color:grey; font-size:75%; vertical-align: super;}</style>
|
<style>g {color:grey; font-size:75%; vertical-align: super;}</style>
|
||||||
<script type="text/javascript" src="<%=resource%>/xhr.js?v=git-23.159.15540-7154b89"></script>
|
<script type="text/javascript" src="<%=resource%>/xhr.js?v=git-23.159.15540-7154b89"></script>
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
|
||||||
|
window.onload=function()
|
||||||
|
{
|
||||||
|
//获取模块选择框元素
|
||||||
|
var modem_select = document.getElementById('modem_select');
|
||||||
|
|
||||||
|
// 更换模组(AT串口)时触发
|
||||||
|
modem_select.addEventListener('change', function() {
|
||||||
|
// 更新数据
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
|
||||||
|
//更新模组数据
|
||||||
|
// XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_info")%>', {"port":at_port},
|
||||||
|
// function(x, modem_info)
|
||||||
|
// {
|
||||||
|
// console.log(modem_info);
|
||||||
|
|
||||||
|
// // 基本信息
|
||||||
|
// // document.getElementById('modem').innerHTML=modem_info.modem;
|
||||||
|
// document.getElementById('manufacturer').innerHTML=modem_info.manufacturer;
|
||||||
|
// document.getElementById('at_port').innerHTML=modem_info.at_port;
|
||||||
|
// document.getElementById('mode').innerHTML=modem_info.mode;
|
||||||
|
// document.getElementById('temperature').innerHTML=modem_info.temperature;
|
||||||
|
// document.getElementById('date').innerHTML=modem_info.date;
|
||||||
|
|
||||||
|
// //SIM卡信息
|
||||||
|
// document.getElementById('csq').innerHTML=modem_info.csq;
|
||||||
|
// document.getElementById('per').innerHTML=modem_info.per;
|
||||||
|
// document.getElementById('rssi').innerHTML=modem_info.rssi;
|
||||||
|
// document.getElementById('cops').innerHTML=modem_info.cops;
|
||||||
|
// document.getElementById('net_type').innerHTML=modem_info.net_type;
|
||||||
|
// document.getElementById('lac').innerHTML=modem_info.lac;
|
||||||
|
// document.getElementById('cid').innerHTML=modem_info.cid;
|
||||||
|
// document.getElementById('lacn').innerHTML=modem_info.lacn;
|
||||||
|
// document.getElementById('cidn').innerHTML=modem_info.cidn;
|
||||||
|
// document.getElementById('mcc').innerHTML=modem_info.mcc;
|
||||||
|
// document.getElementById('mnc').innerHTML=modem_info.mnc;
|
||||||
|
// document.getElementById('rnc').innerHTML=modem_info.rnc;
|
||||||
|
// document.getElementById('rncn').innerHTML=modem_info.rncn;
|
||||||
|
// document.getElementById('down').innerHTML=modem_info.down;
|
||||||
|
// document.getElementById('up').innerHTML=modem_info.up;
|
||||||
|
// document.getElementById('ecio').innerHTML=modem_info.ecio;
|
||||||
|
// document.getElementById('rscp').innerHTML=modem_info.rscp;
|
||||||
|
// document.getElementById('ecio1').innerHTML=modem_info.ecio1;
|
||||||
|
// document.getElementById('rscp1').innerHTML=modem_info.rscp1;
|
||||||
|
// document.getElementById('chan').innerHTML=modem_info.channel;
|
||||||
|
// document.getElementById('lband').innerHTML=modem_info.lband;
|
||||||
|
// document.getElementById('conmon').innerHTML=modem_info.netmode;
|
||||||
|
// document.getElementById('tempur').innerHTML=modem_info.tempur;
|
||||||
|
|
||||||
|
// document.getElementById('pci').innerHTML=modem_info.pci;
|
||||||
|
// document.getElementById('sinr').innerHTML=modem_info.sinr;
|
||||||
|
|
||||||
|
// document.getElementById('imei').innerHTML=modem_info.imei;
|
||||||
|
// document.getElementById('imsi').innerHTML=modem_info.imsi;
|
||||||
|
// document.getElementById('iccid').innerHTML=modem_info.iccid;
|
||||||
|
// document.getElementById('phone').innerHTML=modem_info.phone;
|
||||||
|
|
||||||
|
|
||||||
|
// <% if havegps == 1 then %>
|
||||||
|
// document.getElementById('lat').innerHTML=modem_info.lat;
|
||||||
|
// document.getElementById('long').innerHTML=modem_info.long;
|
||||||
|
// <% end %>
|
||||||
|
// // document.getElementById('idvp').innerHTML=modem_info.modid;
|
||||||
|
// // document.getElementById('proto').innerHTML=modem_info.proto;
|
||||||
|
// // document.getElementById('port').innerHTML=modem_info.port;
|
||||||
|
|
||||||
|
// // document.getElementById('crate').innerHTML=modem_info.crate;
|
||||||
|
// // if (phonenx == "")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById('phone').value=modem_info.phone;
|
||||||
|
// // document.getElementById('phonen').value=modem_info.phonen;
|
||||||
|
// // phonenx = document.getElementById('phone').value;
|
||||||
|
// // document.getElementById("phone").disabled=false;
|
||||||
|
// // document.getElementById("phonen").disabled=false;
|
||||||
|
// // document.getElementById("pho").disabled=false;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // if (modem_info.phone == "-")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById('phone').value="-";
|
||||||
|
// // document.getElementById('phonen').value="-";
|
||||||
|
// // document.getElementById("pho").disabled=true;
|
||||||
|
// // document.getElementById("phone").disabled=true;
|
||||||
|
// // document.getElementById("phonen").disabled=true;
|
||||||
|
// // phonenx = "";
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // simerr = modem_info.simerr;
|
||||||
|
// // if (simerr == "0")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simwarn").style.display="none";
|
||||||
|
// // }
|
||||||
|
// // else
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simwarn").style.display="block";
|
||||||
|
// // document.getElementById("simsg").style.color = "red";
|
||||||
|
// // if (simerr == "1")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simsg").innerHTML = "<%:SIM卡已锁定,个人资料中未输入SIM Pin!!%>";
|
||||||
|
// // }
|
||||||
|
// // else
|
||||||
|
// // {
|
||||||
|
// // if (simerr == "2")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simsg").innerHTML = "<%:解锁SIM卡的Pin不正确%>";
|
||||||
|
// // }
|
||||||
|
// // else
|
||||||
|
// // {
|
||||||
|
// // if (simerr == "3")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simsg").innerHTML = "<%:无效SIM卡%>";
|
||||||
|
// // } else
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("simsg").innerHTML = "<%:SIM卡未锁定.错误的SIM卡%>";
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
|
||||||
|
// // reslt=modem_info.result
|
||||||
|
|
||||||
|
// // portx=modem_info.port
|
||||||
|
// // if (portx == "-" )
|
||||||
|
// // {
|
||||||
|
// // document.getElementById('inc1').style.display="none";
|
||||||
|
// // document.getElementById('dec1').style.display="none";
|
||||||
|
// // }
|
||||||
|
// // else
|
||||||
|
// // {
|
||||||
|
// // document.getElementById('inc1').style.display="block";
|
||||||
|
// // document.getElementById('dec1').style.display="block";
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // host = modem_info.host;
|
||||||
|
// // if(host == "1")
|
||||||
|
// // {
|
||||||
|
// // document.getElementById("pho").disabled=true;
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新模组数据
|
||||||
|
function update()
|
||||||
|
{
|
||||||
|
var at_port="";
|
||||||
|
if (modem_select.options.length!=0) {
|
||||||
|
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},
|
||||||
|
function(x, modem_info)
|
||||||
|
{
|
||||||
|
console.log(modem_info);
|
||||||
|
|
||||||
|
var base_info=modem_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 more_info=modem_info["more_info"];
|
||||||
|
for (var key in more_info)
|
||||||
|
{
|
||||||
|
var more_info_Element=document.getElementById(key);
|
||||||
|
if (more_info_Element!=null)
|
||||||
|
{
|
||||||
|
more_info_Element.innerHTML=more_info[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定时触发更新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;
|
||||||
|
// 更新(key:AT串口,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
modemtype=0;
|
modemtype=0;
|
||||||
cell=0;
|
cell=0;
|
||||||
portx="-";
|
portx="-";
|
||||||
phonenx = "";
|
phonenx = "";
|
||||||
hided = 0;
|
hided = 0;
|
||||||
|
|
||||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_csq")%>', null,
|
|
||||||
function(x, rv)
|
|
||||||
{
|
|
||||||
document.getElementById('date').innerHTML=rv.date;
|
|
||||||
|
|
||||||
document.getElementById('csq').innerHTML=rv.csq;
|
|
||||||
document.getElementById('per').innerHTML=rv.per;
|
|
||||||
document.getElementById('rssi').innerHTML=rv.rssi;
|
|
||||||
document.getElementById('modem').innerHTML=rv.modem;
|
|
||||||
document.getElementById('cops').innerHTML=rv.cops;
|
|
||||||
document.getElementById('net_type').innerHTML=rv.net_type;
|
|
||||||
document.getElementById('lac').innerHTML=rv.lac;
|
|
||||||
document.getElementById('cid').innerHTML=rv.cid;
|
|
||||||
document.getElementById('lacn').innerHTML=rv.lacn;
|
|
||||||
document.getElementById('cidn').innerHTML=rv.cidn;
|
|
||||||
document.getElementById('mcc').innerHTML=rv.mcc;
|
|
||||||
document.getElementById('mnc').innerHTML=rv.mnc;
|
|
||||||
document.getElementById('rnc').innerHTML=rv.rnc;
|
|
||||||
document.getElementById('rncn').innerHTML=rv.rncn;
|
|
||||||
document.getElementById('down').innerHTML=rv.down;
|
|
||||||
document.getElementById('up').innerHTML=rv.up;
|
|
||||||
document.getElementById('ecio').innerHTML=rv.ecio;
|
|
||||||
document.getElementById('rscp').innerHTML=rv.rscp;
|
|
||||||
document.getElementById('ecio1').innerHTML=rv.ecio1;
|
|
||||||
document.getElementById('rscp1').innerHTML=rv.rscp1;
|
|
||||||
document.getElementById('manufacturer').innerHTML=rv.manufacturer;
|
|
||||||
document.getElementById('chan').innerHTML=rv.channel;
|
|
||||||
document.getElementById('lband').innerHTML=rv.lband;
|
|
||||||
document.getElementById('conmon').innerHTML=rv.netmode;
|
|
||||||
document.getElementById('tempur').innerHTML=rv.tempur;
|
|
||||||
|
|
||||||
document.getElementById('pci').innerHTML=rv.pci;
|
|
||||||
document.getElementById('sinr').innerHTML=rv.sinr;
|
|
||||||
|
|
||||||
document.getElementById('imei').innerHTML=rv.imei;
|
|
||||||
document.getElementById('imsi').innerHTML=rv.imsi;
|
|
||||||
document.getElementById('iccid').innerHTML=rv.iccid;
|
|
||||||
document.getElementById('phone').innerHTML=rv.phone;
|
|
||||||
|
|
||||||
|
|
||||||
<% if havegps == 1 then %>
|
|
||||||
document.getElementById('lat').innerHTML=rv.lat;
|
|
||||||
document.getElementById('long').innerHTML=rv.long;
|
|
||||||
<% end %>
|
|
||||||
// document.getElementById('idvp').innerHTML=rv.modid;
|
|
||||||
// document.getElementById('proto').innerHTML=rv.proto;
|
|
||||||
// document.getElementById('port').innerHTML=rv.port;
|
|
||||||
|
|
||||||
// document.getElementById('crate').innerHTML=rv.crate;
|
|
||||||
// if (phonenx == "")
|
|
||||||
// {
|
|
||||||
// document.getElementById('phone').value=rv.phone;
|
|
||||||
// document.getElementById('phonen').value=rv.phonen;
|
|
||||||
// phonenx = document.getElementById('phone').value;
|
|
||||||
// document.getElementById("phone").disabled=false;
|
|
||||||
// document.getElementById("phonen").disabled=false;
|
|
||||||
// document.getElementById("pho").disabled=false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (rv.phone == "-")
|
|
||||||
// {
|
|
||||||
// document.getElementById('phone').value="-";
|
|
||||||
// document.getElementById('phonen').value="-";
|
|
||||||
// document.getElementById("pho").disabled=true;
|
|
||||||
// document.getElementById("phone").disabled=true;
|
|
||||||
// document.getElementById("phonen").disabled=true;
|
|
||||||
// phonenx = "";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// simerr = rv.simerr;
|
|
||||||
// if (simerr == "0")
|
|
||||||
// {
|
|
||||||
// document.getElementById("simwarn").style.display="none";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// document.getElementById("simwarn").style.display="block";
|
|
||||||
// document.getElementById("simsg").style.color = "red";
|
|
||||||
// if (simerr == "1")
|
|
||||||
// {
|
|
||||||
// document.getElementById("simsg").innerHTML = "<%:SIM卡已锁定,个人资料中未输入SIM Pin!!%>";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (simerr == "2")
|
|
||||||
// {
|
|
||||||
// document.getElementById("simsg").innerHTML = "<%:解锁SIM卡的Pin不正确%>";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (simerr == "3")
|
|
||||||
// {
|
|
||||||
// document.getElementById("simsg").innerHTML = "<%:无效SIM卡%>";
|
|
||||||
// } else
|
|
||||||
// {
|
|
||||||
// document.getElementById("simsg").innerHTML = "<%:SIM卡未锁定.错误的SIM卡%>";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// reslt=rv.result
|
|
||||||
|
|
||||||
// portx=rv.port
|
|
||||||
// if (portx == "-" )
|
|
||||||
// {
|
|
||||||
// document.getElementById('inc1').style.display="none";
|
|
||||||
// document.getElementById('dec1').style.display="none";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// document.getElementById('inc1').style.display="block";
|
|
||||||
// document.getElementById('dec1').style.display="block";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// host = rv.host;
|
|
||||||
// if(host == "1")
|
|
||||||
// {
|
|
||||||
// document.getElementById("pho").disabled=true;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function clear_data()
|
function clear_data()
|
||||||
{
|
{
|
||||||
document.getElementById('port').innerHTML="<%:Changing Port%>";
|
document.getElementById('port').innerHTML="<%:Changing Port%>";
|
||||||
document.getElementById('csq').innerHTML="-";
|
document.getElementById('csq').innerHTML="-";
|
||||||
document.getElementById('per').innerHTML="-";
|
document.getElementById('per').innerHTML="-";
|
||||||
document.getElementById('rssi').innerHTML="-";
|
document.getElementById('rssi').innerHTML="-";
|
||||||
document.getElementById('modem').innerHTML="-";
|
// document.getElementById('modem').innerHTML="-";
|
||||||
document.getElementById('cops').innerHTML="-";
|
document.getElementById('cops').innerHTML="-";
|
||||||
document.getElementById('net_type').innerHTML="-";
|
document.getElementById('net_type').innerHTML="-";
|
||||||
document.getElementById('lac').innerHTML="-";
|
document.getElementById('lac').innerHTML="-";
|
||||||
@ -187,19 +311,12 @@ end
|
|||||||
// document.getElementById('idvp').innerHTML="-";
|
// document.getElementById('idvp').innerHTML="-";
|
||||||
// document.getElementById('phonen').value="-";
|
// document.getElementById('phonen').value="-";
|
||||||
}
|
}
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//]]></script>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="cbi-map" id="cbi-modem">
|
<div class="cbi-map" id="cbi-modem">
|
||||||
<h2 name="content"><%:信号状态/模块信息%></h2>
|
<h2 name="content"><%:Modem Info%></h2>
|
||||||
<div class="cbi-map-descr">请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配)
|
<div class="cbi-map-descr"><%:%></div>
|
||||||
</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>
|
||||||
@ -212,27 +329,50 @@ end
|
|||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<% at_ports = getATPort() %>
|
||||||
|
<% if next(at_ports) == nil then %>
|
||||||
|
|
||||||
<fieldset class="cbi-section" id="cbi-mod">
|
<fieldset class="cbi-section" id="info">
|
||||||
<legend><%:综合信息%></legend>
|
<h3><%:信息%></h3>
|
||||||
|
<table width="550" border="0">
|
||||||
|
<tr>
|
||||||
|
<td width="10%"></td>
|
||||||
|
<td width="60%"><div align="left" id="simsg" style="font-size:1.875em"><strong><%:No modems found%></strong></div></td>
|
||||||
|
<td width="30%"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
<fieldset class="cbi-section" id="cbi-baseinfo">
|
||||||
|
<h3><%:基本信息%></h3>
|
||||||
<table width="100%" cellspacing="10">
|
<table width="100%" cellspacing="10">
|
||||||
<tr><td width="20%"><%:模块 :%></td><td id="modem">-</td><td></td></tr>
|
<tr><td width="20%"><%:模组 :%></td><td id="modem_name">
|
||||||
|
<select name="modem_select" id="modem_select">
|
||||||
|
<% at_ports = getATPort() %>
|
||||||
|
<% for key in pairs(at_ports) do %>
|
||||||
|
<option value="<%= key %>"><%= at_ports[key] %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</td><td></td></tr>
|
||||||
<tr><td width="20%"><%:制造商 :%></td><td id="manufacturer"></td><td></td></tr>
|
<tr><td width="20%"><%:制造商 :%></td><td id="manufacturer"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:温度 : %></td><td id="tempur"></td><td></td></tr>
|
<tr><td width="20%"><%:固件版本 :%></td><td id="revision"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:更新时间 : %></td><td id="date"></td><td></td></tr>
|
<tr><td width="20%"><%:数据接口 : %></td><td id="data_interface"></td><td></td></tr>
|
||||||
<!-- <tr><td width="20%"><%:ID : %></td><td id="idvp"></td><td></td></tr>
|
<tr><td width="20%"><%:拨号模式 : %></td><td id="mode"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:端口 : %></td><td id="port"></td><td></td></tr>
|
<tr><td width="20%"><%:AT串口 : %></td><td id="at_port"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:协议 : %></td><td id="proto"></td><td></td></tr> -->
|
<tr><td width="20%"><%:移动网络 : %></td><td id="network"></td><td></td></tr>
|
||||||
|
<tr><td width="20%"><%:温度 : %></td><td id="temperature"></td><td></td></tr>
|
||||||
|
<tr><td width="20%"><%:更新时间 : %></td><td id="update_time"></td><td></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<% if nosms == 0 then %>
|
<% if nosms == 0 then %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<fieldset class="cbi-section" id="cbi-msinfo">
|
<fieldset class="cbi-section" id="cbi-siminfo">
|
||||||
<legend><%:通信模块/SIM卡信息%></legend>
|
<h3><%:SIM卡信息%></h3>
|
||||||
<table width="100%" cellspacing="10">
|
<table width="100%" cellspacing="10">
|
||||||
<tr><td width="20%"><%:运营商 : %></td><td id="cops"></td><td></td></tr>
|
<tr><td width="20%"><%:运营商 : %></td><td id="isp"></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>
|
||||||
@ -240,11 +380,10 @@ end
|
|||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="cbi-section" id="cbi-networkinfo">
|
||||||
<fieldset class="cbi-section" id="cbi-sig">
|
<h3><%:网络信息%></h3>
|
||||||
<legend><%:信号状态%></legend>
|
|
||||||
<table width="100%" cellspacing="10">
|
<table width="100%" cellspacing="10">
|
||||||
<tr><td width="20%"><%:蜂窝网络类型 :%></td><td id="net_type"></td><td></td></tr>
|
<tr><td width="20%"><%:网络类型 :%></td><td id="net_type"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:CSQ : %></td><td id="csq"></td><td></td></tr>
|
<tr><td width="20%"><%:CSQ : %></td><td id="csq"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:信号强度 : %></td><td id="per"></td><td></td></tr>
|
<tr><td width="20%"><%:信号强度 : %></td><td id="per"></td><td></td></tr>
|
||||||
<tr><td width="20%"><%:信号接收强度 RSSI : %></td><td id="rssi"></td><td></td></tr>
|
<tr><td width="20%"><%:信号接收强度 RSSI : %></td><td id="rssi"></td><td></td></tr>
|
||||||
@ -257,7 +396,7 @@ end
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="cbi-section" id="cbi-sig">
|
<fieldset class="cbi-section" id="cbi-sig">
|
||||||
<legend><%:基站信息%></legend>
|
<h3><%:基站信息%></h3>
|
||||||
<table width="100%" cellspacing="10">
|
<table width="100%" cellspacing="10">
|
||||||
<tr><td width="20%"><%:MCC / MNC :%></td><td id="mcc"></td><td id="mnc"></td></tr>
|
<tr><td width="20%"><%:MCC / MNC :%></td><td id="mcc"></td><td id="mnc"></td></tr>
|
||||||
<tr><td width="20%"><%:eNB ID : %></td><td><ul><span id="rnc" class="r"></span><span id="rncn" class="r"></span></ul></td><td></td></tr>
|
<tr><td width="20%"><%:eNB ID : %></td><td><ul><span id="rnc" class="r"></span><span id="rncn" class="r"></span></ul></td><td></td></tr>
|
||||||
@ -271,10 +410,9 @@ end
|
|||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
||||||
<% if havegps == 1 then %>
|
<% if havegps == 1 then %>
|
||||||
<fieldset class="cbi-section" id="cbi-gps">
|
<fieldset class="cbi-section" id="cbi-gpsinfo">
|
||||||
<legend><%:GPS 定位%></legend>
|
<h3><%:GPS 定位%></h3>
|
||||||
<table width="550" border="0">
|
<table width="550" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td width="30%"><div align="right"><%:纬度 :%></div></td>
|
<td width="30%"><div align="right"><%:纬度 :%></div></td>
|
||||||
@ -290,6 +428,7 @@ end
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<%+footer%>
|
<%+footer%>
|
||||||
|
95
luci-app-modem/luasrc/view/modem/modem_status.htm
Normal file
95
luci-app-modem/luasrc/view/modem/modem_status.htm
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<%#
|
||||||
|
Copyright 2014 Aedan Renner <chipdankly@gmail.com>
|
||||||
|
Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
|
Licensed to the public under the GNU General Public License v2.
|
||||||
|
-%>
|
||||||
|
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modems")%>', null,
|
||||||
|
function(x, modems)
|
||||||
|
{
|
||||||
|
console.log(modems);
|
||||||
|
var modemsDiv = document.getElementById('modem_status_text');
|
||||||
|
if (modems.length!=0)
|
||||||
|
{
|
||||||
|
var modem_view = '';
|
||||||
|
for ( var key in modems)
|
||||||
|
{
|
||||||
|
var modem=modems[key];
|
||||||
|
var state = '';
|
||||||
|
var css = ''
|
||||||
|
switch (modem["connect_status"])
|
||||||
|
{
|
||||||
|
case 'connect':
|
||||||
|
state = '<%:Connect%>';
|
||||||
|
css = 'success';
|
||||||
|
break;
|
||||||
|
case 'disconnect':
|
||||||
|
state = '<%:Disconnect%>';
|
||||||
|
css = 'danger';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state = '<%:Disabled%>';
|
||||||
|
css = 'warning';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div class="alert-message %s">',
|
||||||
|
css
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong>No: </strong>%s</div>',
|
||||||
|
modem[".name"]
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong><%:Modem Name%>: </strong>%s</div>',
|
||||||
|
modem.name.toUpperCase()
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong><%:Data Interface%>: </strong>%s</div>',
|
||||||
|
modem.data_interface.toUpperCase()
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong><%:Mode%>: </strong>%s</div>',
|
||||||
|
modem.mode.toUpperCase()
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong><%:Moblie Network%>: </strong>%s</div>',
|
||||||
|
modem.network
|
||||||
|
);
|
||||||
|
modem_view += String.format(
|
||||||
|
'<div><strong><%:Connect Status%>: </strong>%s</div>',
|
||||||
|
<%:modem.connect_status%>
|
||||||
|
);
|
||||||
|
modem_view += '</div>'
|
||||||
|
}
|
||||||
|
modemsDiv.innerHTML = modem_view;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modemsDiv.innerHTML = '<strong><%:No modems found%></strong>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
#modem_status_text > div {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
width: 15rem;
|
||||||
|
float: left;
|
||||||
|
line-height: 125%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<fieldset id="modem_field" class="cbi-section">
|
||||||
|
<!-- <legend><%:Modem Status%></legend> -->
|
||||||
|
<h3><%:Modem Status%></h3>
|
||||||
|
<div id="modem_status_text">
|
||||||
|
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
|
||||||
|
<%:Loading modem status...%>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
@ -1,135 +0,0 @@
|
|||||||
# OpenWRT软件开发
|
|
||||||
|
|
||||||
# 一、相关文档
|
|
||||||
|
|
||||||
UCI系统:https://openwrt.org/docs/guide-user/base-system/uci
|
|
||||||
|
|
||||||
OpenWRT命令解释器:https://openwrt.org/zh/docs/guide-user/base-system/user.beginner.cli
|
|
||||||
|
|
||||||
热插拔:https://openwrt.org/zh/docs/guide-user/base-system/hotplug
|
|
||||||
|
|
||||||
网络基础配置:https://openwrt.org/zh/docs/guide-user/base-system/basic-networking
|
|
||||||
|
|
||||||
Web界面相关
|
|
||||||
|
|
||||||
- 自定义主题:https://github.com/openwrt/luci/wiki/HowTo:-Create-Themes
|
|
||||||
- 模块参考:https://github.com/openwrt/luci/wiki/Modules
|
|
||||||
- 模板参考:https://github.com/openwrt/luci/wiki/Templates
|
|
||||||
- 实例参考:https://blog.csdn.net/byb123/article/details/77921486/
|
|
||||||
|
|
||||||
# 二、网络配置
|
|
||||||
|
|
||||||
在任何网络配置更改(通过uci或其他方式)之后,你需要输入以下内容来重载网络配置:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
service network reload
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您安装的版本没有提供`service`命令,则可以使用:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
/etc/init.d/network reload
|
|
||||||
```
|
|
||||||
|
|
||||||
# 三、拨号程序
|
|
||||||
|
|
||||||
拨号步骤
|
|
||||||
|
|
||||||
```shell
|
|
||||||
run_dial()
|
|
||||||
{
|
|
||||||
local enabled
|
|
||||||
config_get_bool enabled $1 enabled
|
|
||||||
|
|
||||||
if [ "$enabled" = "1" ]; then
|
|
||||||
local apn
|
|
||||||
local user
|
|
||||||
local password
|
|
||||||
local auth
|
|
||||||
local ipv6
|
|
||||||
local device
|
|
||||||
|
|
||||||
#获取配置
|
|
||||||
config_get apn $1 apn
|
|
||||||
config_get user $1 user
|
|
||||||
config_get password $1 password
|
|
||||||
config_get auth $1 auth
|
|
||||||
config_get ipv6 $1 ipv6
|
|
||||||
config_get device $1 device
|
|
||||||
|
|
||||||
devname="$(basename "$device")" #获取调制解调器,/dev/cdc-wdm0->cdc-wdm0
|
|
||||||
devicepath="$(find /sys/class/ -name $devname)" #找到设备快捷路径,/sys/class/net/cdc-wdm0
|
|
||||||
devpath="$(readlink -f $devicepath/device/)" #找出连接的物理设备路径,/sys/devices/.../
|
|
||||||
ifname="$( ls "$devpath"/net )" #获取设备名,/sys/devices/.../net->cdc-wdm0
|
|
||||||
|
|
||||||
procd_open_instance #打开一个示例?
|
|
||||||
procd_set_param command quectel-CM #设置参数?
|
|
||||||
if [ "$ipv6" = 1 ]; then
|
|
||||||
procd_append_param command -4 -6
|
|
||||||
fi
|
|
||||||
if [ "$apn" != "" ];then
|
|
||||||
procd_append_param command -s $apn
|
|
||||||
fi
|
|
||||||
if [ "$user" != "" ]; then
|
|
||||||
procd_append_param command $user
|
|
||||||
fi
|
|
||||||
if [ "$password" != "" ]; then
|
|
||||||
procd_append_param command $password
|
|
||||||
fi
|
|
||||||
if [ "$auth" != "" ]; then
|
|
||||||
procd_append_param command $auth
|
|
||||||
fi
|
|
||||||
if [ "$device" != "" ]; then
|
|
||||||
procd_append_param command -i $ifname
|
|
||||||
fi
|
|
||||||
procd_set_param respawn
|
|
||||||
procd_close_instance
|
|
||||||
|
|
||||||
if [ -d /sys/class/net/rmnet_mhi0 ]; then
|
|
||||||
pre_set rmnet_mhi0.1
|
|
||||||
elif [ -d /sys/class/net/wwan0_1 ]; then
|
|
||||||
pre_set wwan0_1
|
|
||||||
elif [ -d /sys/class/net/wwan0.1 ]; then
|
|
||||||
pre_set wwan0.1
|
|
||||||
elif [ -d /sys/class/net/wwan0 ]; then
|
|
||||||
pre_set wwan0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 15
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
# 四、shell
|
|
||||||
|
|
||||||
获取设备物理路径
|
|
||||||
|
|
||||||
device_bus_path.sh
|
|
||||||
|
|
||||||
```shell
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#获取物理设备地址
|
|
||||||
local device_name="$(basename "$1")"
|
|
||||||
local device_path="$(find /sys/class/ -name $device_name)"
|
|
||||||
local device_physical_path="$(readlink -f $device_path/device/)"
|
|
||||||
local device_bus_path=$(dirname "$device_physical_path")
|
|
||||||
return $device_bus_path
|
|
||||||
```
|
|
||||||
|
|
||||||
设置配置
|
|
||||||
|
|
||||||
setConfig.sh
|
|
||||||
|
|
||||||
```shell
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#处理获取到的路径
|
|
||||||
substr="${parentDir/\/sys\/devices\//}"
|
|
||||||
echo $substr
|
|
||||||
|
|
||||||
#写入到配置中
|
|
||||||
uci set modem.modem1.path="$substr"
|
|
||||||
uci commit modem2
|
|
||||||
```
|
|
||||||
|
|
@ -7,18 +7,60 @@ msgstr "移动通信模组"
|
|||||||
msgid "Modem Config"
|
msgid "Modem Config"
|
||||||
msgstr "模组配置"
|
msgstr "模组配置"
|
||||||
|
|
||||||
msgid "Modem List"
|
msgid "Modem Status"
|
||||||
msgstr "模块列表"
|
msgstr "模组状态"
|
||||||
|
|
||||||
msgid "Configuration panel for Modem, Add and configure all modules on this page"
|
msgid "Modem Name"
|
||||||
msgstr "通信模组服务配置界面,在此页面添加和配置所有模块"
|
msgstr "模组名称"
|
||||||
|
|
||||||
|
msgid "Modem Select"
|
||||||
|
msgstr "选择模组"
|
||||||
|
|
||||||
|
msgid "Check information about adapted modem on this page"
|
||||||
|
msgstr "在此页面查看已适配模组的信息"
|
||||||
|
|
||||||
|
msgid "Loading modem status..."
|
||||||
|
msgstr "正在加载模组状态"
|
||||||
|
|
||||||
|
msgid "Connect"
|
||||||
|
msgstr "已连接"
|
||||||
|
|
||||||
|
msgid "Disconnect"
|
||||||
|
msgstr "未连接"
|
||||||
|
|
||||||
|
msgid "Disabled"
|
||||||
|
msgstr "未启用"
|
||||||
|
|
||||||
|
msgid "Data Interface"
|
||||||
|
msgstr "数据接口"
|
||||||
|
|
||||||
|
msgid "Mode"
|
||||||
|
msgstr "模式"
|
||||||
|
|
||||||
|
msgid "Connect Status"
|
||||||
|
msgstr "连接状态"
|
||||||
|
|
||||||
|
msgid "Config List"
|
||||||
|
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"
|
||||||
|
msgstr "使用AT命令调试你的模组"
|
||||||
|
|
||||||
msgid "Modem Info"
|
msgid "Modem Info"
|
||||||
msgstr "模组信息"
|
msgstr "模组信息"
|
||||||
|
|
||||||
|
msgid "No modems found"
|
||||||
|
msgstr "没有找到模组"
|
||||||
|
|
||||||
|
msgid "Check to enable all configurations"
|
||||||
|
msgstr "勾选启用全部配置"
|
||||||
|
|
||||||
msgid "General Settings"
|
msgid "General Settings"
|
||||||
msgstr "通用配置"
|
msgstr "通用配置"
|
||||||
|
|
||||||
@ -34,11 +76,14 @@ msgstr "移动网络"
|
|||||||
msgid "UNKNOWN"
|
msgid "UNKNOWN"
|
||||||
msgstr "未知"
|
msgstr "未知"
|
||||||
|
|
||||||
msgid "The network device was not found"
|
msgid "Mobile network not found"
|
||||||
msgstr "移动网络"
|
msgstr "未发现移动网络"
|
||||||
|
|
||||||
msgid "Mode"
|
msgid "The network device was not found"
|
||||||
msgstr "模式"
|
msgstr "找不到网络设备"
|
||||||
|
|
||||||
|
msgid "Only display the modes available for the adaptation modem"
|
||||||
|
msgstr "仅显示适配模组可用的拨号模式"
|
||||||
|
|
||||||
msgid "Dial Tool"
|
msgid "Dial Tool"
|
||||||
msgstr "拨号工具"
|
msgstr "拨号工具"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
config global 'global'
|
config global 'global'
|
||||||
option enable '0'
|
option enable '1'
|
||||||
|
option modem_number '0'
|
||||||
|
51
luci-app-modem/root/etc/config/modem_command.user
Normal file
51
luci-app-modem/root/etc/config/modem_command.user
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
****************通用****************;ATI
|
||||||
|
模组信息 > ATI;ATI
|
||||||
|
查询SIM卡状态 > AT+CPIN?;AT+CPIN?
|
||||||
|
查询此时信号强度 > AT+CSQ;AT+CSQ
|
||||||
|
查询网络信息 > AT+COPS?;AT+COPS?
|
||||||
|
查询PDP信息 > AT+CGDCONT?;AT+CGDCONT?
|
||||||
|
最小功能模式 > AT+CFUN=0;AT+CFUN=0
|
||||||
|
全功能模式 > AT+CFUN=1;AT+CFUN=1
|
||||||
|
****************移远****************;ATI
|
||||||
|
SIM卡状态上报 > AT+QSIMSTAT?;AT+QSIMSTAT?
|
||||||
|
设置当前使用的为卡1 > AT+QUIMSLOT=1;AT+QUIMSLOT=1
|
||||||
|
设置当前使用的为卡2 > AT+QUIMSLOT=2;AT+QUIMSLOT=2
|
||||||
|
查询网络信息 > AT+QNWINFO;AT+QNWINFO
|
||||||
|
查询载波聚合参数 > AT+QCAINFO;AT+QCAINFO
|
||||||
|
查询当前拨号模式 > AT+QCFG="usbnet";AT+QCFG="usbnet"
|
||||||
|
QMI/GobiNet拨号 > AT+QCFG="usbnet",0;AT+QCFG="usbnet",0
|
||||||
|
ECM拨号 > AT+QCFG="usbnet",1;AT+QCFG="usbnet",1
|
||||||
|
MBIM拨号 > AT+QCFG="usbnet",2;AT+QCFG="usbnet",2
|
||||||
|
RNDIS拨号 > AT+QCFG="usbnet",3;AT+QCFG="usbnet",3
|
||||||
|
NCM拨号 > AT+QCFG="usbnet",5;AT+QCFG="usbnet",5
|
||||||
|
锁4G > AT+QNWPREFCFG="mode_pref",LTE;AT+QNWPREFCFG="mode_pref",LTE
|
||||||
|
锁5G > AT+QNWPREFCFG="mode_pref",NR5G;AT+QNWPREFCFG="mode_pref",NR5G
|
||||||
|
恢复自动搜索网络 > AT+QNWPREFCFG="mode_pref",AUTO;AT+QNWPREFCFG="mode_pref",AUTO
|
||||||
|
查询模组IMEI > AT+CGSN;AT+CGSN
|
||||||
|
查询模组IMEI > AT+GSN;AT+GSN
|
||||||
|
更改模组IMEI > AT+EGMR=1,7,"IMEI";AT+EGMR=1,7,"在此设置IMEI"
|
||||||
|
获取模组温度 > AT+QTEMP;AT+QTEMP
|
||||||
|
切换为USB通信端口 > AT+QCFG="data_interface",0,0;AT+QCFG="data_interface",0,0
|
||||||
|
切换为PCIE通信端口 > AT+QCFG="data_interface",1,0;AT+QCFG="data_interface",1,0
|
||||||
|
重置模组 > AT+CFUN=1,1;AT+CFUN=1,1
|
||||||
|
****************广和通****************;ATI
|
||||||
|
设置当前使用的为卡1 > AT+GTDUALSIM=0;AT+GTDUALSIM=0
|
||||||
|
设置当前使用的为卡2 > AT+GTDUALSIM=1;AT+GTDUALSIM=1
|
||||||
|
ECM手动拨号 > AT+GTRNDIS=1,1;AT+GTRNDIS=1,1
|
||||||
|
ECM拨号断开 > AT+GTRNDIS=0,1;AT+GTRNDIS=0,1
|
||||||
|
查询当前端口模式 > AT+GTUSBMODE?;AT+GTUSBMODE?
|
||||||
|
QMI/GobiNet拨号 > AT+GTUSBMODE=32;AT+GTUSBMODE=32
|
||||||
|
ECM拨号 > AT+GTUSBMODE=18;AT+GTUSBMODE=18
|
||||||
|
MBIM拨号 > AT+GTUSBMODE=30;AT+GTUSBMODE=30
|
||||||
|
RNDIS拨号 > AT+GTUSBMODE=24;AT+GTUSBMODE=24
|
||||||
|
NCM拨号 > AT+GTUSBMODE=18;AT+GTUSBMODE=18
|
||||||
|
锁4G > AT+GTACT=2;AT+GTACT=2
|
||||||
|
锁5G > AT+GTACT=14;AT+GTACT=14
|
||||||
|
恢复自动搜索网络 > AT+GTACT=20;AT+GTACT=20
|
||||||
|
查询当前连接的网络类型 > AT+PSRAT?;AT+PSRAT?
|
||||||
|
查询模组IMEI > AT+CGSN?;AT+CGSN?
|
||||||
|
查询模组IMEI > AT+GSN?;AT+GSN?
|
||||||
|
更改模组IMEI > AT+GTSN=1,7,"IMEI";AT+GTSN=1,7,"在此设置IMEI"
|
||||||
|
报告一次当前BBIC的温度 > AT+MTSM=1,6;AT+MTSM=1,6
|
||||||
|
报告一次当前射频的温度 > AT+MTSM=1,7;AT+MTSM=1,7
|
||||||
|
重置模组 > AT+CFUN=15;AT+CFUN=15
|
@ -1,88 +1,93 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2006-2014 OpenWrt.org
|
# Copyright (C) 2006-2014 OpenWrt.org
|
||||||
|
|
||||||
START=94
|
START=21
|
||||||
STOP=13
|
STOP=13
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
#设置拨号模式
|
#设置拨号模式
|
||||||
# $1:拨号模式
|
# $1:拨号模式
|
||||||
set_mode()
|
# set_mode()
|
||||||
{
|
# {
|
||||||
#获取AT串口、制造商、模块名
|
# #获取AT串口、制造商、模块名
|
||||||
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
# local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||||
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
# local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||||
local name=$(uci -q get modem.modem$modem_no.name)
|
# local name=$(uci -q get modem.modem$modem_no.name)
|
||||||
|
|
||||||
#分制造商设置不同的AT命令
|
# #分制造商设置不同的AT命令
|
||||||
local command
|
# local command
|
||||||
if [ "$manufacturer" = "quectel" ]; then
|
# if [ "$manufacturer" = "quectel" ]; then
|
||||||
local mode_num
|
# local mode_num
|
||||||
case $1 in
|
# case $1 in
|
||||||
"qmi") mode_num='0' ;;
|
# "qmi") mode_num='0' ;;
|
||||||
"gobinet") mode_num='0' ;;
|
# "gobinet") mode_num='0' ;;
|
||||||
"ecm") mode_num='1' ;;
|
# "ecm") mode_num='1' ;;
|
||||||
"mbim") mode_num='2' ;;
|
# "mbim") mode_num='2' ;;
|
||||||
"rndis") mode_num='3' ;;
|
# "rndis") mode_num='3' ;;
|
||||||
"ncm") mode_num='5' ;;
|
# "ncm") mode_num='5' ;;
|
||||||
"*") mode_num='0' ;;
|
# "*") mode_num='0' ;;
|
||||||
esac
|
# esac
|
||||||
|
|
||||||
#查询当前拨号模式
|
# #查询当前拨号模式
|
||||||
command='AT+QCFG="usbnet"'
|
# command='AT+QCFG="usbnet"'
|
||||||
local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
# local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
||||||
if [[ "$at_result" != *"$mode_num"* ]]; then
|
# if [[ "$at_result" != *"$mode_num"* ]]; then
|
||||||
#切换到指定的拨号模式
|
|
||||||
case $1 in
|
|
||||||
"qmi") command='AT+QCFG="usbnet",0' ;;
|
|
||||||
"gobinet") command='AT+QCFG="usbnet",0' ;;
|
|
||||||
"ecm") command='AT+QCFG="usbnet",1' ;;
|
|
||||||
"mbim") command='AT+QCFG="usbnet",2' ;;
|
|
||||||
"rndis") command='AT+QCFG="usbnet",3' ;;
|
|
||||||
"ncm") command='AT+QCFG="usbnet",5' ;;
|
|
||||||
"*") command='AT+QCFG="usbnet",0' ;;
|
|
||||||
esac
|
|
||||||
sh /usr/share/modem/modem_at.sh $at_port $command
|
|
||||||
#移远切换模式后,还需要重启模块,待测试
|
|
||||||
fi
|
|
||||||
elif [ "$manufacturer" = "fibocom" ]; then
|
|
||||||
if [ "$name" = "fm150-ae" ]; then
|
|
||||||
local mode_num
|
|
||||||
case $1 in
|
|
||||||
"qmi") mode_num='32' ;;
|
|
||||||
"gobinet") mode_num='32' ;;
|
|
||||||
"ecm") mode_num='23' ;;
|
|
||||||
"mbim") mode_num='29' ;;
|
|
||||||
"rndis") mode_num='24' ;;
|
|
||||||
"ncm") mode_num='23' ;;
|
|
||||||
"*") mode_num='32' ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
#查询当前拨号模式
|
# #切换到指定的拨号模式
|
||||||
command='AT+GTUSBMODE?'
|
# case $1 in
|
||||||
local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
# "qmi") command='AT+QCFG="usbnet",0' ;;
|
||||||
if [[ "$at_result" != *"$mode_num"* ]]; then
|
# "gobinet") command='AT+QCFG="usbnet",0' ;;
|
||||||
#切换到指定的拨号模式
|
# "ecm") command='AT+QCFG="usbnet",1' ;;
|
||||||
case $1 in
|
# "mbim") command='AT+QCFG="usbnet",2' ;;
|
||||||
"qmi") command='AT+GTUSBMODE=32' ;;
|
# "rndis") command='AT+QCFG="usbnet",3' ;;
|
||||||
"gobinet") command='AT+GTUSBMODE=32' ;;
|
# "ncm") command='AT+QCFG="usbnet",5' ;;
|
||||||
"ecm") command='AT+GTUSBMODE=23' ;;
|
# "*") command='AT+QCFG="usbnet",0' ;;
|
||||||
"mbim") command='AT+GTUSBMODE=29' ;;
|
# esac
|
||||||
"rndis") command='AT+GTUSBMODE=24' ;;
|
# at_result=$(sh /usr/share/modem/modem_at.sh "$at_port" "$command")
|
||||||
"ncm") command='AT+GTUSBMODE=23' ;;
|
# #移远切换模式后,还需要重启模块,待测试
|
||||||
"*") command='AT+GTUSBMODE=32' ;;
|
# sleep 5
|
||||||
esac
|
# modem_scan
|
||||||
sh /usr/share/modem/modem_at.sh $at_port $command
|
# fi
|
||||||
fi
|
# elif [ "$manufacturer" = "fibocom" ]; then
|
||||||
elif [ "$name" = "fm650" ]; then
|
# if [ "$name" = "fm150-ae" ]; then
|
||||||
#待处理
|
# local mode_num
|
||||||
echo "fm650"
|
# case $1 in
|
||||||
fi
|
# "qmi") mode_num='32' ;;
|
||||||
else
|
# "gobinet") mode_num='32' ;;
|
||||||
#没有匹配到制造商,需要手动切换模块的拨号模式
|
# "ecm") mode_num='23' ;;
|
||||||
echo "请手动切换模块的拨号模式"
|
# "mbim") mode_num='29' ;;
|
||||||
fi
|
# "rndis") mode_num='24' ;;
|
||||||
}
|
# "ncm") mode_num='23' ;;
|
||||||
|
# "*") mode_num='32' ;;
|
||||||
|
# esac
|
||||||
|
|
||||||
|
# #查询当前拨号模式
|
||||||
|
# command='AT+GTUSBMODE?'
|
||||||
|
# local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
||||||
|
# if [[ "$at_result" != *"$mode_num"* ]]; then
|
||||||
|
# #切换到指定的拨号模式
|
||||||
|
# case $1 in
|
||||||
|
# "qmi") command='AT+GTUSBMODE=32' ;;
|
||||||
|
# "gobinet") command='AT+GTUSBMODE=32' ;;
|
||||||
|
# "ecm") command='AT+GTUSBMODE=23' ;;
|
||||||
|
# "mbim") command='AT+GTUSBMODE=29' ;;
|
||||||
|
# "rndis") command='AT+GTUSBMODE=24' ;;
|
||||||
|
# "ncm") command='AT+GTUSBMODE=23' ;;
|
||||||
|
# "*") command='AT+GTUSBMODE=32' ;;
|
||||||
|
# esac
|
||||||
|
# at_result=$(sh /usr/share/modem/modem_at.sh "$at_port" "$command")
|
||||||
|
# sleep 5
|
||||||
|
# modem_scan
|
||||||
|
# fi
|
||||||
|
# elif [ "$name" = "fm650" ]; then
|
||||||
|
# #待处理
|
||||||
|
# echo "fm650"
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# #没有匹配到制造商,需要手动切换模块的拨号模式
|
||||||
|
# echo "请手动切换模块的拨号模式"
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
|
||||||
#设置防火墙
|
#设置防火墙
|
||||||
set_firewall()
|
set_firewall()
|
||||||
@ -100,10 +105,12 @@ set_firewall()
|
|||||||
# $2:网络接口
|
# $2:网络接口
|
||||||
set_ipv4_interface()
|
set_ipv4_interface()
|
||||||
{
|
{
|
||||||
[ "$(uci -q get network.$1.ifname)" != "$2" ] && {
|
#配置中不存在这个网络接口配置,或这个网络接口配置的设备不同
|
||||||
|
[ "$(uci -q get network.$1.device)" != "$2" ] && {
|
||||||
uci set network.$1='interface'
|
uci set network.$1='interface'
|
||||||
uci set network.$1.ifname="$2"
|
|
||||||
uci set network.$1.proto='dhcp'
|
uci set network.$1.proto='dhcp'
|
||||||
|
uci set network.$1.device="$2"
|
||||||
|
uci set network.$1.ifname="$2"
|
||||||
uci commit network
|
uci commit network
|
||||||
|
|
||||||
#加入WAN防火墙
|
#加入WAN防火墙
|
||||||
@ -119,11 +126,12 @@ set_ipv4_interface()
|
|||||||
# $2:网络接口
|
# $2:网络接口
|
||||||
set_ipv6_interface()
|
set_ipv6_interface()
|
||||||
{
|
{
|
||||||
if [ "$(uci -q get network.$1.ifname)" != "$2" ]; then
|
if [ "$(uci -q get network.$1.device)" != "$2" ]; then
|
||||||
uci set network.$1='interface'
|
uci set network.$1='interface'
|
||||||
uci set network.$1.ifname="$2"
|
|
||||||
uci set network.$1.proto='dhcpv6'
|
uci set network.$1.proto='dhcpv6'
|
||||||
uci set network.$1.extendprefix='1'
|
uci set network.$1.extendprefix='1'
|
||||||
|
uci set network.$1.device="$2"
|
||||||
|
uci set network.$1.ifname="$2"
|
||||||
uci commit network
|
uci commit network
|
||||||
|
|
||||||
#加入WAN防火墙
|
#加入WAN防火墙
|
||||||
@ -146,24 +154,21 @@ set_interface()
|
|||||||
"ipv4") set_ipv4_interface wwan_5g_$1 $2 ;;
|
"ipv4") set_ipv4_interface wwan_5g_$1 $2 ;;
|
||||||
"ipv6") set_ipv6_interface wwan6_5g_$1 $2 ;;
|
"ipv6") set_ipv6_interface wwan6_5g_$1 $2 ;;
|
||||||
"ipv4_ipv6")
|
"ipv4_ipv6")
|
||||||
set_ipv4_interface wwan_5g_$1 $2
|
set_ipv4_interface "wwan_5g_$1" $2
|
||||||
set_ipv6_interface wwan6_5g_$1 $2
|
set_ipv6_interface "wwan6_5g_$1" $2
|
||||||
;;
|
;;
|
||||||
"*")
|
"*")
|
||||||
set_ipv4_interface wwan_5g_$1 $2
|
set_ipv4_interface "wwan_5g_$1" $2
|
||||||
set_ipv6_interface wwan6_5g_$1 $2
|
set_ipv6_interface "wwan6_5g_$1" $2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
qmi()
|
qmi()
|
||||||
{
|
{
|
||||||
#设置拨号模式
|
|
||||||
set_mode qmi
|
|
||||||
|
|
||||||
#设置网络接口
|
#设置网络接口
|
||||||
local net_interface=$(uci -q get modem.modem$modem_no.net_interface)
|
local network_interface=$(uci -q get modem.modem$modem_no.network_interface)
|
||||||
set_interface $modem_no $net_interface
|
set_interface $modem_no $network_interface
|
||||||
|
|
||||||
#拨号
|
#拨号
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
@ -195,8 +200,8 @@ qmi()
|
|||||||
if [ "$auth" != "" ]; then
|
if [ "$auth" != "" ]; then
|
||||||
procd_append_param command $auth
|
procd_append_param command $auth
|
||||||
fi
|
fi
|
||||||
if [ "$moblie_net" != "" ]; then
|
if [ "$network" != "" ]; then
|
||||||
procd_append_param command -i $moblie_net
|
procd_append_param command -i $network
|
||||||
fi
|
fi
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_set_param procd_pid /var/run/modem/modem$modem_no.pid
|
procd_set_param procd_pid /var/run/modem/modem$modem_no.pid
|
||||||
@ -205,29 +210,32 @@ qmi()
|
|||||||
|
|
||||||
gobinet()
|
gobinet()
|
||||||
{
|
{
|
||||||
qmi
|
#获取网络接口、AT串口、制造商
|
||||||
|
local network_interface=$(uci -q get modem.modem$modem_no.network_interface)
|
||||||
|
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||||
|
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||||
|
#设置网络接口
|
||||||
|
set_interface $modem_no $network_interface
|
||||||
|
|
||||||
|
#拨号
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command sh /usr/share/modem/modem_usb_network.sh $id $at_port $manufacturer "gobinet"
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
ecm()
|
ecm()
|
||||||
{
|
{
|
||||||
#设置拨号模式
|
|
||||||
set_mode ecm
|
|
||||||
|
|
||||||
#获取网络接口、AT串口、制造商
|
#获取网络接口、AT串口、制造商
|
||||||
local net_interface=$(uci -q get modem.modem$modem_no.net_interface)
|
local network_interface=$(uci -q get modem.modem$modem_no.network_interface)
|
||||||
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||||
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||||
#设置网络接口
|
#设置网络接口
|
||||||
set_interface $modem_no $net_interface
|
set_interface $modem_no $network_interface
|
||||||
|
|
||||||
#拨号
|
#拨号
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command sh /usr/share/modem/modem_at.sh $at_port
|
procd_set_param command sh /usr/share/modem/modem_usb_network.sh $id $at_port $manufacturer "ecm"
|
||||||
if [ "$manufacturer" = "quectel" ]; then
|
|
||||||
procd_append_param command 'ATI'
|
|
||||||
elif [ "$manufacturer" = "fibocom" ]; then
|
|
||||||
procd_append_param command 'AT+GTRNDIS=1,1'
|
|
||||||
fi
|
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
@ -248,30 +256,166 @@ ncm()
|
|||||||
ecm
|
ecm
|
||||||
}
|
}
|
||||||
|
|
||||||
#实例运行状态
|
stop_qmi()
|
||||||
instance_status()
|
|
||||||
{
|
{
|
||||||
#获取modem的实例信息
|
#获取modem的实例信息
|
||||||
local response=$(ubus call service list '{"name": "modem"}')
|
local response=$(ubus call service list '{"name": "modem"}')
|
||||||
local instance_number=$(echo "$response" | jq -r '.modem.instances | length')
|
local instance_number=$(echo "$response" | jq -r '.modem.instances | length')
|
||||||
for i in $(seq 1 $((instance_number))); do
|
for i in $(seq 1 $((instance_number))); do
|
||||||
#获取运行状态和拨号命令
|
#获取拨号命令
|
||||||
local running_status=$(echo "$response" | jq -r '.modem.instances.$i.running')
|
|
||||||
local command=$(echo "$response" | jq -r '.modem.instances.instance$i.command')
|
local command=$(echo "$response" | jq -r '.modem.instances.instance$i.command')
|
||||||
if [ "$running_status" = "$true" ] && [[ "$command" = *"$moblie_net"* ]]; then
|
if [ "$command" = *"$network"* ]; then
|
||||||
return 1
|
local pid=$(echo "$response" | jq -r '.modem.instances.$i.pid')
|
||||||
|
kill $pid >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_gobinet()
|
||||||
|
{
|
||||||
|
#获取AT串口、制造商
|
||||||
|
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||||
|
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||||
|
|
||||||
|
#停止拨号
|
||||||
|
local command="sh /usr/share/modem/modem_at.sh $at_port"
|
||||||
|
if [ "$manufacturer" = "quectel" ]; then
|
||||||
|
$command 'ATI'
|
||||||
|
elif [ "$manufacturer" = "fibocom" ]; then
|
||||||
|
$command 'AT$QCRMCALL=0,1'
|
||||||
|
else
|
||||||
|
$command 'ATI'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_ecm()
|
||||||
|
{
|
||||||
|
#获取AT串口、制造商
|
||||||
|
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||||
|
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||||
|
|
||||||
|
#停止拨号
|
||||||
|
local command="sh /usr/share/modem/modem_at.sh $at_port"
|
||||||
|
if [ "$manufacturer" = "quectel" ]; then
|
||||||
|
$command 'ATI'
|
||||||
|
elif [ "$manufacturer" = "fibocom" ]; then
|
||||||
|
$command 'AT+GTRNDIS=0,1'
|
||||||
|
else
|
||||||
|
$command 'ATI'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_mbim()
|
||||||
|
{
|
||||||
|
stop_qmi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_rndis()
|
||||||
|
{
|
||||||
|
stop_ecm
|
||||||
|
#广和通的rndis和ecm不同,后续再测试
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_ncm()
|
||||||
|
{
|
||||||
|
stop_ecm
|
||||||
|
}
|
||||||
|
|
||||||
|
#获取模块序号
|
||||||
|
# $1:移动网络
|
||||||
|
get_modem_no()
|
||||||
|
{
|
||||||
|
local modem_number=$(uci -q get modem.@global[0].modem_number)
|
||||||
|
echo "modem_number:$modem_number" >> /root/a
|
||||||
|
local modem_network
|
||||||
|
for i in $(seq 0 $((modem_number-1))); do
|
||||||
|
modem_network=$(uci -q get modem.modem$i.network)
|
||||||
|
if [ "$modem_network" = "$1" ]; then
|
||||||
|
#模块序号
|
||||||
|
modem_no=$i
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "modem_no:$modem_no" >> /root/a
|
||||||
|
}
|
||||||
|
|
||||||
|
#获取实例运行状态(未使用)
|
||||||
|
# $1:配置ID
|
||||||
|
get_instance_status()
|
||||||
|
{
|
||||||
|
#获取modem的实例信息
|
||||||
|
local response=$(ubus call service list '{"name": "modem"}')
|
||||||
|
local instance_number=$(echo "$response" | jq -r ".modem.instances | length")
|
||||||
|
for i in $(seq 1 $((instance_number))); do
|
||||||
|
#获取运行状态和拨号命令
|
||||||
|
local running_status=$(echo "$response" | jq -r ".modem.instances.instance$i.running")
|
||||||
|
local command=$(echo "$response" | jq -r ".modem.instances.instance$i.command")
|
||||||
|
if [ "$running_status" = "true" ] && [[ "$command" = *"$network"* ]]; then
|
||||||
|
#查看配置ID是否记录在已运行的文件里
|
||||||
|
local run_config="/tmp/modem/run_config"
|
||||||
|
local run_config_id=$(grep -n "$network" "$run_config" | cut -d ';' -f 2)
|
||||||
|
if [ "$1" = "$run_config_id" ]; then
|
||||||
|
status=2
|
||||||
|
break
|
||||||
|
else
|
||||||
|
status=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#停止拨号
|
||||||
|
# $1:配置ID
|
||||||
|
stop_dial()
|
||||||
|
{
|
||||||
|
local id="$1" #配置ID
|
||||||
|
local network=$(uci -q get modem.$1.network) #移动网络
|
||||||
|
|
||||||
|
#把配置ID从临时列表中移除
|
||||||
|
local run_config="/tmp/modem/run_config"
|
||||||
|
local row_no=$(grep -n "$id" "$run_config" | cut -d ':' -f 1)
|
||||||
|
if [ -z "$row_no" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
#该配置ID在运行,需要删除记录
|
||||||
|
sed -i "$row_no"d $run_config
|
||||||
|
|
||||||
|
#获取模块序号
|
||||||
|
get_modem_no $network
|
||||||
|
#获取模组的拨号模式
|
||||||
|
local mode=$(uci -q get modem.modem$modem_no.mode)
|
||||||
|
|
||||||
|
#根据不同的拨号模式停止拨号
|
||||||
|
if [ "$mode" = "qmi" ]; then
|
||||||
|
stop_qmi
|
||||||
|
elif [ "$mode" = "gobinet" ]; then
|
||||||
|
stop_gobinet
|
||||||
|
elif [ "$mode" = "ecm" ]; then
|
||||||
|
stop_ecm
|
||||||
|
elif [ "$mode" = "mbim" ]; then
|
||||||
|
stop_mbim
|
||||||
|
elif [ "$mode" = "rndis" ]; then
|
||||||
|
stop_rndis
|
||||||
|
elif [ "$mode" = "ncm" ]; then
|
||||||
|
stop_ncm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
dial()
|
dial()
|
||||||
{
|
{
|
||||||
|
local enable #启用
|
||||||
|
local id #ID
|
||||||
|
|
||||||
config_get enable $1 enable
|
config_get enable $1 enable
|
||||||
[ "$enable" = "0" ] && return 0
|
config_get id $1 id
|
||||||
|
[ "$enable" = "0" ] && {
|
||||||
|
stop_dial "$id"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
local remarks #备注
|
local remarks #备注
|
||||||
local moblie_net #移动网络
|
local network #移动网络
|
||||||
local mode #拨号模式
|
|
||||||
local dial_tool #拨号工具
|
local dial_tool #拨号工具
|
||||||
local pdp_type #网络类型
|
local pdp_type #网络类型
|
||||||
local apn
|
local apn
|
||||||
@ -280,8 +424,7 @@ dial()
|
|||||||
local auth
|
local auth
|
||||||
|
|
||||||
config_get remarks $1 remarks
|
config_get remarks $1 remarks
|
||||||
config_get moblie_net $1 moblie_net
|
config_get network $1 network
|
||||||
config_get mode $1 mode
|
|
||||||
config_get dial_tool $1 dial_tool
|
config_get dial_tool $1 dial_tool
|
||||||
config_get pdp_type $1 pdp_type
|
config_get pdp_type $1 pdp_type
|
||||||
config_get apn $1 apn
|
config_get apn $1 apn
|
||||||
@ -289,25 +432,34 @@ dial()
|
|||||||
config_get password $1 password
|
config_get password $1 password
|
||||||
config_get auth $1 auth
|
config_get auth $1 auth
|
||||||
|
|
||||||
#查看移动网络是否已经有实例在运行
|
|
||||||
instance_status
|
|
||||||
[ $? = "1" ] && return 0
|
|
||||||
|
|
||||||
#获取模块序号
|
#获取模块序号
|
||||||
local modem_number=$(uci -q get modem.@global[0].option.modem_number)
|
get_modem_no $network
|
||||||
for i in $(seq 0 $((modem_number-1))); do
|
#获取模组的拨号模式
|
||||||
local net=$(uci -q get modem.modem$i.net)
|
[ -z "$modem_no" ] && return 0
|
||||||
if [ "$net" = "$moblie_net" ]; then
|
local mode=$(uci -q get modem.modem$modem_no.mode)
|
||||||
#模块序号
|
|
||||||
modem_no=$i
|
#查看移动网络是否已经有配置在运行
|
||||||
|
local run_path="/tmp/modem"
|
||||||
|
mkdir -p $run_path
|
||||||
|
local run_config="/tmp/modem/run_config"
|
||||||
|
local row_no=$(grep -n "$network" "$run_config" | cut -d ':' -f 1) #1:wwan0;abc->1
|
||||||
|
if [ -z "$row_no" ]; then #未记录该移动网络
|
||||||
|
#把已运行的配置ID加入到记录中
|
||||||
|
echo "$network;$id" >> "$run_path/run_config"
|
||||||
|
else
|
||||||
|
local run_config_id=$(grep -n "$network" "$run_config" | cut -d ';' -f 2)
|
||||||
|
if [ "$id" != "$run_config_id" ]; then #该移动网络已存在,且已有其他配置运行
|
||||||
|
uci set modem.$1.enable=0
|
||||||
|
uci commit modem
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
#根据不同的拨号模式拨号
|
#根据不同的拨号模式拨号
|
||||||
if [ "$mode" = "qmi" ]; then
|
if [ "$mode" = "qmi" ]; then
|
||||||
qmi
|
qmi
|
||||||
elif [ "$mode" = "gobinet" ]; then
|
elif [ "$mode" = "gobinet" ]; then
|
||||||
gobinet #暂无,同qmi
|
gobinet
|
||||||
elif [ "$mode" = "ecm" ]; then
|
elif [ "$mode" = "ecm" ]; then
|
||||||
ecm
|
ecm
|
||||||
elif [ "$mode" = "mbim" ]; then
|
elif [ "$mode" = "mbim" ]; then
|
||||||
@ -321,39 +473,13 @@ dial()
|
|||||||
# sleep 15
|
# sleep 15
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_dial()
|
|
||||||
{
|
|
||||||
#停止所有拨号
|
|
||||||
config_get enable $1 enable
|
|
||||||
[ "$enable" = "0" ] && {
|
|
||||||
killall quectel-CM >/dev/null 2>&1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#停止单个拨号
|
|
||||||
local moblie_net #移动网络
|
|
||||||
config_get moblie_net $1 moblie_net
|
|
||||||
|
|
||||||
#获取modem的实例信息
|
|
||||||
local response=$(ubus call service list '{"name": "modem"}')
|
|
||||||
local instance_number=$(echo "$response" | jq -r '.modem.instances | length')
|
|
||||||
for i in $(seq 1 $((instance_number))); do
|
|
||||||
#获取拨号命令
|
|
||||||
local command=$(echo "$response" | jq -r '.modem.instances.instance$i.command')
|
|
||||||
if [ "$command" = *"$moblie_net"* ]; then
|
|
||||||
local pid=$(echo "$response" | jq -r '.modem.instances.$i.pid')
|
|
||||||
kill $pid >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
service_triggers()
|
service_triggers()
|
||||||
{
|
{
|
||||||
procd_add_reload_trigger "modem"
|
procd_add_reload_trigger "modem"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
enable=$(uci -q get modem.@global[0].enable)
|
local enable=$(uci -q get modem.@global[0].enable)
|
||||||
if [ "$enable" = "0" ]; then
|
if [ "$enable" = "0" ]; then
|
||||||
stop_service
|
stop_service
|
||||||
else
|
else
|
||||||
@ -364,6 +490,14 @@ start_service() {
|
|||||||
|
|
||||||
stop_service()
|
stop_service()
|
||||||
{
|
{
|
||||||
config_load modem
|
#删除记录文件
|
||||||
config_foreach stop_dial "config"
|
rm -rf /tmp/modem
|
||||||
|
#停止qmi、mbim拨号
|
||||||
|
killall quectel-CM >/dev/null 2>&1
|
||||||
|
#停止ecm、rndis、ncm拨号
|
||||||
|
local modem_number=$(uci -q get modem.@global[0].modem_number)
|
||||||
|
for i in $(seq 0 $((modem_number-1))); do
|
||||||
|
modem_no=$i
|
||||||
|
stop_ecm
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
START=99
|
START=16
|
||||||
|
STOP=13
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
# /bin/sh /usr/share/cpe/rssi &
|
procd_open_instance #启动实例
|
||||||
/bin/sh /usr/share/modem/modem_data &
|
procd_set_param command /bin/sh /usr/share/modem/modem_task.sh
|
||||||
|
procd_set_param respawn # 定义respawn参数,告知procd当task程序退出后尝试进行重启
|
||||||
|
procd_close_instance #关闭实例
|
||||||
}
|
}
|
@ -3,9 +3,11 @@
|
|||||||
uci -q get modem.global >/dev/null || uci -q batch <<-EOF >/dev/null
|
uci -q get modem.global >/dev/null || uci -q batch <<-EOF >/dev/null
|
||||||
set modem.global=global
|
set modem.global=global
|
||||||
set modem.global.enable=1
|
set modem.global.enable=1
|
||||||
|
set modem.global.modem_number=0
|
||||||
commit modem
|
commit modem
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
/etc/init.d/modeminit enable
|
||||||
/etc/init.d/modem enable
|
/etc/init.d/modem enable
|
||||||
|
|
||||||
uci -q batch <<-EOF >/dev/null
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
@ -1,21 +1,123 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
|
||||||
|
#获取拨号模式
|
||||||
|
# $1:AT串口
|
||||||
|
get_fibocom_mode()
|
||||||
|
{
|
||||||
|
local at_port="$1"
|
||||||
|
local 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
|
||||||
|
case "$mode_num" in
|
||||||
|
"17") mode="qmi" ;; #-
|
||||||
|
"31") mode="qmi" ;; #-
|
||||||
|
"32") mode="qmi" ;;
|
||||||
|
"32") mode="gobinet" ;;
|
||||||
|
"18") mode="ecm" ;;
|
||||||
|
"23") mode="ecm" ;; #-
|
||||||
|
"33") mode="ecm" ;; #-
|
||||||
|
"29") mode="mbim" ;; #-
|
||||||
|
"30") mode="mbim" ;;
|
||||||
|
"24") mode="rndis" ;;
|
||||||
|
"18") mode='ncm' ;;
|
||||||
|
"*") mode="$mode_num" ;;
|
||||||
|
esac
|
||||||
|
echo "$mode"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#基本信息
|
||||||
|
fibocom_base_info()
|
||||||
|
{
|
||||||
|
debug "Fibocom base info"
|
||||||
|
|
||||||
|
local at_command="ATI"
|
||||||
|
local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
|
||||||
|
|
||||||
|
#名称
|
||||||
|
name=$(echo "$response" | sed -n '3p' | sed 's/Model: //g' | sed 's/\r//g')
|
||||||
|
#制造商
|
||||||
|
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/Manufacturer: //g' | sed 's/\r//g')
|
||||||
|
#固件版本
|
||||||
|
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
|
||||||
|
|
||||||
|
#拨号模式
|
||||||
|
mode=$(get_fibocom_mode $at_port | tr 'a-z' 'A-Z')
|
||||||
|
|
||||||
|
#温度
|
||||||
|
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
|
||||||
|
temperature="$response$(printf "\xc2\xb0")C"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#SIM卡信息
|
||||||
|
fibocom_sim_info()
|
||||||
|
{
|
||||||
|
debug "Fibocom sim info"
|
||||||
|
|
||||||
|
#ISP(互联网服务提供商)
|
||||||
|
local 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="中国移动"
|
||||||
|
elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then
|
||||||
|
isp="中国联通"
|
||||||
|
elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
|
||||||
|
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')
|
||||||
|
|
||||||
|
#IMSI
|
||||||
|
at_command="AT+CIMI"
|
||||||
|
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
|
||||||
|
|
||||||
|
#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?"
|
||||||
|
phone=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
|
||||||
|
}
|
||||||
|
|
||||||
|
#网络信息
|
||||||
|
fibocom_net_info()
|
||||||
|
{
|
||||||
|
debug "Fibocom net info"
|
||||||
|
|
||||||
|
#Network Type(网络类型)
|
||||||
|
local at_command="AT+PSRAT?"
|
||||||
|
net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/+PSRAT: //g' | sed 's/\r//g')
|
||||||
|
|
||||||
|
#CSQ
|
||||||
|
|
||||||
|
#per(信号强度)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# fibocom获取基站信息
|
# fibocom获取基站信息
|
||||||
Fibocom_Cellinfo()
|
Fibocom_Cellinfo()
|
||||||
{
|
{
|
||||||
#baseinfo.gcom
|
#baseinfo.gcom
|
||||||
OX=$( sh modem_at.sh $at_port "ATI")
|
OX=$( sh $current_dir/modem_at.sh $at_port "ATI")
|
||||||
OX=$( sh modem_at.sh $at_port "AT+CGEQNEG=1")
|
OX=$( sh $current_dir/modem_at.sh $at_port "AT+CGEQNEG=1")
|
||||||
|
|
||||||
#cellinfo0.gcom
|
#cellinfo0.gcom
|
||||||
OX1=$( sh modem_at.sh $at_port "AT+COPS=3,0;+COPS?")
|
# OX1=$( sh $current_dir/modem_at.sh $at_port "AT+COPS=3,0;+COPS?")
|
||||||
OX2=$( sh modem_at.sh $at_port "AT+COPS=3,2;+COPS?")
|
# OX2=$( sh $current_dir/modem_at.sh $at_port "AT+COPS=3,2;+COPS?")
|
||||||
OX=$OX1" "$OX2
|
OX=$OX1" "$OX2
|
||||||
|
|
||||||
#cellinfo.gcom
|
#cellinfo.gcom
|
||||||
OY1=$( sh modem_at.sh $at_port "AT+CREG=2;+CREG?;+CREG=0")
|
OY1=$( sh $current_dir/modem_at.sh $at_port "AT+CREG=2;+CREG?;+CREG=0")
|
||||||
OY2=$( sh modem_at.sh $at_port "AT+CEREG=2;+CEREG?;+CEREG=0")
|
OY2=$( sh $current_dir/modem_at.sh $at_port "AT+CEREG=2;+CEREG?;+CEREG=0")
|
||||||
OY3=$( sh modem_at.sh $at_port "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
|
OY3=$( sh $current_dir/modem_at.sh $at_port "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
|
||||||
OY=$OY1" "$OY2" "$OY3
|
OY=$OY1" "$OY2" "$OY3
|
||||||
|
|
||||||
|
|
||||||
@ -131,42 +233,26 @@ Fibocom_Cellinfo()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
Fibocom_SIMINFO()
|
#获取Fibocom模块信息
|
||||||
{
|
|
||||||
debug "Fibocom_SIMINFO"
|
|
||||||
|
|
||||||
# 获取IMEI
|
|
||||||
IMEI=$( sh modem_at.sh $at_port "AT+CGSN" | sed -n '2p' )
|
|
||||||
# 获取IMSI
|
|
||||||
IMSI=$( sh modem_at.sh $at_port "AT+CIMI" | sed -n '2p' )
|
|
||||||
# 获取ICCID
|
|
||||||
ICCID=$( sh modem_at.sh $at_port "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
|
|
||||||
# 获取电话号码
|
|
||||||
phone=$( sh modem_at.sh $at_port "AT+CNUM" | grep "+CNUM:" )
|
|
||||||
}
|
|
||||||
|
|
||||||
#fibocom查找基站AT
|
|
||||||
# $1:AT串口
|
# $1:AT串口
|
||||||
get_fibocom_data()
|
get_fibocom_info()
|
||||||
{
|
{
|
||||||
debug "get fibocom data"
|
debug "get fibocom info"
|
||||||
#设置AT串口
|
#设置AT串口
|
||||||
at_port=$1
|
at_port=$1
|
||||||
|
|
||||||
|
#基本信息
|
||||||
|
fibocom_base_info
|
||||||
|
#SIM卡信息
|
||||||
|
fibocom_sim_info
|
||||||
|
#网络信息
|
||||||
|
fibocom_net_info
|
||||||
|
|
||||||
# All_CSQ
|
# All_CSQ
|
||||||
|
# Fibocom_Cellinfo
|
||||||
Fibocom_SIMINFO
|
|
||||||
Fibocom_Cellinfo
|
|
||||||
|
|
||||||
#温度
|
|
||||||
OX=$( sh modem_at.sh $at_port "AT+CPMUTEMP")
|
|
||||||
TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
|
|
||||||
if [ -n "$TEMP" ]; then
|
|
||||||
TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#基站信息
|
#基站信息
|
||||||
OX=$( sh modem_at.sh $at_port "AT+CPSI?")
|
OX=$( sh $current_dir/modem_at.sh $at_port "AT+CPSI?")
|
||||||
rec=$(echo "$OX" | grep "+CPSI:")
|
rec=$(echo "$OX" | grep "+CPSI:")
|
||||||
w=$(echo $rec |grep "NO SERVICE"| wc -l)
|
w=$(echo $rec |grep "NO SERVICE"| wc -l)
|
||||||
if [ $w -ge 1 ];then
|
if [ $w -ge 1 ];then
|
||||||
@ -244,7 +330,7 @@ get_fibocom_data()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#CNMP
|
#CNMP
|
||||||
OX=$( sh modem_at.sh $at_port "AT+CNMP?")
|
OX=$( sh $current_dir/modem_at.sh $at_port "AT+CNMP?")
|
||||||
CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
||||||
if [ -n "$CNMP" ]; then
|
if [ -n "$CNMP" ]; then
|
||||||
case $CNMP in
|
case $CNMP in
|
||||||
@ -266,7 +352,7 @@ get_fibocom_data()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# CMGRMI 信息
|
# CMGRMI 信息
|
||||||
OX=$( sh modem_at.sh $at_port "AT+CMGRMI=4")
|
OX=$( sh $current_dir/modem_at.sh $at_port "AT+CMGRMI=4")
|
||||||
CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
|
CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
|
||||||
if [ -n "$CAINFO" ]; then
|
if [ -n "$CAINFO" ]; then
|
||||||
for CASV in $(echo "$CAINFO"); do
|
for CASV in $(echo "$CAINFO"); do
|
||||||
|
27
luci-app-modem/root/usr/share/modem/fibocom_command
Normal file
27
luci-app-modem/root/usr/share/modem/fibocom_command
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
模组信息 > ATI;ATI
|
||||||
|
查询SIM卡状态 > AT+CPIN?;AT+CPIN?
|
||||||
|
查询此时信号强度 > AT+CSQ;AT+CSQ
|
||||||
|
查询网络信息 > AT+COPS?;AT+COPS?
|
||||||
|
查询PDP信息 > AT+CGDCONT?;AT+CGDCONT?
|
||||||
|
最小功能模式 > AT+CFUN=0;AT+CFUN=0
|
||||||
|
全功能模式 > AT+CFUN=1;AT+CFUN=1
|
||||||
|
设置当前使用的为卡1 > AT+GTDUALSIM=0;AT+GTDUALSIM=0
|
||||||
|
设置当前使用的为卡2 > AT+GTDUALSIM=1;AT+GTDUALSIM=1
|
||||||
|
ECM手动拨号 > AT+GTRNDIS=1,1;AT+GTRNDIS=1,1
|
||||||
|
ECM拨号断开 > AT+GTRNDIS=0,1;AT+GTRNDIS=0,1
|
||||||
|
查询当前端口模式 > AT+GTUSBMODE?;AT+GTUSBMODE?
|
||||||
|
QMI/GobiNet拨号 > AT+GTUSBMODE=32;AT+GTUSBMODE=32
|
||||||
|
ECM拨号 > AT+GTUSBMODE=18;AT+GTUSBMODE=18
|
||||||
|
MBIM拨号 > AT+GTUSBMODE=30;AT+GTUSBMODE=30
|
||||||
|
RNDIS拨号 > AT+GTUSBMODE=24;AT+GTUSBMODE=24
|
||||||
|
NCM拨号 > AT+GTUSBMODE=18;AT+GTUSBMODE=18
|
||||||
|
锁4G > AT+GTACT=2;AT+GTACT=2
|
||||||
|
锁5G > AT+GTACT=14;AT+GTACT=14
|
||||||
|
恢复自动搜索网络 > AT+GTACT=20;AT+GTACT=20
|
||||||
|
查询当前连接的网络类型 > AT+PSRAT?;AT+PSRAT?
|
||||||
|
查询模组IMEI > AT+CGSN?;AT+CGSN?
|
||||||
|
查询模组IMEI > AT+GSN?;AT+GSN?
|
||||||
|
更改模组IMEI > AT+GTSN=1,7,"IMEI";AT+GTSN=1,7,"在此设置IMEI"
|
||||||
|
报告一次当前BBIC的温度 > AT+MTSM=1,6;AT+MTSM=1,6
|
||||||
|
报告一次当前射频的温度 > AT+MTSM=1,7;AT+MTSM=1,7
|
||||||
|
重置模组 > AT+CFUN=15;AT+CFUN=15
|
@ -1,166 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
current_dir="$(dirname "$0")"
|
|
||||||
source "$current_dir/modem_debug.sh"
|
|
||||||
source "$current_dir/modem_scan.sh"
|
|
||||||
source "$current_dir/quectel.sh"
|
|
||||||
source "$current_dir/fibocom.sh"
|
|
||||||
source "$current_dir/simcom.sh"
|
|
||||||
|
|
||||||
#初值化数据结构
|
|
||||||
initData()
|
|
||||||
{
|
|
||||||
Date=''
|
|
||||||
CHANNEL="-"
|
|
||||||
ECIO="-"
|
|
||||||
RSCP="-"
|
|
||||||
ECIO1=" "
|
|
||||||
RSCP1=" "
|
|
||||||
NETMODE="-"
|
|
||||||
LBAND="-"
|
|
||||||
PCI="-"
|
|
||||||
CTEMP="-"
|
|
||||||
net_type="-"
|
|
||||||
SINR="-"
|
|
||||||
IMEI='-'
|
|
||||||
IMSI='-'
|
|
||||||
ICCID='-'
|
|
||||||
phone='-'
|
|
||||||
manufacturer=''
|
|
||||||
modem=''
|
|
||||||
}
|
|
||||||
|
|
||||||
#保存模块数据
|
|
||||||
setData()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
echo $modem #'RM520N-GL'
|
|
||||||
echo $manufacturer #制造商
|
|
||||||
# echo '1e0e:9001' #厂商号
|
|
||||||
echo $COPS #运营商
|
|
||||||
echo $at_port #AT串口
|
|
||||||
echo $TEMP #温度
|
|
||||||
echo $mode #拨号模式
|
|
||||||
echo '---------------------------------'
|
|
||||||
echo $IMEI #imei
|
|
||||||
echo $IMSI #imsi
|
|
||||||
echo $ICCID #iccid
|
|
||||||
echo $phone #phone
|
|
||||||
echo '---------------------------------'
|
|
||||||
|
|
||||||
echo $net_type
|
|
||||||
echo $CSQ
|
|
||||||
echo $CSQ_PER
|
|
||||||
echo $CSQ_RSSI
|
|
||||||
echo $ECIO #参考信号接收质量 RSRQ ecio
|
|
||||||
echo $ECIO1 #参考信号接收质量 RSRQ ecio1
|
|
||||||
echo $RSCP #参考信号接收功率 RSRP rscp0
|
|
||||||
echo $RSCP1 #参考信号接收功率 RSRP rscp1
|
|
||||||
echo $SINR #信噪比 SINR rv["sinr"]
|
|
||||||
echo $NETMODE #连接状态监控 rv["netmode"]
|
|
||||||
echo '---------------------------------'
|
|
||||||
|
|
||||||
echo $COPS_MCC #MCC
|
|
||||||
echo $$COPS_MNC #MNC
|
|
||||||
echo $LAC #eNB ID
|
|
||||||
echo '' #LAC_NUM
|
|
||||||
echo $RNC #TAC
|
|
||||||
echo '' #RNC_NUM
|
|
||||||
echo $CID
|
|
||||||
echo '' #CID_NUM
|
|
||||||
echo $LBAND
|
|
||||||
echo $CHANNEL
|
|
||||||
echo $PCI
|
|
||||||
|
|
||||||
echo $Date
|
|
||||||
|
|
||||||
echo $MODTYPE
|
|
||||||
echo $QTEMP
|
|
||||||
|
|
||||||
} > /tmp/modem_cell.file
|
|
||||||
}
|
|
||||||
|
|
||||||
#采集模块数据(暂时设置为单模块信息收集)
|
|
||||||
data_acquisition()
|
|
||||||
{
|
|
||||||
debug "--检查模块的AT串口--"
|
|
||||||
#获取模块AT串口
|
|
||||||
at_port=$(uci -q get modem.modem0.at_port)
|
|
||||||
if [ -z "$at_port" ]; then
|
|
||||||
debug "模块0没有找到AT串口"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
debug "--检查SIM状态--"
|
|
||||||
local sim_status=$(echo `sh modem_at.sh $at_port "AT+CPIN?"`)
|
|
||||||
local sim_error=$(echo "$sim_status" | grep "ERROR")
|
|
||||||
if [ -n "$sim_error" ]; then
|
|
||||||
debug "未插入SIM卡"
|
|
||||||
sleep 5s
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local sim_ready=$(echo "$sim_status" | grep "READY")
|
|
||||||
if [ -n "$sim_ready" ]; then
|
|
||||||
debug "SIM卡正常"
|
|
||||||
else
|
|
||||||
debug "SIM卡被锁定"
|
|
||||||
sleep 5s
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
debug "--根据模块类型开始采集数据--"
|
|
||||||
# 获取模块基本信息
|
|
||||||
modem=$(uci -q get modem.modem0.name) #模块名称
|
|
||||||
manufacturer=$(uci -q get modem.modem0.manufacturer) #制造商
|
|
||||||
mode=$(uci -q get modem.@config[0].mode) #制造商
|
|
||||||
|
|
||||||
#信号获取
|
|
||||||
case $manufacturer in
|
|
||||||
"quectel") get_quectel_data $at_port ;;
|
|
||||||
"fibocom") get_fibocom_data $at_port ;;
|
|
||||||
"simcom") et_simcom_data $at_port ;;
|
|
||||||
"*") debug "未适配该模块" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
#数据采集循环
|
|
||||||
data_acquisition_task()
|
|
||||||
{
|
|
||||||
while true; do
|
|
||||||
enable=$(uci -q get modem.global.enable)
|
|
||||||
if [ "$enable" = "1" ] ;then
|
|
||||||
modem_scan
|
|
||||||
debug "------------------------------开启任务---------------------------"
|
|
||||||
data_acquisition
|
|
||||||
setData
|
|
||||||
debug "------------------------------结束任务---------------------------"
|
|
||||||
fi
|
|
||||||
sleep 10s
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
#扫描并配置模块信息
|
|
||||||
modem_scan
|
|
||||||
sleep 1s
|
|
||||||
|
|
||||||
#初值化模块数据
|
|
||||||
debug "开启数据采集服务"
|
|
||||||
initData
|
|
||||||
debug "初值化数据完成"
|
|
||||||
sleep 1s
|
|
||||||
|
|
||||||
#采集模块数据
|
|
||||||
debug "采集数据"
|
|
||||||
data_acquisition
|
|
||||||
#保存模块数据
|
|
||||||
setData
|
|
||||||
|
|
||||||
#数据采集循环
|
|
||||||
data_acquisition_task
|
|
||||||
|
|
||||||
#移动网络联网检查
|
|
||||||
# checkMobileNetwork
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
@ -1,10 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
source "$current_dir/quectel.sh"
|
||||||
|
source "$current_dir/fibocom.sh"
|
||||||
|
source "$current_dir/simcom.sh"
|
||||||
|
|
||||||
#调试开关
|
#调试开关
|
||||||
# 0关闭
|
# 0关闭
|
||||||
# 1打开
|
# 1打开
|
||||||
# 2输出到文件
|
# 2输出到文件
|
||||||
switch=1
|
switch=0
|
||||||
out_file="/tmp/modem.log" #输出文件
|
out_file="/tmp/modem.log" #输出文件
|
||||||
#日志信息
|
#日志信息
|
||||||
debug()
|
debug()
|
||||||
@ -24,9 +28,32 @@ at()
|
|||||||
{
|
{
|
||||||
local new_str="${2/[$]/$}"
|
local new_str="${2/[$]/$}"
|
||||||
local atCommand="${new_str/\"/\"}"
|
local atCommand="${new_str/\"/\"}"
|
||||||
|
|
||||||
|
#echo
|
||||||
|
# echo -e $2 > $1 2>&1
|
||||||
|
|
||||||
|
#sms_tool
|
||||||
sms_tool -d $1 at $atCommand 2>&1
|
sms_tool -d $1 at $atCommand 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
#测试时打开
|
#测试时打开
|
||||||
# debug $1
|
# debug $1
|
||||||
# at $1 $2
|
# at $1 $2
|
||||||
|
|
||||||
|
#获取模块拨号模式
|
||||||
|
# $1:制造商
|
||||||
|
# $2:AT串口
|
||||||
|
get_mode()
|
||||||
|
{
|
||||||
|
local mode
|
||||||
|
case $1 in
|
||||||
|
"quectel") mode=$(get_quectel_mode "$2") ;;
|
||||||
|
"fibocom") mode=$(get_fibocom_mode "$2") ;;
|
||||||
|
"simcom") mode=$(get_simcom_mode "$2") ;;
|
||||||
|
"*")
|
||||||
|
debug "未适配该模块,尝试使用拨号工具自动拨号"
|
||||||
|
mode="qmi"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "$mode"
|
||||||
|
}
|
165
luci-app-modem/root/usr/share/modem/modem_info.sh
Normal file
165
luci-app-modem/root/usr/share/modem/modem_info.sh
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
source "$current_dir/modem_debug.sh"
|
||||||
|
source "$current_dir/quectel.sh"
|
||||||
|
source "$current_dir/fibocom.sh"
|
||||||
|
source "$current_dir/simcom.sh"
|
||||||
|
|
||||||
|
#初值化数据结构
|
||||||
|
init_modem_info()
|
||||||
|
{
|
||||||
|
#基本信息
|
||||||
|
name='' #名称
|
||||||
|
manufacturer='' #制造商
|
||||||
|
revision='-' #固件版本
|
||||||
|
at_port='-' #AT串口
|
||||||
|
mode='' #拨号模式
|
||||||
|
temperature="NaN $(printf "\xc2\xb0")C" #温度
|
||||||
|
update_time='' #更新时间
|
||||||
|
|
||||||
|
#SIM卡信息
|
||||||
|
isp="-" #运营商(互联网服务提供商)
|
||||||
|
imei='-' #IMEI
|
||||||
|
imsi='-' #IMSI
|
||||||
|
iccid='-' #ICCID
|
||||||
|
phone='-' #SIM卡号码(手机号)
|
||||||
|
|
||||||
|
#信号信息
|
||||||
|
net_type="-" #蜂窝网络类型
|
||||||
|
csq="" #CSQ
|
||||||
|
csq_per=""
|
||||||
|
ssi="" #信号强度
|
||||||
|
rssi="" #信号接收强度 RSSI
|
||||||
|
ECIO="-" #参考信号接收质量 RSRQ ecio
|
||||||
|
ECIO1=" " #参考信号接收质量 RSRQ ecio1
|
||||||
|
RSCP="-" #参考信号接收功率 RSRP rscp0
|
||||||
|
RSCP1=" " #参考信号接收功率 RSRP rscp1
|
||||||
|
SINR="-" #信噪比 SINR rv["sinr"]
|
||||||
|
NETMODE="-" #连接状态监控 rv["netmode"]
|
||||||
|
|
||||||
|
#基站信息
|
||||||
|
MCC=""
|
||||||
|
eNBID=""
|
||||||
|
TAC=""
|
||||||
|
cell_id=""
|
||||||
|
LBAND="-" #频段
|
||||||
|
CHANNEL="-" #频点
|
||||||
|
PCI="-" #物理小区标识
|
||||||
|
qos="" #最大Qos级别
|
||||||
|
}
|
||||||
|
|
||||||
|
#保存模块数据
|
||||||
|
info_to_json()
|
||||||
|
{
|
||||||
|
modem_info="{
|
||||||
|
\"manufacturer\":\"$manufacturer\",
|
||||||
|
\"revision\":\"$revision\",
|
||||||
|
\"at_port\":\"$at_port\",
|
||||||
|
\"mode\":\"$mode\",
|
||||||
|
\"temperature\":\"$temperature\",
|
||||||
|
\"update_time\":\"$update_time\",
|
||||||
|
|
||||||
|
\"isp\":\"$isp\",
|
||||||
|
\"imei\":\"$imei\",
|
||||||
|
\"imsi\":\"$imsi\",
|
||||||
|
\"iccid\":\"$iccid\",
|
||||||
|
\"phone\":\"$phone\",
|
||||||
|
|
||||||
|
\"net_type\":\"$net_type\",
|
||||||
|
\"csq\":\"$csq\"
|
||||||
|
|
||||||
|
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# echo $CSQ_RSSI
|
||||||
|
# echo $ECIO #参考信号接收质量 RSRQ ecio
|
||||||
|
# echo $ECIO1 #参考信号接收质量 RSRQ ecio1
|
||||||
|
# echo $RSCP #参考信号接收功率 RSRP rscp0
|
||||||
|
# echo $RSCP1 #参考信号接收功率 RSRP rscp1
|
||||||
|
# echo $SINR #信噪比 SINR rv["sinr"]
|
||||||
|
# echo $NETMODE #连接状态监控 rv["netmode"]
|
||||||
|
# echo '---------------------------------'
|
||||||
|
# #基站信息
|
||||||
|
# echo $COPS_MCC #MCC
|
||||||
|
# echo $$COPS_MNC #MNC
|
||||||
|
# echo $LAC #eNB ID
|
||||||
|
# echo '' #LAC_NUM
|
||||||
|
# echo $RNC #TAC
|
||||||
|
# echo '' #RNC_NUM
|
||||||
|
# echo $CID
|
||||||
|
# echo '' #CID_NUM
|
||||||
|
# echo $LBAND
|
||||||
|
# echo $CHANNEL
|
||||||
|
# echo $PCI
|
||||||
|
# echo $MODTYPE
|
||||||
|
# echo $QTEMP
|
||||||
|
|
||||||
|
#获取模组信息
|
||||||
|
get_modem_info()
|
||||||
|
{
|
||||||
|
update_time=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
debug "检查模块的AT串口"
|
||||||
|
#获取模块AT串口
|
||||||
|
if [ -z "$at_port" ]; then
|
||||||
|
debug "模块0没有找到AT串口"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug "检查SIM状态"
|
||||||
|
local sim_status=$(echo `sh $current_dir/modem_at.sh $at_port "AT+CPIN?"`)
|
||||||
|
local sim_error=$(echo "$sim_status" | grep "ERROR")
|
||||||
|
if [ -n "$sim_error" ]; then
|
||||||
|
debug "未插入SIM卡"
|
||||||
|
sleep 1s
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
local sim_ready=$(echo "$sim_status" | grep "READY")
|
||||||
|
if [ -n "$sim_ready" ]; then
|
||||||
|
debug "SIM卡正常"
|
||||||
|
else
|
||||||
|
debug "SIM卡被锁定"
|
||||||
|
sleep 1s
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug "根据模块类型开始采集数据"
|
||||||
|
#更多信息获取
|
||||||
|
case $manufacturer in
|
||||||
|
"quectel") get_quectel_info $at_port ;;
|
||||||
|
"fibocom") get_fibocom_info $at_port ;;
|
||||||
|
"simcom") get_simcom_info $at_port ;;
|
||||||
|
"*") debug "未适配该模块" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
#获取更新时间
|
||||||
|
update_time=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
}
|
||||||
|
|
||||||
|
#获取模组数据信息
|
||||||
|
# $1:AT串口
|
||||||
|
# $2:制造商
|
||||||
|
modem_info()
|
||||||
|
{
|
||||||
|
#初值化模组信息
|
||||||
|
debug "初值化模组信息"
|
||||||
|
init_modem_info
|
||||||
|
debug "初值化模组信息完成"
|
||||||
|
|
||||||
|
#获取模组信息
|
||||||
|
at_port=$1
|
||||||
|
manufacturer=$2
|
||||||
|
debug "获取模组信息"
|
||||||
|
get_modem_info
|
||||||
|
|
||||||
|
#整合模块信息
|
||||||
|
info_to_json
|
||||||
|
echo $modem_info
|
||||||
|
|
||||||
|
#移动网络联网检查
|
||||||
|
# checkMobileNetwork
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_info $1 $2
|
@ -1,6 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
source "$current_dir/modem_debug.sh"
|
||||||
|
|
||||||
|
#获取USB串口总线地址
|
||||||
|
# $1:USB串口
|
||||||
|
getUSBDeviceBusPath()
|
||||||
|
{
|
||||||
|
local device_name="$(basename "$1")"
|
||||||
|
local device_path="$(find /sys/class/ -name $device_name)"
|
||||||
|
local device_physical_path="$(readlink -f $device_path/device/)"
|
||||||
|
|
||||||
|
#获取父路径的上两层
|
||||||
|
local tmp=$(dirname "$device_physical_path")
|
||||||
|
local device_bus_path=$(dirname $tmp)
|
||||||
|
|
||||||
|
echo $device_bus_path
|
||||||
|
}
|
||||||
|
|
||||||
#获取设备总线地址
|
#获取设备总线地址
|
||||||
|
# $1:网络设备或PCIE串口
|
||||||
getDeviceBusPath()
|
getDeviceBusPath()
|
||||||
{
|
{
|
||||||
local device_name="$(basename "$1")"
|
local device_name="$(basename "$1")"
|
||||||
@ -11,21 +29,27 @@ getDeviceBusPath()
|
|||||||
if [ "$device_name" != "mhi_BHI" ]; then #未考虑多个mhi_BHI的情况
|
if [ "$device_name" != "mhi_BHI" ]; then #未考虑多个mhi_BHI的情况
|
||||||
device_bus_path=$(dirname "$device_physical_path")
|
device_bus_path=$(dirname "$device_physical_path")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $device_bus_path
|
echo $device_bus_path
|
||||||
}
|
}
|
||||||
|
|
||||||
#设置模块配置
|
#设置模块配置
|
||||||
# $1:模块序号
|
# $1:模块序号
|
||||||
# $2:设备(设备节点)
|
# $2:设备数据接口
|
||||||
# $3:设备数据接口
|
# $3:总线地址
|
||||||
# $4:总线地址
|
|
||||||
setModemConfig()
|
setModemConfig()
|
||||||
{
|
{
|
||||||
|
#判断地址是否为net
|
||||||
|
local path=$(basename "$3")
|
||||||
|
if [ "$path" = "net" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
#处理获取到的地址
|
#处理获取到的地址
|
||||||
# local substr="${4/\/sys\/devices\//}" #x86平台,替换掉/sys/devices/
|
# local substr="${3/\/sys\/devices\//}" #x86平台,替换掉/sys/devices/
|
||||||
# local substr="${4/\/sys\/devices\/platform\//}" #arm平台,替换掉/sys/devices/platform/
|
# local substr="${3/\/sys\/devices\/platform\//}" #arm平台,替换掉/sys/devices/platform/
|
||||||
# local substr="${4/\/sys\/devices\/platform\/soc\//}" #arm平台,替换掉/sys/devices/platform/soc/
|
# local substr="${3/\/sys\/devices\/platform\/soc\//}" #arm平台,替换掉/sys/devices/platform/soc/
|
||||||
local substr=$4 #路径存在不同,暂不处理
|
local substr=$3 #路径存在不同,暂不处理
|
||||||
|
|
||||||
#获取网络接口
|
#获取网络接口
|
||||||
local net_path="$(find $substr -name net | sed -n '1p')"
|
local net_path="$(find $substr -name net | sed -n '1p')"
|
||||||
@ -35,36 +59,19 @@ setModemConfig()
|
|||||||
local net_count="$(find $substr -name net | wc -l)"
|
local net_count="$(find $substr -name net | wc -l)"
|
||||||
if [ "$net_count" = "2" ]; then
|
if [ "$net_count" = "2" ]; then
|
||||||
net_net_interface_path="$(find $substr -name net | sed -n '2p')"
|
net_net_interface_path="$(find $substr -name net | sed -n '2p')"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
local net=$(ls $net_path)
|
local network=$(ls $net_path)
|
||||||
local net_interface=$(ls $net_net_interface_path)
|
local network_interface=$(ls $net_net_interface_path)
|
||||||
|
|
||||||
#设置配置
|
#设置配置
|
||||||
uci set modem.modem$1="modem-device"
|
uci set modem.modem$1="modem-device"
|
||||||
uci set modem.modem$1.device_node="$2"
|
uci set modem.modem$1.data_interface="$2"
|
||||||
uci set modem.modem$1.data_interface="$3"
|
|
||||||
uci set modem.modem$1.path="$substr"
|
uci set modem.modem$1.path="$substr"
|
||||||
uci set modem.modem$1.net="$net"
|
uci set modem.modem$1.network="$network"
|
||||||
uci set modem.modem$1.net_interface="$net_interface"
|
uci set modem.modem$1.network_interface="$network_interface"
|
||||||
}
|
|
||||||
|
|
||||||
#设置模块网络接口
|
#增加模组计数
|
||||||
# $1:模块序号
|
modem_count=$((modem_count + 1))
|
||||||
# $2:总线地址
|
|
||||||
setModemNet()
|
|
||||||
{
|
|
||||||
local net_count="$(find $2 -name net | wc -l)"
|
|
||||||
local net_path
|
|
||||||
if [ "$net_count" = "1" ]; then
|
|
||||||
net_path="$(find $2 -name net | sed -n '1p')"
|
|
||||||
elif [ "$net_count" = "2" ]; then
|
|
||||||
net_path="$(find $2 -name net | sed -n '2p')"
|
|
||||||
fi
|
|
||||||
local net=$(ls $net_path)
|
|
||||||
|
|
||||||
#设置配置
|
|
||||||
uci set modem.modem$1.net="$net"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#设置模块串口配置
|
#设置模块串口配置
|
||||||
@ -86,10 +93,11 @@ setPortConfig()
|
|||||||
#添加新的串口
|
#添加新的串口
|
||||||
uci add_list modem.modem$i.ports="$2"
|
uci add_list modem.modem$i.ports="$2"
|
||||||
#判断是不是AT串口
|
#判断是不是AT串口
|
||||||
local result=$(sh modem_at.sh $2 "ATI")
|
local result=$(sh $current_dir/modem_at.sh $2 "ATI")
|
||||||
local str1="No response from modem."
|
local str1="No" #No response from modem.
|
||||||
local str2="failed"
|
local str2="failed"
|
||||||
if [ "$result" != "$str1" ] && [[ "$result" != *"failed"* ]]; then
|
if [[ "$result" != *"$str1"* ]] && [[ "$result" != *"$str2"* ]]; then
|
||||||
|
#原先的AT串口会被覆盖掉(是否需要加判断)
|
||||||
uci set modem.modem$i.at_port="$2"
|
uci set modem.modem$i.at_port="$2"
|
||||||
setModemInfoConfig $i $2
|
setModemInfoConfig $i $2
|
||||||
fi
|
fi
|
||||||
@ -107,19 +115,19 @@ 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_info_file")
|
local line_count=$(wc -l < "$modem_support_file")
|
||||||
local line_context
|
local line_context
|
||||||
for i in $(seq 1 $(($line_count))); do
|
for i in $(seq 1 $(($line_count))); do
|
||||||
|
|
||||||
#获取一行的内容
|
#获取一行的内容
|
||||||
local line_context=$(sed -n $i'p' "$modem_info_file")
|
local line_context=$(sed -n $i'p' "$modem_support_file")
|
||||||
#获取数据接口内容
|
#获取数据接口内容
|
||||||
local data_interface_info=$(echo "$line_context" | cut -d ";" -f 3)
|
local data_interface_info=$(echo "$line_context" | cut -d ";" -f 3)
|
||||||
if [ "$data_interface" = "$data_interface_info" ]; then
|
if [ "$data_interface" = "$data_interface_info" ]; then
|
||||||
#获取模块名
|
#获取模块名
|
||||||
local modem_name=$(echo "$line_context" | cut -d ";" -f 2)
|
local modem_name=$(echo "$line_context" | cut -d ";" -f 2)
|
||||||
#获取AT命令返回的内容
|
#获取AT命令返回的内容
|
||||||
local at_result=$(echo `sh modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
|
local at_result=$(echo `sh $current_dir/modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
|
||||||
if [[ "$at_result" = *"$modem_name"* ]]; then
|
if [[ "$at_result" = *"$modem_name"* ]]; then
|
||||||
#设置模块名
|
#设置模块名
|
||||||
uci set modem.modem$1.name="$modem_name"
|
uci set modem.modem$1.name="$modem_name"
|
||||||
@ -128,11 +136,15 @@ setModemInfoConfig()
|
|||||||
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
||||||
uci set modem.modem$1.manufacturer="$manufacturer"
|
uci set modem.modem$1.manufacturer="$manufacturer"
|
||||||
|
|
||||||
#设置拨号模式
|
#设置当前的拨号模式
|
||||||
|
local mode=$(get_mode $manufacturer $2)
|
||||||
|
uci set modem.modem$1.mode="$mode"
|
||||||
|
|
||||||
|
#设置支持的拨号模式
|
||||||
local modes=$(echo "$line_context" | cut -d ";" -f 4 | tr ',' ' ')
|
local modes=$(echo "$line_context" | cut -d ";" -f 4 | tr ',' ' ')
|
||||||
|
|
||||||
#删除原来的拨号模式列表
|
#删除原来的拨号模式列表
|
||||||
uci del modem.modem$1.modes
|
uci -q del modem.modem$1.modes
|
||||||
#添加新的拨号模式列表
|
#添加新的拨号模式列表
|
||||||
for mode in $modes; do
|
for mode in $modes; do
|
||||||
uci add_list modem.modem$1.modes="$mode"
|
uci add_list modem.modem$1.modes="$mode"
|
||||||
@ -149,7 +161,7 @@ setModemInfoConfig()
|
|||||||
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
||||||
uci set modem.modem$1.manufacturer="$manufacturer"
|
uci set modem.modem$1.manufacturer="$manufacturer"
|
||||||
#删除原来的拨号模式列表
|
#删除原来的拨号模式列表
|
||||||
uci del modem.modem$1.modes
|
uci -q del modem.modem$1.modes
|
||||||
#添加新的拨号模式列表
|
#添加新的拨号模式列表
|
||||||
for mode in $modes; do
|
for mode in $modes; do
|
||||||
uci add_list modem.modem$1.modes="$mode"
|
uci add_list modem.modem$1.modes="$mode"
|
||||||
@ -164,12 +176,19 @@ setModemInfoConfig()
|
|||||||
setModemCount()
|
setModemCount()
|
||||||
{
|
{
|
||||||
uci set modem.global.modem_number="$modem_count"
|
uci set modem.global.modem_number="$modem_count"
|
||||||
|
|
||||||
|
#数量为0时,清空模块列表
|
||||||
|
if [ "$modem_count" = "0" ]; then
|
||||||
|
for i in $(seq 0 $((modem_count-1))); do
|
||||||
|
uci -q del modem.modem$i
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#模块计数
|
#模块计数
|
||||||
modem_count=0
|
modem_count=0
|
||||||
#模块信息文件
|
#模块支持文件
|
||||||
modem_info_file="modem_info"
|
modem_support_file="$current_dir/modem_support"
|
||||||
#设置模块信息
|
#设置模块信息
|
||||||
modem_scan()
|
modem_scan()
|
||||||
{
|
{
|
||||||
@ -177,49 +196,50 @@ modem_scan()
|
|||||||
modem_count=0
|
modem_count=0
|
||||||
########设置模块基本信息########
|
########设置模块基本信息########
|
||||||
#USB
|
#USB
|
||||||
local usb_devices=$(ls /dev/cdc-wdm*)
|
local usb_network=$(find /sys/class/net -name usb*)
|
||||||
for device in $usb_devices; do
|
for network in $usb_network; do
|
||||||
local usb_device_bus_path=$(getDeviceBusPath $device)
|
local usb_device_bus_path=$(getDeviceBusPath $network)
|
||||||
setModemConfig $modem_count $device "usb" $usb_device_bus_path
|
setModemConfig $modem_count "usb" $usb_device_bus_path
|
||||||
modem_count=$((modem_count + 1))
|
done
|
||||||
|
local usb_network=$(find /sys/class/net -name wwan*)
|
||||||
|
for network in $usb_network; do
|
||||||
|
local usb_device_bus_path=$(getDeviceBusPath $network)
|
||||||
|
setModemConfig $modem_count "usb" $usb_device_bus_path
|
||||||
done
|
done
|
||||||
#PCIE
|
#PCIE
|
||||||
local pcie_devices=$(ls /dev/mhi_QMI*)
|
local pcie_network=$(find /sys/class/net -name mhi_hwip*) #(通用mhi驱动)
|
||||||
for device in $pcie_devices; do
|
for network in $pcie_network; do
|
||||||
local pcie_device_bus_path=$(getDeviceBusPath $device)
|
local pcie_device_bus_path=$(getDeviceBusPath $network)
|
||||||
setModemConfig $modem_count $device "pcie" $pcie_device_bus_path
|
setModemConfig $modem_count "pcie" $pcie_device_bus_path
|
||||||
modem_count=$((modem_count + 1))
|
done
|
||||||
|
local pcie_network=$(find /sys/class/net -name rmnet_mhi*) #(制造商mhi驱动)
|
||||||
|
for network in $pcie_network; do
|
||||||
|
local pcie_device_bus_path=$(getDeviceBusPath $network)
|
||||||
|
setModemConfig $modem_count "pcie" $pcie_device_bus_path
|
||||||
done
|
done
|
||||||
|
|
||||||
#写入到配置中
|
|
||||||
# uci commit modem
|
|
||||||
|
|
||||||
########设置模块串口########
|
########设置模块串口########
|
||||||
#清除原串口配置
|
#清除原串口配置
|
||||||
for i in $(seq 0 $((modem_count-1))); do
|
for i in $(seq 0 $((modem_count-1))); do
|
||||||
uci del modem.modem$i.ports
|
uci -q del modem.modem$i.ports
|
||||||
done
|
done
|
||||||
#USB串口
|
#USB串口
|
||||||
local usb_port=$(ls /dev/ttyUSB*)
|
local usb_port=$(find /dev -name ttyUSB*)
|
||||||
for port in $usb_port; do
|
for port in $usb_port; do
|
||||||
local device_node=$(uci -q get modem.modem$i.device_node)
|
local usb_port_device_bus_path=$(getUSBDeviceBusPath $port)
|
||||||
if [ "$port" = "$device_node" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
local usb_port_device_bus_path=$(getDeviceBusPath $port)
|
|
||||||
setPortConfig $usb_port_device_bus_path $port
|
setPortConfig $usb_port_device_bus_path $port
|
||||||
done
|
done
|
||||||
#PCIE串口
|
#PCIE串口
|
||||||
local pcie_port=$(ls /dev/mhi*)
|
local pcie_port=$(find /dev -name wwan*)
|
||||||
|
for port in $pcie_port; do
|
||||||
|
local pcie_port_device_bus_path=$(getDeviceBusPath $port)
|
||||||
|
setPortConfig $pcie_port_device_bus_path $port
|
||||||
|
done
|
||||||
|
local pcie_port=$(find /dev -name mhi*)
|
||||||
for port in $pcie_port; do
|
for port in $pcie_port; do
|
||||||
local device_node=$(uci -q get modem.modem$i.device_node)
|
|
||||||
if [ "$port" = "$device_node" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
local pcie_port_device_bus_path=$(getDeviceBusPath $port)
|
local pcie_port_device_bus_path=$(getDeviceBusPath $port)
|
||||||
setPortConfig $pcie_port_device_bus_path $port
|
setPortConfig $pcie_port_device_bus_path $port
|
||||||
done
|
done
|
||||||
|
|
||||||
########设置模块数量########
|
########设置模块数量########
|
||||||
setModemCount
|
setModemCount
|
||||||
|
|
||||||
|
@ -5,5 +5,6 @@ quectel;rm500q-gl;pcie;qmi,gobinet,ecm,mbim,rndis,ncm
|
|||||||
fibocom;fm650-cn;usb;ecm,mbim,rndis,ncm
|
fibocom;fm650-cn;usb;ecm,mbim,rndis,ncm
|
||||||
fibocom;fm150-ae;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
fibocom;fm150-ae;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||||
fibocom;fm150-ae;pcie;qmi
|
fibocom;fm150-ae;pcie;qmi
|
||||||
|
fibocom;fm160-cn;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||||
unknown;unknown;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
unknown;unknown;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||||
unknown;unknown;pcie;qmi,gobinet,mbim
|
unknown;unknown;pcie;qmi,gobinet,mbim
|
21
luci-app-modem/root/usr/share/modem/modem_task.sh
Normal file
21
luci-app-modem/root/usr/share/modem/modem_task.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
source "$current_dir/modem_debug.sh"
|
||||||
|
source "$current_dir/modem_scan.sh"
|
||||||
|
|
||||||
|
#模组扫描任务
|
||||||
|
modem_scan_task()
|
||||||
|
{
|
||||||
|
while true; do
|
||||||
|
enable=$(uci -q get modem.@global[0].enable)
|
||||||
|
if [ "$enable" = "1" ] ;then
|
||||||
|
#扫描模块
|
||||||
|
debug "开启模块扫描任务"
|
||||||
|
modem_scan
|
||||||
|
debug "结束模块扫描任务"
|
||||||
|
fi
|
||||||
|
sleep 10s
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_scan_task
|
76
luci-app-modem/root/usr/share/modem/modem_usb_network.sh
Normal file
76
luci-app-modem/root/usr/share/modem/modem_usb_network.sh
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
source "$current_dir/modem_debug.sh"
|
||||||
|
source "$current_dir/modem_scan.sh"
|
||||||
|
|
||||||
|
#拨号
|
||||||
|
# $1:AT串口
|
||||||
|
# $2:制造商
|
||||||
|
ecm_dial()
|
||||||
|
{
|
||||||
|
#拨号
|
||||||
|
local manufacturer=$2
|
||||||
|
local at_command
|
||||||
|
if [ "$manufacturer" = "quectel" ]; then
|
||||||
|
at_command='ATI'
|
||||||
|
elif [ "$manufacturer" = "fibocom" ]; then
|
||||||
|
at_command='AT+GTRNDIS=1,1'
|
||||||
|
else
|
||||||
|
at_command='ATI'
|
||||||
|
fi
|
||||||
|
sh "$current_dir/modem_at.sh" $1 $at_command
|
||||||
|
}
|
||||||
|
|
||||||
|
#拨号
|
||||||
|
# $1:AT串口
|
||||||
|
# $2:制造商
|
||||||
|
gobinet_dial()
|
||||||
|
{
|
||||||
|
#拨号
|
||||||
|
local manufacturer=$2
|
||||||
|
local at_command
|
||||||
|
if [ "$manufacturer" = "quectel" ]; then
|
||||||
|
at_command='ATI'
|
||||||
|
elif [ "$manufacturer" = "fibocom" ]; then
|
||||||
|
at_command='AT$QCRMCALL=1,1'
|
||||||
|
else
|
||||||
|
at_command='ATI'
|
||||||
|
fi
|
||||||
|
sh "$current_dir/modem_at.sh" $1 $at_command
|
||||||
|
}
|
||||||
|
|
||||||
|
#检查模组网络连接
|
||||||
|
# $1:配置ID
|
||||||
|
# $2:AT串口
|
||||||
|
# $3:制造商
|
||||||
|
# $4:拨号模式
|
||||||
|
modem_network_task()
|
||||||
|
{
|
||||||
|
while true; do
|
||||||
|
local enable=$(uci -q get modem.@global[0].enable)
|
||||||
|
if [ "$enable" != "1" ] ;then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
enable=$(uci -q get modem.$1.enable)
|
||||||
|
if [ "$enable" != "1" ] ;then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
#网络连接检查
|
||||||
|
debug "开启网络连接检查任务"
|
||||||
|
local at_port=$2
|
||||||
|
local at_command="AT+COPS?"
|
||||||
|
local connect_status=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p')
|
||||||
|
if [ "$connect_status" = "0" ]; then
|
||||||
|
case "$4" in
|
||||||
|
"ecm") ecm_dial $at_port $3 ;;
|
||||||
|
"gobinet") gobinet_dial $at_port $3 ;;
|
||||||
|
"*") ecm_dial $at_port $3 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
debug "结束网络连接检查任务"
|
||||||
|
sleep 10s
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_network_task $1 $2 $3 $4
|
@ -1,4 +1,114 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
current_dir="$(dirname "$0")"
|
||||||
|
|
||||||
|
#获取拨号模式
|
||||||
|
# $1:AT串口
|
||||||
|
get_quectel_mode()
|
||||||
|
{
|
||||||
|
local at_port="$1"
|
||||||
|
local at_command='AT+QCFG="usbnet"'
|
||||||
|
local mode_num=$(echo "$response" | sed -n '2p' | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
|
||||||
|
|
||||||
|
local mode
|
||||||
|
case "$mode_num" in
|
||||||
|
"0") mode="qmi" ;;
|
||||||
|
# "0") mode="gobinet" ;;
|
||||||
|
"1") mode="ecm" ;;
|
||||||
|
"2") mode="mbim" ;;
|
||||||
|
"3") mode="rndis" ;;
|
||||||
|
"5") mode='ncm' ;;
|
||||||
|
"*") mode="$mode_num" ;;
|
||||||
|
esac
|
||||||
|
echo "$mode"
|
||||||
|
}
|
||||||
|
|
||||||
|
#基本信息
|
||||||
|
quectel_base_info()
|
||||||
|
{
|
||||||
|
debug "Quectel base info"
|
||||||
|
|
||||||
|
local at_command="ATI"
|
||||||
|
local response=$(sh $current_dir/modem_at.sh $at_port $at_command)
|
||||||
|
|
||||||
|
#名称
|
||||||
|
name=$(echo "$response" | sed -n '3p' | sed 's/\r//g')
|
||||||
|
#制造商
|
||||||
|
manufacturer=$(echo "$response" | sed -n '2p' | sed 's/\r//g')
|
||||||
|
#固件版本
|
||||||
|
revision=$(echo "$response" | sed -n '4p' | sed 's/Revision: //g' | sed 's/\r//g')
|
||||||
|
|
||||||
|
#拨号模式
|
||||||
|
mode=$(get_quectel_mode $at_port | tr 'a-z' 'A-Z')
|
||||||
|
|
||||||
|
#温度
|
||||||
|
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
|
||||||
|
temperature="$response$(printf "\xc2\xb0")C"
|
||||||
|
fi
|
||||||
|
# response=$(sh $current_dir/modem_at.sh $at_port $at_command | grep "+QTEMP:")
|
||||||
|
# QTEMP=$(echo $response | grep -o -i "+QTEMP: [0-9]\{1,3\}")
|
||||||
|
# if [ -z "$QTEMP" ]; then
|
||||||
|
# QTEMP=$(echo $response | grep -o -i "+QTEMP:[ ]\?\"XO[_-]THERM[_-][^,]\+,[\"]\?[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
||||||
|
# fi
|
||||||
|
# if [ -z "$QTEMP" ]; then
|
||||||
|
# QTEMP=$(echo $response | grep -o -i "+QTEMP:[ ]\?\"MDM-CORE-USR.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
||||||
|
# fi
|
||||||
|
# if [ -z "$QTEMP" ]; then
|
||||||
|
# QTEMP=$(echo $response | grep -o -i "+QTEMP:[ ]\?\"MDMSS.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
||||||
|
# fi
|
||||||
|
# if [ -n "$QTEMP" ]; then
|
||||||
|
# CTEMP=$(echo $QTEMP | grep -o -i "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C"
|
||||||
|
# fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#SIM卡信息
|
||||||
|
quectel_sim_info()
|
||||||
|
{
|
||||||
|
debug "Quectel sim info"
|
||||||
|
|
||||||
|
#ISP(互联网服务提供商)
|
||||||
|
local 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="中国移动"
|
||||||
|
elif [ "$isp" = "CHN-UNICOM" ] || [ "$isp" = "UNICOM" ] || [ "$isp" = "46001" ]; then
|
||||||
|
isp="中国联通"
|
||||||
|
elif [ "$isp" = "CHN-CT" ] || [ "$isp" = "CT" ] || [ "$isp" = "46011" ]; then
|
||||||
|
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')
|
||||||
|
|
||||||
|
#IMSI
|
||||||
|
at_command="AT+CIMI"
|
||||||
|
imsi=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | sed 's/\r//g')
|
||||||
|
|
||||||
|
#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"
|
||||||
|
phone=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $4}')
|
||||||
|
}
|
||||||
|
|
||||||
|
#网络信息
|
||||||
|
quectel_net_info()
|
||||||
|
{
|
||||||
|
debug "Quectel net info"
|
||||||
|
|
||||||
|
#Network Type(网络类型)
|
||||||
|
# local at_command="AT+COPS?"
|
||||||
|
local at_command="AT+QNWINFO"
|
||||||
|
net_type=$(sh $current_dir/modem_at.sh $at_port $at_command | sed -n '2p' | awk -F'"' '{print $2}')
|
||||||
|
|
||||||
|
#CSQ
|
||||||
|
#per(信号强度)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#quectel
|
#quectel
|
||||||
lte_bw() {
|
lte_bw() {
|
||||||
@ -48,19 +158,6 @@ All_CSQ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
Quectel_SIMINFO()
|
|
||||||
{
|
|
||||||
debug "Quectel_SIMINFO"
|
|
||||||
# 获取IMEI
|
|
||||||
IMEI=$( sh modem_at.sh $at_port "AT+CGSN" | sed -n '2p' )
|
|
||||||
# 获取IMSI
|
|
||||||
IMSI=$( sh modem_at.sh $at_port "AT+CIMI" | sed -n '2p' )
|
|
||||||
# 获取ICCID
|
|
||||||
ICCID=$( sh modem_at.sh $at_port "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
|
|
||||||
# 获取电话号码
|
|
||||||
phone=$( sh modem_at.sh $at_port "AT+CNUM" | grep "+CNUM:" )
|
|
||||||
|
|
||||||
}
|
|
||||||
# SIMCOM获取基站信息
|
# SIMCOM获取基站信息
|
||||||
Quectel_Cellinfo()
|
Quectel_Cellinfo()
|
||||||
{
|
{
|
||||||
@ -189,18 +286,25 @@ Quectel_Cellinfo()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#Quectel公司查找基站AT
|
#获取Quectel模块信息
|
||||||
# $1:AT串口
|
# $1:AT串口
|
||||||
get_quectel_data()
|
get_quectel_info()
|
||||||
{
|
{
|
||||||
debug "get quectel data"
|
debug "get quectel info"
|
||||||
#设置AT串口
|
#设置AT串口
|
||||||
at_port=$1
|
at_port=$1
|
||||||
|
|
||||||
Quectel_SIMINFO
|
#基本信息
|
||||||
All_CSQ
|
quectel_base_info
|
||||||
|
#SIM卡信息
|
||||||
|
quectel_sim_info
|
||||||
|
#网络信息
|
||||||
|
quectel_net_info
|
||||||
|
|
||||||
Quectel_Cellinfo
|
return
|
||||||
|
# All_CSQ
|
||||||
|
|
||||||
|
# Quectel_Cellinfo
|
||||||
|
|
||||||
#
|
#
|
||||||
OX=$( sh modem_at.sh $at_port 'AT+QENG="servingcell"' | grep "+QENG:" )
|
OX=$( sh modem_at.sh $at_port 'AT+QENG="servingcell"' | grep "+QENG:" )
|
||||||
@ -435,24 +539,6 @@ get_quectel_data()
|
|||||||
OX=$( sh modem_at.sh $at_port 'AT+QNWPREFCFG="mode_pref"' | grep "+QNWPREFCFG:" )
|
OX=$( sh modem_at.sh $at_port 'AT+QNWPREFCFG="mode_pref"' | grep "+QNWPREFCFG:" )
|
||||||
QNWP=$(echo $OX | grep -o -i "+QNWPREFCFG: \"MODE_PREF\",[A-Z5:]\+" | cut -d, -f2)
|
QNWP=$(echo $OX | grep -o -i "+QNWPREFCFG: \"MODE_PREF\",[A-Z5:]\+" | cut -d, -f2)
|
||||||
|
|
||||||
#温度
|
|
||||||
OX=$( sh modem_at.sh $at_port 'AT+QTEMP' | grep "+QTEMP:" )
|
|
||||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP: [0-9]\{1,3\}")
|
|
||||||
if [ -z "$QTEMP" ]; then
|
|
||||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"XO[_-]THERM[_-][^,]\+,[\"]\?[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
|
||||||
fi
|
|
||||||
if [ -z "$QTEMP" ]; then
|
|
||||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDM-CORE-USR.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
|
||||||
fi
|
|
||||||
if [ -z "$QTEMP" ]; then
|
|
||||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDMSS.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
|
||||||
fi
|
|
||||||
if [ -n "$QTEMP" ]; then
|
|
||||||
CTEMP=$(echo $QTEMP | grep -o -i "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
OX=$( sh modem_at.sh $at_port "AT+QRSRP" | grep "+QRSRP:" )
|
OX=$( sh modem_at.sh $at_port "AT+QRSRP" | grep "+QRSRP:" )
|
||||||
QRSRP=$(echo "$OX" | grep -o -i "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*")
|
QRSRP=$(echo "$OX" | grep -o -i "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*")
|
||||||
|
28
luci-app-modem/root/usr/share/modem/quectel_command
Normal file
28
luci-app-modem/root/usr/share/modem/quectel_command
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
模组信息 > ATI;ATI
|
||||||
|
查询SIM卡状态 > AT+CPIN?;AT+CPIN?
|
||||||
|
查询此时信号强度 > AT+CSQ;AT+CSQ
|
||||||
|
查询网络信息 > AT+COPS?;AT+COPS?
|
||||||
|
查询PDP信息 > AT+CGDCONT?;AT+CGDCONT?
|
||||||
|
最小功能模式 > AT+CFUN=0;AT+CFUN=0
|
||||||
|
全功能模式 > AT+CFUN=1;AT+CFUN=1
|
||||||
|
SIM卡状态上报 > AT+QSIMSTAT?;AT+QSIMSTAT?
|
||||||
|
设置当前使用的为卡1 > AT+QUIMSLOT=1;AT+QUIMSLOT=1
|
||||||
|
设置当前使用的为卡2 > AT+QUIMSLOT=2;AT+QUIMSLOT=2
|
||||||
|
查询网络信息 > AT+QNWINFO;AT+QNWINFO
|
||||||
|
查询载波聚合参数 > AT+QCAINFO;AT+QCAINFO
|
||||||
|
查询当前拨号模式 > AT+QCFG="usbnet";AT+QCFG="usbnet"
|
||||||
|
QMI/GobiNet拨号 > AT+QCFG="usbnet",0;AT+QCFG="usbnet",0
|
||||||
|
ECM拨号 > AT+QCFG="usbnet",1;AT+QCFG="usbnet",1
|
||||||
|
MBIM拨号 > AT+QCFG="usbnet",2;AT+QCFG="usbnet",2
|
||||||
|
RNDIS拨号 > AT+QCFG="usbnet",3;AT+QCFG="usbnet",3
|
||||||
|
NCM拨号 > AT+QCFG="usbnet",5;AT+QCFG="usbnet",5
|
||||||
|
锁4G > AT+QNWPREFCFG="mode_pref",LTE;AT+QNWPREFCFG="mode_pref",LTE
|
||||||
|
锁5G > AT+QNWPREFCFG="mode_pref",NR5G;AT+QNWPREFCFG="mode_pref",NR5G
|
||||||
|
恢复自动搜索网络 > AT+QNWPREFCFG="mode_pref",AUTO;AT+QNWPREFCFG="mode_pref",AUTO
|
||||||
|
查询模组IMEI > AT+CGSN;AT+CGSN
|
||||||
|
查询模组IMEI > AT+GSN;AT+GSN
|
||||||
|
更改模组IMEI > AT+EGMR=1,7,"IMEI";AT+EGMR=1,7,"在此设置IMEI"
|
||||||
|
获取模组温度 > AT+QTEMP;AT+QTEMP
|
||||||
|
切换为USB通信端口 > AT+QCFG="data_interface",0,0;AT+QCFG="data_interface",0,0
|
||||||
|
切换为PCIE通信端口 > AT+QCFG="data_interface",1,0;AT+QCFG="data_interface",1,0
|
||||||
|
重置模组 > AT+CFUN=1,1;AT+CFUN=1,1
|
Loading…
x
Reference in New Issue
Block a user