更新log日志功能,更新插件信息页面,优化拨号连接,优化界面显示

This commit is contained in:
ling 2024-04-21 20:22:02 +08:00
parent cc5bb96750
commit 74a15e63dd
15 changed files with 1401 additions and 442 deletions

View File

@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-modem PKG_NAME:=luci-app-modem
LUCI_TITLE:=LuCI support for Modem LUCI_TITLE:=LuCI support for Modem
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
PKG_VERSION:=1.2.0 PKG_VERSION:=1.4.0
PKG_LICENSE:=GPLv3 PKG_LICENSE:=GPLv3
PKG_LINCESE_FILES:=LICENSE PKG_LINCESE_FILES:=LICENSE
PKF_MAINTAINER:=siriling <siriling@qq.com> PKF_MAINTAINER:=siriling <siriling@qq.com>
@ -29,13 +29,6 @@ define Package/luci-app-modem/conffiles
/etc/config/modem /etc/config/modem
endef endef
define Package/$(PKG_NAME)/config
# shown in make menuconfig <Help>
help
$(LUCI_TITLE)
Version: $(PKG_VERSION)
endef
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature # call BuildPackage - OpenWrt buildroot signature

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -5,6 +5,7 @@ local fs = require "nixio.fs"
local json = require("luci.jsonc") local json = require("luci.jsonc")
uci = luci.model.uci.cursor() uci = luci.model.uci.cursor()
local script_path="/usr/share/modem/" local script_path="/usr/share/modem/"
local run_path="/tmp/run/modem/"
function index() function index()
if not nixio.fs.access("/etc/config/modem") then if not nixio.fs.access("/etc/config/modem") then
@ -22,19 +23,25 @@ function index()
entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Dial Config"),20).leaf = true entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Dial Config"),20).leaf = true
entry({"admin", "network", "modem", "config"}, cbi("modem/config")).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", "get_modems"}, call("getModems"), nil).leaf = true
entry({"admin", "network", "modem", "get_dial_log_info"}, call("getDialLogInfo"), nil).leaf = true
entry({"admin", "network", "modem", "clean_dial_log"}, call("cleanDialLog"), nil).leaf = true
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
--模块调试 --模块调试
entry({"admin", "network", "modem", "modem_debug"},template("modem/modem_debug"),translate("Modem Debug"),30).leaf = true entry({"admin", "network", "modem", "modem_debug"},template("modem/modem_debug"),translate("Modem Debug"),30).leaf = true
entry({"admin", "network", "modem", "get_quick_commands"}, call("getQuickCommands"), nil).leaf = true entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).leaf = true
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true
entry({"admin", "network", "modem", "get_mode_info"}, call("getModeInfo"), nil).leaf = true entry({"admin", "network", "modem", "get_mode_info"}, call("getModeInfo"), nil).leaf = true
entry({"admin", "network", "modem", "set_mode"}, call("setMode"), nil).leaf = true entry({"admin", "network", "modem", "set_mode"}, call("setMode"), nil).leaf = true
entry({"admin", "network", "modem", "get_network_prefer_info"}, call("getNetworkPreferInfo"), nil).leaf = true entry({"admin", "network", "modem", "get_network_prefer_info"}, call("getNetworkPreferInfo"), nil).leaf = true
entry({"admin", "network", "modem", "set_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true entry({"admin", "network", "modem", "set_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true
entry({"admin", "network", "modem", "get_self_test_info"}, call("getSelfTestInfo"), nil).leaf = true entry({"admin", "network", "modem", "get_self_test_info"}, call("getSelfTestInfo"), nil).leaf = true
entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).leaf = true entry({"admin", "network", "modem", "get_quick_commands"}, call("getQuickCommands"), nil).leaf = true
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
-- entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true
--插件信息
entry({"admin", "network", "modem", "plugin_info"},template("modem/plugin_info"),translate("Plugin Info"),40).leaf = true
entry({"admin", "network", "modem", "get_plugin_info"}, call("getPluginInfo"), nil).leaf = true
--AT命令旧界面 --AT命令旧界面
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
@ -50,6 +57,18 @@ function hasLetters(str)
return string.find(str, pattern) ~= nil return string.find(str, pattern) ~= nil
end end
--[[
@Description Shell脚本
@Params
command sh命令
]]
function shell(command)
local odpall = io.popen(command)
local odp = odpall:read("*a")
odpall:close()
return odp
end
--[[ --[[
@Description AT命令 @Description AT命令
@Params @Params
@ -57,11 +76,29 @@ end
at_command AT命令 at_command AT命令
]] ]]
function at(at_port,at_command) function at(at_port,at_command)
local odpall = io.popen("source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command) local command="source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command
local odp = odpall:read("*a") local result=shell(command)
odpall:close() result=string.gsub(result, "\r", "")
odp=string.gsub(odp, "\r", "") return result
return odp end
--[[
@Description
@Params
at_port AT串口
]]
function getManufacturer(at_port)
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
return manufacturer
end end
--[[ --[[
@ -75,15 +112,33 @@ function getMode(at_port,manufacturer,platform)
local mode="unknown" local mode="unknown"
if at_port and manufacturer~="unknown" then if at_port and manufacturer~="unknown" then
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform) local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform
opd = odpall:read("*a") local result=shell(command)
odpall:close() mode=string.gsub(result, "\n", "")
mode = string.gsub(opd, "\n", "")
end end
return mode return mode
end end
--[[
@Description
@Params
at_port AT串口
]]
function getModes(at_port)
local modes
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
modes=modem_device["modes"]
return true --跳出循环
end
end)
return modes
end
--[[ --[[
@Description @Description
@Params @Params
@ -96,10 +151,9 @@ function getModemConnectStatus(at_port,manufacturer,define_connect)
local connect_status="unknown" local connect_status="unknown"
if at_port and manufacturer~="unknown" then if at_port and manufacturer~="unknown" then
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect) local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect
opd = odpall:read("*a") local result=shell(command)
odpall:close() connect_status=string.gsub(result, "\n", "")
connect_status = string.gsub(opd, "\n", "")
end end
return connect_status return connect_status
@ -140,12 +194,11 @@ end
function getModemMoreInfo(at_port,manufacturer,define_connect) function getModemMoreInfo(at_port,manufacturer,define_connect)
--获取模组信息 --获取模组信息
local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect) local command="sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect
local opd = odpall:read("*a") local result=shell(command)
odpall:close()
--设置值 --设置值
local modem_more_info=json.parse(opd) local modem_more_info=json.parse(result)
return modem_more_info return modem_more_info
end end
@ -309,6 +362,74 @@ function getModems()
luci.http.write_json(data) luci.http.write_json(data)
end end
--[[
@Description
]]
function getDialLogInfo()
local command="find "..run_path.." -name \"modem*_dial.cache\""
local result=shell(command)
local log_paths=string.split(result, "\n")
table.sort(log_paths)
local logs={}
local names={}
for key in pairs(log_paths) do
local log_path=log_paths[key]
if log_path ~= "" then
--获取模组
local tmp=string.gsub(log_path, run_path, "")
local modem=string.gsub(tmp, "_dial.cache", "")
local modem_name=uci:get("modem", modem, "name")
--获取日志内容
local command="cat "..log_path
log=shell(command)
--排序插入
modem_log={}
modem_log[modem]=log
table.insert(logs, modem_log)
names[modem]=modem_name
end
end
-- 设置值
local data={}
data["dial_log_info"]=logs
data["modem_name"]=names
data["translation"]=translation
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(data)
end
--[[
@Description
]]
function cleanDialLog()
-- 获取拨号日志路径
local dial_log_path = http.formvalue("path")
-- 清空拨号日志
local command=": > "..dial_log_path
shell(command)
-- 设置值
local data={}
data["clean_result"]="clean dial log"
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(data)
end
--[[ --[[
@Description @Description
]] ]]
@ -380,6 +501,160 @@ function getATPort()
luci.http.write_json(data) luci.http.write_json(data)
end end
--[[
@Description
]]
function getModeInfo()
local at_port = http.formvalue("port")
--获取值
local mode_info={}
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
local manufacturer=modem_device["manufacturer"]
if manufacturer=="unknown" then
return true --跳出循环
end
--获取支持的拨号模式
local modes=modem_device["modes"]
--获取模组拨号模式
local mode=getMode(at_port,manufacturer,modem_device["platform"])
--设置模式信息
mode_info["mode"]=mode
mode_info["modes"]=modes
return true --跳出循环
end
end)
--设置值
local modem_debug_info={}
modem_debug_info["mode_info"]=mode_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[
@Description
]]
function setMode()
local at_port = http.formvalue("port")
local mode_config = http.formvalue("mode_config")
--获取制造商
local manufacturer=getManufacturer(at_port)
--设置模组拨号模式
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config
shell(command)
--获取设置好后的模组拨号模式
local mode
if at_port and manufacturer and manufacturer~="unknown" then
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port
local result=shell(command)
mode=string.gsub(result, "\n", "")
end
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(mode)
end
--[[
@Description
]]
function getNetworkPreferInfo()
local at_port = http.formvalue("port")
--获取制造商
local manufacturer=getManufacturer(at_port)
--获取值
local network_prefer_info
if manufacturer~="unknown" then
--获取模组网络偏好
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port
local result=shell(command)
network_prefer_info=json.parse(result)
end
--设置值
local modem_debug_info={}
modem_debug_info["network_prefer_info"]=network_prefer_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[
@Description
]]
function setNetworkPrefer()
local at_port = http.formvalue("port")
local network_prefer_config = json.stringify(http.formvalue("prefer_config"))
--获取制造商
local manufacturer=getManufacturer(at_port)
--设置模组网络偏好
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config
shell(command)
--获取设置好后的模组网络偏好
local network_prefer={}
if at_port and manufacturer and manufacturer~="unknown" then
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port
local result=shell(command)
network_prefer=json.parse(result)
end
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(network_prefer)
end
--[[
@Description
]]
function getSelfTestInfo()
local at_port = http.formvalue("port")
--获取制造商
local manufacturer=getManufacturer(at_port)
--获取值
local self_test_info={}
if manufacturer~="unknown" then
--获取模组电压
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_voltage "..at_port
local result=shell(command)
self_test_info["voltage"]=json.parse(result)
--获取模组温度
command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_temperature "..at_port
result=shell(command)
self_test_info["temperature"]=json.parse(result)
end
--设置值
local modem_debug_info={}
modem_debug_info["self_test_info"]=self_test_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[ --[[
@Description @Description
]] ]]
@ -391,15 +666,7 @@ function getQuickCommands()
local at_port = http.formvalue("port") local at_port = http.formvalue("port")
--获取制造商 --获取制造商
local manufacturer local manufacturer=getManufacturer(at_port)
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--未适配模组时,快捷命令选项为自定义 --未适配模组时,快捷命令选项为自定义
if manufacturer=="unknown" then if manufacturer=="unknown" then
@ -410,11 +677,11 @@ function getQuickCommands()
local commands={} local commands={}
if quick_option=="auto" then if quick_option=="auto" then
--获取模组AT命令 --获取模组AT命令
-- local odpall = io.popen(source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer) -- local command="source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer
local odpall = io.popen("cat "..script_path..manufacturer.."_at_commands.json") local command="cat "..script_path..manufacturer.."_at_commands.json"
local opd = odpall:read("*a") local result=shell(command)
odpall:close() quick_commands=json.parse(result)
quick_commands=json.parse(opd)
else else
uci:foreach("modem", "custom-commands", function (custom_commands) uci:foreach("modem", "custom-commands", function (custom_commands)
local command={} local command={}
@ -447,207 +714,6 @@ function sendATCommand()
luci.http.write_json(response) luci.http.write_json(response)
end end
--[[
@Description
]]
function setNetworkPrefer()
local at_port = http.formvalue("port")
local network_prefer_config = json.stringify(http.formvalue("prefer_config"))
--获取制造商
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--设置模组网络偏好
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config)
odpall:close()
--获取设置好后的模组网络偏好
local network_prefer={}
if at_port and manufacturer and manufacturer~="unknown" then
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
local opd = odpall:read("*a")
network_prefer=json.parse(opd)
odpall:close()
end
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(network_prefer)
end
--[[
@Description
]]
function setMode()
local at_port = http.formvalue("port")
local mode_config = http.formvalue("mode_config")
--获取制造商
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--设置模组拨号模式
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config)
odpall:close()
--获取设置好后的模组拨号模式
local mode
if at_port and manufacturer and manufacturer~="unknown" then
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
mode = odpall:read("*a")
mode=string.gsub(mode, "\n", "")
odpall:close()
end
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(mode)
end
--[[
@Description
]]
function getModeInfo()
local at_port = http.formvalue("port")
--获取制造商
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--获取值
local mode_info={}
if manufacturer~="unknown" then
--获取支持的拨号模式
local modes
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
modes=modem_device["modes"]
return true --跳出循环
end
end)
--获取模组拨号模式
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
local opd = odpall:read("*a")
odpall:close()
local mode=string.gsub(opd, "\n", "")
--设置模式信息
mode_info["mode"]=mode
mode_info["modes"]=modes
end
--设置值
local modem_debug_info={}
modem_debug_info["mode_info"]=mode_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[
@Description
]]
function getNetworkPreferInfo()
local at_port = http.formvalue("port")
--获取制造商
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--获取值
local network_prefer_info
if manufacturer~="unknown" then
--获取模组网络偏好
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
local opd = odpall:read("*a")
odpall:close()
network_prefer_info=json.parse(opd)
end
--设置值
local modem_debug_info={}
modem_debug_info["network_prefer_info"]=network_prefer_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[
@Description
]]
function getSelfTestInfo()
local at_port = http.formvalue("port")
--获取制造商
local manufacturer
uci:foreach("modem", "modem-device", function (modem_device)
--设置模组AT串口
if at_port == modem_device["at_port"] then
--获取制造商
manufacturer=modem_device["manufacturer"]
return true --跳出循环
end
end)
--获取值
local self_test_info={}
if manufacturer~="unknown" then
--获取模组电压
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_voltage "..at_port)
local opd = odpall:read("*a")
odpall:close()
self_test_info["voltage"]=json.parse(opd)
--获取模组温度
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_temperature "..at_port)
local opd = odpall:read("*a")
odpall:close()
self_test_info["temperature"]=json.parse(opd)
end
--设置值
local modem_debug_info={}
modem_debug_info["self_test_info"]=self_test_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(modem_debug_info)
end
--[[ --[[
@Description @Description
]] ]]
@ -655,15 +721,7 @@ end
-- local at_port = http.formvalue("port") -- local at_port = http.formvalue("port")
-- --获取制造商 -- --获取制造商
-- local manufacturer -- local manufacturer=getManufacturer(at_port)
-- uci:foreach("modem", "modem-device", function (modem_device)
-- --设置模组AT串口
-- if at_port == modem_device["at_port"] then
-- --获取制造商
-- manufacturer=modem_device["manufacturer"]
-- return true --跳出循环
-- end
-- end)
-- --获取值 -- --获取值
-- local mode_info={} -- local mode_info={}
@ -675,7 +733,7 @@ end
-- self_test_info=getSelfTestInfo(at_port,manufacturer) -- self_test_info=getSelfTestInfo(at_port,manufacturer)
-- end -- end
-- --设置值 -- -- 设置值
-- local modem_debug_info={} -- local modem_debug_info={}
-- modem_debug_info["mode_info"]=mode_info -- modem_debug_info["mode_info"]=mode_info
-- modem_debug_info["network_prefer_info"]=network_prefer_info -- modem_debug_info["network_prefer_info"]=network_prefer_info
@ -685,3 +743,125 @@ end
-- luci.http.prepare_content("application/json") -- luci.http.prepare_content("application/json")
-- luci.http.write_json(modem_debug_info) -- luci.http.write_json(modem_debug_info)
-- end -- end
--[[
@Description
@Params
info
]]
function setPluginVersionInfo(info)
-- 正则表达式
local version_regular_expression="[0-9]+.[0-9]+.[0-9]+"
for key in pairs(info) do
-- 获取插件版本
local command="opkg list-installed | grep -oE '"..key.." - "..version_regular_expression.."' | awk -F' ' '{print $3}' | tr -d '\n'"
local plugin_version=shell(command)
if plugin_version~="" then
info[key]=plugin_version
end
end
end
--[[
@Description
@Params
result
]]
function getModelStatus(result)
local model_status="Not loaded"
if result~="" then
model_status="Loaded"
end
return model_status
end
--[[
@Description
@Params
info
]]
function setModelStatus(info)
for key in pairs(info) do
-- 获取内核模块名
local model_name=key:gsub(".ko","")
local command="lsmod | grep -oE '"..model_name.." '"
local result=shell(command)
local model_status=getModelStatus(result)
-- 修改信息表
info[key]=model_status
end
end
--[[
@Description
]]
function getPluginInfo()
-- 设置翻译
translation={}
translation["Unknown"]=luci.i18n.translate("Unknown")
translation["Loaded"]=luci.i18n.translate("Loaded")
translation["Not loaded"]=luci.i18n.translate("Not loaded")
-- 获取插件信息
local plugin_info={}
plugin_info["luci-app-modem"]="Unknown"
setPluginVersionInfo(plugin_info)
-- 获取拨号工具信息
local dial_tool_info={}
dial_tool_info["quectel-CM-5G"]="Unknown"
dial_tool_info["modemmanager"]="Unknown"
setPluginVersionInfo(dial_tool_info)
-- 获取通用驱动信息
local general_driver_info={}
general_driver_info["usbnet.ko"]="Not loaded"
general_driver_info["qcserial.ko"]="Not loaded"
setModelStatus(general_driver_info)
-- 获取模组USB驱动信息
local usb_driver_info={}
usb_driver_info["qmi_wwan.ko"]="Not loaded"
usb_driver_info["cdc_ether.ko"]="Not loaded"
usb_driver_info["cdc_mbim.ko"]="Not loaded"
usb_driver_info["rndis_host.ko"]="Not loaded"
usb_driver_info["cdc_ncm.ko"]="Not loaded"
setModelStatus(usb_driver_info)
-- 获取模组PCIE驱动信息
local pcie_driver_info={}
pcie_driver_info["mhi_net.ko"]="Not loaded"
pcie_driver_info["qrtr_mhi.ko"]="Not loaded"
pcie_driver_info["mhi_pci_generic.ko"]="Not loaded"
pcie_driver_info["mhi_wwan_mbim.ko"]="Not loaded"
pcie_driver_info["mhi_wwan_ctrl.ko"]="Not loaded"
pcie_driver_info["pcie_mhi.ko"]="Not loaded"
pcie_driver_info["mtk_pcie_wwan_m80.ko"]="Not loaded"
setModelStatus(pcie_driver_info)
-- 设置值
local data={}
data["translation"]=translation
data["plugin_info"]=plugin_info
data["dial_tool_info"]=dial_tool_info
data["general_driver_info"]=general_driver_info
data["usb_driver_info"]=usb_driver_info
data["pcie_driver_info"]=pcie_driver_info
-- 写入Web界面
luci.http.prepare_content("application/json")
luci.http.write_json(data)
end

View File

@ -93,6 +93,9 @@ o.cfgvalue = function(t, n)
return apn return apn
end end
-- 添加模块拨号日志
m:append(Template("modem/modem_dial_log"))
-- m:append(Template("modem/list_status")) -- m:append(Template("modem/list_status"))
return m return m

View File

@ -15,8 +15,8 @@
get_modem_debug_info(debug_params); get_modem_debug_info(debug_params);
}); });
//获取tab菜单 //获取标签菜单
var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0]; var tab_menu = document.getElementById("tab_menu");
set_tab_event(tab_menu); set_tab_event(tab_menu);
//获取快捷选项父元素 //获取快捷选项父元素
@ -69,7 +69,7 @@
}); });
} }
//设置tab菜单事件 //设置标签菜单事件
function set_tab_event(parent_element) function set_tab_event(parent_element)
{ {
//获取子元素 //获取子元素
@ -77,35 +77,36 @@
//获取需要禁用的元素 //获取需要禁用的元素
for (var i = 0; i < childElements.length; i++) for (var i = 0; i < childElements.length; i++)
{ {
// childElements[i].addEventListener('click', function(event) { childElements[i].addEventListener('click', function(event) {
// var debug_params={first_cache:true}; tab_event(this);
// get_modem_debug_info(debug_params);
// });
// 创建一个 MutationObserver 实例
var observer = new MutationObserver(function(mutationsList) {
for (var mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
//只处理当前变为禁用的tab
if (mutation.target.className=='cbi-tab') {
//获取模组调试信息
var debug_params={first_cache:true}; var debug_params={first_cache:true};
get_modem_debug_info(debug_params); get_modem_debug_info(debug_params);
//只处理一次
break;
}
}
}
}); });
// 配置观察器选项 // // 创建一个 MutationObserver 实例
var observerOptions = { // var observer = new MutationObserver(function(mutationsList) {
attributes: true, // 监听属性值变化 // for (var mutation of mutationsList) {
attributeFilter: ['class'], // 要监听的属性名称 // if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
}; // //只处理当前变为禁用的tab
// if (mutation.target.className=='cbi-tab') {
// //获取模组调试信息
// var debug_params={first_cache:true};
// get_modem_debug_info(debug_params);
// //只处理一次
// break;
// }
// }
// }
// });
// 开始观察目标元素 // // 配置观察器选项
observer.observe(childElements[i], observerOptions); // var observerOptions = {
// attributes: true, // 监听属性值变化
// attributeFilter: ['class'], // 要监听的属性名称
// };
// // 开始观察目标元素
// observer.observe(childElements[i], observerOptions);
} }
} }
@ -123,7 +124,8 @@
function(x, data) function(x, data)
{ {
responseElement=document.getElementById("response"); responseElement=document.getElementById("response");
if ("response" in data) { if ("response" in data)
{
//显示当前时间 //显示当前时间
responseElement.value+=data["time"]+" "; responseElement.value+=data["time"]+" ";
//显示返回值 //显示返回值
@ -233,7 +235,26 @@
return disenable_element; return disenable_element;
} }
// 设置tab显示 //获取需要禁用的元素
function get_enable_element(parent_element)
{
var enable_element;
//获取子元素
var childElements = parent_element.children;
//获取已启用的元素
for (var i = 0; i < childElements.length; i++)
{
// 检查当前子元素的class属性是否为cbi-tab
if (childElements[i].classList.contains('cbi-tab'))
{
enable_element=childElements[i];
break;
}
}
return enable_element;
}
// 设置标签显示
function set_tab_view(disenable_element,enable_element) function set_tab_view(disenable_element,enable_element)
{ {
//获取tab内容父元素 //获取tab内容父元素
@ -246,6 +267,7 @@
var data_tab_disenable = disenable_element.getAttribute('data-tab'); var data_tab_disenable = disenable_element.getAttribute('data-tab');
var tab_context_disenable_element = tab_context.querySelector('div[data-tab="'+data_tab_disenable+'"]'); var tab_context_disenable_element = tab_context.querySelector('div[data-tab="'+data_tab_disenable+'"]');
tab_context_disenable_element.setAttribute('data-tab-active','false'); tab_context_disenable_element.setAttribute('data-tab-active','false');
tab_context_disenable_element.style.display="none";
//启用tab //启用tab
enable_element.classList.remove('cbi-tab-disabled'); enable_element.classList.remove('cbi-tab-disabled');
@ -254,13 +276,15 @@
var data_tab_enable = enable_element.getAttribute('data-tab'); var data_tab_enable = enable_element.getAttribute('data-tab');
var tab_context_enable_element = tab_context.querySelector('div[data-tab="'+data_tab_enable+'"]'); var tab_context_enable_element = tab_context.querySelector('div[data-tab="'+data_tab_enable+'"]');
tab_context_enable_element.setAttribute('data-tab-active','true'); tab_context_enable_element.setAttribute('data-tab-active','true');
tab_context_enable_element.style.display="block";
} }
// tab事件处理更新选中的tab及tab内容) // 标签事件(更新选中的标签及标签内容)
function tab_event(tab_element) function tab_event(tab_element)
{ {
//获取需要禁用的tab元素 //获取需要禁用的tab元素
var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0]; // var tab_menu = document.getElementsByClassName("cbi-tabmenu")[0];
var tab_menu = document.getElementById("tab_menu");
var disenable_element=get_tab_enable_element(tab_menu); var disenable_element=get_tab_enable_element(tab_menu);
if (tab_element != disenable_element) { if (tab_element != disenable_element) {
set_tab_view(disenable_element,tab_element); set_tab_view(disenable_element,tab_element);
@ -277,22 +301,11 @@
//隐藏模组选择界面 //隐藏模组选择界面
document.getElementById("cbi-modem").style.display="none"; document.getElementById("cbi-modem").style.display="none";
//隐藏tab菜单界面 //隐藏tab菜单界面
document.getElementsByClassName("cbi-tabmenu")[0].style.display="none"; document.getElementById("tab_menu").style.display="none";
//隐藏tab内容界面 //隐藏tab内容界面
document.getElementById("tab_context").style.display="none"; document.getElementById("tab_context").style.display="none";
} }
// 有模组界面
function modems_view()
{
//显示模组选择界面
document.getElementById("cbi-modem").style.display="block";
//显示AT命令标题
document.getElementById("at_command_title").style.display="block";
//隐藏提示信息
// document.getElementById("cbi-info").style.display="none";
}
// 未适配模组界面 // 未适配模组界面
function not_adapted_modems_view() function not_adapted_modems_view()
{ {
@ -300,26 +313,30 @@
document.getElementById("info_message").innerHTML="<strong><%:Not adapted to this modem%></strong>"; document.getElementById("info_message").innerHTML="<strong><%:Not adapted to this modem%></strong>";
//显示提示信息 //显示提示信息
document.getElementById("cbi-info").style.display="block"; document.getElementById("cbi-info").style.display="block";
//显示tab内容界面 //显示模组选择界面
document.getElementById("cbi-modem").style.display="block";
//显示标签内容界面
document.getElementById("tab_context").style.display="block"; document.getElementById("tab_context").style.display="block";
//显示AT命令标题 //显示AT命令标题
document.getElementById("at_command_title").style.display="block"; document.getElementById("at_command_title").style.display="block";
//隐藏tab菜单界面 //隐藏标签菜单界面
document.getElementsByClassName("cbi-tabmenu")[0].style.display="none"; document.getElementById("tab_menu").style.display="none";
//在tab菜单选中AT命令 //在标签菜单选中AT命令
var data_tab="at_command_tab" var data_tab="at_command_tab"
var at_command_tab_element = document.querySelector('li[data-tab="'+data_tab+'"]'); var at_command_tab_element = document.querySelector('li[data-tab="'+data_tab+'"]');
tab_event(at_command_tab_element); tab_event(at_command_tab_element);
//隐藏tab内容界面
// document.getElementById("tab_context").style.display="none";
} }
// 全功能界面 // 全功能界面
function all_function_view() function all_function_view()
{ {
//显示tab菜单界面 //更新提示信息
document.getElementsByClassName("cbi-tabmenu")[0].style.display="block"; document.getElementById("info_message").innerHTML='<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle"/><%:Loading modem%>...';
//显示tab内容界面 //显示模组选择界面
document.getElementById("cbi-modem").style.display="block";
//显示标签菜单界面
document.getElementById("tab_menu").style.display="block";
//显示标签内容界面
document.getElementById("tab_context").style.display="block"; document.getElementById("tab_context").style.display="block";
//隐藏AT命令标题 //隐藏AT命令标题
document.getElementById("at_command_title").style.display="none"; document.getElementById("at_command_title").style.display="none";
@ -390,9 +407,6 @@
var command_select = document.getElementById('command_select'); var command_select = document.getElementById('command_select');
//更新选项 //更新选项
update_option(command_select,data["quick_commands"],true); update_option(command_select,data["quick_commands"],true);
//显示有模组界面
modems_view();
} }
); );
} }
@ -462,6 +476,11 @@
{ {
//获取当前拨号模式 //获取当前拨号模式
var current_mode=mode_info["mode"]; var current_mode=mode_info["mode"];
if (current_mode=="unknown")
{
return
}
//获取支持的拨号模式 //获取支持的拨号模式
var modes=mode_info["modes"]; var modes=mode_info["modes"];
@ -489,7 +508,10 @@
document.getElementById('mode_option').innerHTML=mode_option_view; document.getElementById('mode_option').innerHTML=mode_option_view;
//设置拨号模式选项 //设置拨号模式选项
document.getElementById('mode_option_'+current_mode).checked=true; element=document.getElementById('mode_option_'+current_mode).checked=true;
//设置第一次获取数据标志
first_cache=false;
} }
} }
@ -588,6 +610,9 @@
//启用偏好复选框 //启用偏好复选框
disabled_prefer_custom_config(false); disabled_prefer_custom_config(false);
} }
//设置第一次获取数据标志
first_cache=false;
} }
} }
@ -602,7 +627,7 @@
//设置当前电压 //设置当前电压
document.getElementById('current_voltage').innerHTML=voltage/1000+" V"; document.getElementById('current_voltage').innerHTML=voltage/1000+" V";
//设置当前温度 //设置当前温度
document.getElementById('current_temperature').innerHTML=temperature+" °C"; document.getElementById('current_temperature').innerHTML=temperature*1+" °C";
//设置电压状态 //设置电压状态
var state = ''; var state = '';
@ -719,7 +744,7 @@
var at_port = document.getElementById("modem_select").value; var at_port = document.getElementById("modem_select").value;
//获取当前启用的tab元素 //获取当前启用的tab元素
var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0]; var tab_menu = document.getElementById("tab_menu");
var tab_enable_element=get_tab_enable_element(tab_menu); var tab_enable_element=get_tab_enable_element(tab_menu);
//获取当前选中的tab元素 //获取当前选中的tab元素
@ -733,19 +758,11 @@
var mode_info=data["mode_info"]; var mode_info=data["mode_info"];
if (Object.keys(mode_info).length==0) if (Object.keys(mode_info).length==0)
{ {
//显示未适配模组界面
not_adapted_modems_view();
return false return false
} }
//设置模式信息 //设置模式信息
set_mode_info(mode_info,debug_params.first_cache); set_mode_info(mode_info,debug_params.first_cache);
//设置第一次获取数据标志
debug_params.first_cache=false;
//显示全功能界面
all_function_view();
} }
); );
} }
@ -757,19 +774,11 @@
var network_prefer_info=data["network_prefer_info"]; var network_prefer_info=data["network_prefer_info"];
if (Object.keys(network_prefer_info).length==0) if (Object.keys(network_prefer_info).length==0)
{ {
//显示未适配模组界面
not_adapted_modems_view();
return false return false
} }
//设置网络偏好信息 //设置网络偏好信息
set_network_prefer_info(network_prefer_info,debug_params.first_cache); set_network_prefer_info(network_prefer_info,debug_params.first_cache);
//设置第一次获取数据标志
debug_params.first_cache=false;
//显示全功能界面
all_function_view();
} }
); );
} }
@ -781,53 +790,14 @@
var self_test_info=data["self_test_info"]; var self_test_info=data["self_test_info"];
if (Object.keys(self_test_info).length==0) if (Object.keys(self_test_info).length==0)
{ {
//显示未适配模组界面
not_adapted_modems_view();
return false return false
} }
//设置模组自检信息 //设置模组自检信息
set_modem_self_test_info(self_test_info); set_modem_self_test_info(self_test_info);
//设置第一次获取数据标志
// debug_params.first_cache=false;
//显示全功能界面
all_function_view();
} }
); );
} }
//获取调试信息
// XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_debug_info")%>', {"port":at_port},
// function(x, data)
// {
// var mode_info=data["mode_info"];
// var network_prefer_info=data["network_prefer_info"];
// var self_test_info=data["self_test_info"];
// if (Object.keys(mode_info).length==0||Object.keys(network_prefer_info).length==0) {
// //显示未适配模组界面
// not_adapted_modems_view();
// return false
// }
// //设置模式信息
// set_mode_info(mode_info,debug_params.first_cache);
// //设置网络偏好信息
// set_network_prefer_info(network_prefer_info,debug_params.first_cache);
// //设置模组自检信息
// set_modem_self_test_info(self_test_info);
// //设置第一次获取数据标志
// debug_params.first_cache=false;
// //显示全功能界面
// all_function_view();
// }
// );
} }
// 定时触发更新AT串口 // 定时触发更新AT串口
@ -836,7 +806,7 @@
{ {
//缓存当前选择的模组 //缓存当前选择的模组
var modem_select_cache=""; var modem_select_cache="";
var debug_params={first_cache:true}; var debug_params={first_cache:true,view:0};
return function(x, data) return function(x, data)
{ {
var at_ports=data["at_ports"]; var at_ports=data["at_ports"];
@ -848,8 +818,7 @@
//获取快捷命令 //获取快捷命令
if (Object.keys(at_ports).length==0) if (Object.keys(at_ports).length==0)
{ {
//显示无模组界面 debug_params.view=0;
no_modems_view();
} }
else else
{ {
@ -857,6 +826,15 @@
var modem_select_element = document.getElementById('modem_select'); var modem_select_element = document.getElementById('modem_select');
var select_modem_name = modem_select_element.options[modem_select_element.selectedIndex].text; var select_modem_name = modem_select_element.options[modem_select_element.selectedIndex].text;
if (select_modem_name.includes("ttyUSB")||select_modem_name.includes("at")||select_modem_name.includes("DUN"))
{
debug_params.view=2;
}
else
{
debug_params.view=1;
}
if (select_modem_name != modem_select_cache) if (select_modem_name != modem_select_cache)
{ {
//获取快捷选项 //获取快捷选项
@ -864,6 +842,7 @@
if (quick_option=="auto") { if (quick_option=="auto") {
get_quick_commands(); get_quick_commands();
} }
//缓存当前选中的模组
modem_select_cache=select_modem_name; modem_select_cache=select_modem_name;
//设置第一次获取数据标志 //设置第一次获取数据标志
@ -873,6 +852,20 @@
//获取模组调试信息 //获取模组调试信息
get_modem_debug_info(debug_params); get_modem_debug_info(debug_params);
} }
//设置界面
if (debug_params.view==0) {
//显示无模组界面
no_modems_view();
}
else if (debug_params.view==1) {
//显示全功能界面
all_function_view();
}
else if (debug_params.view==2) {
//显示未适配模组界面
not_adapted_modems_view();
}
}; };
})() })()
); );
@ -913,7 +906,7 @@
display: none; display: none;
} }
/* 终端 */ /* AT命令响应 */
textarea { textarea {
background:#373737; background:#373737;
border:none; border:none;
@ -975,16 +968,16 @@
</div> </div>
</fieldset> </fieldset>
<!-- <ul class="cbi-tabmenu" id="tab_menu"> <ul class="cbi-tabmenu" id="tab_menu">
<li class="cbi-tab" data-tab="mode_tab"><a href="#"><%:Mode%></a></li> <li class="cbi-tab" data-tab="mode_tab"><a href="#"><%:Mode%></a></li>
<li class="cbi-tab-disabled" data-tab="network_prefer_tab"><a href="#"><%:Network Preferences%></a></li> <li class="cbi-tab-disabled" data-tab="network_prefer_tab"><a href="#"><%:Network Preferences%></a></li>
<li class="cbi-tab-disabled" data-tab="self_test_tab"><a href="#"><%:Self Test%></a></li> <li class="cbi-tab-disabled" data-tab="self_test_tab"><a href="#"><%:Self Test%></a></li>
<li class="cbi-tab-disabled" data-tab="at_command_tab"><a href="#"><%:AT Command%></a></li> <li class="cbi-tab-disabled" data-tab="at_command_tab"><a href="#"><%:AT Command%></a></li>
</ul> --> </ul>
<div id="tab_context"> <div class="cbi-section-node cbi-section-node-tabbed" id="tab_context">
<!-- <div class="cbi-section cbi-tblsection" data-tab-active="true"> --> <!-- <div class="cbi-section cbi-tblsection" data-tab-active="true"> -->
<div class="cbi-section" data-tab="mode_tab" data-tab-title="<%:Mode%>" data-tab-active="true"> <div class="cbi-section" data-tab="mode_tab" data-tab-title="<%:Mode%>" data-tab-active="true" style="display: block;">
<!-- <legend><%:Mode%></legend> --> <!-- <legend><%:Mode%></legend> -->
<!-- <h3><%:Mode%></h3> --> <!-- <h3><%:Mode%></h3> -->
<table class="table cbi-section-table"> <table class="table cbi-section-table">
@ -1030,7 +1023,7 @@
</table> </table>
</div> </div>
<!-- <div class="cbi-section cbi-tblsection"> --> <!-- <div class="cbi-section cbi-tblsection"> -->
<div class="cbi-section" data-tab="network_prefer_tab" data-tab-title="<%:Network Preferences%>" data-tab-active="false"> <div class="cbi-section" data-tab="network_prefer_tab" data-tab-title="<%:Network Preferences%>" data-tab-active="false" style="display: none;">
<!-- <legend><%:Network Preferences%></legend> --> <!-- <legend><%:Network Preferences%></legend> -->
<!-- <h3><%:Network Preferences%></h3> --> <!-- <h3><%:Network Preferences%></h3> -->
<table class="table cbi-section-table"> <table class="table cbi-section-table">
@ -1081,7 +1074,7 @@
</table> </table>
</div> </div>
<!-- <div class="cbi-section fade-in"> --> <!-- <div class="cbi-section fade-in"> -->
<div class="cbi-section" data-tab="self_test_tab" data-tab-title="<%:Self Test%>" data-tab-active="false"> <div class="cbi-section" data-tab="self_test_tab" data-tab-title="<%:Self Test%>" data-tab-active="false" style="display: none;">
<!-- <legend><%:Self Test%></legend> --> <!-- <legend><%:Self Test%></legend> -->
<!-- <h3><%:Self Test%></h3> --> <!-- <h3><%:Self Test%></h3> -->
<table class="table cbi-section-table"> <table class="table cbi-section-table">
@ -1105,7 +1098,7 @@
</table> </table>
</div> </div>
<!-- <div class="cbi-section fade-in"> --> <!-- <div class="cbi-section fade-in"> -->
<div class="cbi-section" data-tab="at_command_tab" data-tab-title="<%:AT Command%>" data-tab-active="false"> <div class="cbi-section" data-tab="at_command_tab" data-tab-title="<%:AT Command%>" data-tab-active="false" style="display: none;">
<!-- <legend><%:AT Command%></legend> --> <!-- <legend><%:AT Command%></legend> -->
<h3 id="at_command_title"><%:AT Command%></h3> <h3 id="at_command_title"><%:AT Command%></h3>
<table class="table" id="at_command_info"> <table class="table" id="at_command_info">
@ -1150,8 +1143,8 @@
<div id="response_label"><%:Response%></div><br/> <div id="response_label"><%:Response%></div><br/>
<div><textarea readonly="readonly" id="response" rows="20" maxlength="160"></textarea></div> <div><textarea readonly="readonly" id="response" rows="20" maxlength="160"></textarea></div>
<div class="cbi-page-actions"> <div class="cbi-page-actions">
<input class="btn cbi-button cbi-button-link" type="button" value="<%:Return to old page%>" onclick="location.href='/cgi-bin/luci/admin/network/modem/at_command_old'"> <input class="btn cbi-button cbi-button-link" type="button" value="<%:Return to old page%>" onclick="location.href='/cgi-bin/luci/admin/network/modem/at_command_old'" alt="<%:Return to old page%>" title="<%:Return to old page%>">
<input class="btn cbi-button cbi-button-link" type="button" value="<%:Custom quick commands%>" onclick="location.href='/cgi-bin/luci/admin/network/modem/quick_commands_config'"> <input class="btn cbi-button cbi-button-link" type="button" value="<%:Custom quick commands%>" onclick="location.href='/cgi-bin/luci/admin/network/modem/quick_commands_config'" alt="<%:Custom quick commands%>" title="<%:Custom quick commands%>">
<input class="cbi-button cbi-button-reset" type="button" value="<%:Clean%>" onclick="clean_response()" alt="<%:Clean%>" title="<%:Clean%>"> <input class="cbi-button cbi-button-reset" type="button" value="<%:Clean%>" onclick="clean_response()" alt="<%:Clean%>" title="<%:Clean%>">
</div> </div>
</td> </td>

View File

@ -0,0 +1,281 @@
<script type="text/javascript">//<![CDATA[
function set_tab_event()
{
var tab_menu = document.getElementById("tab_menu");
//获取子元素
var childElements = tab_menu.children;
//获取需要禁用的元素
for (var i = 0; i < childElements.length; i++)
{
childElements[i].addEventListener('click', function(event) {
tab_event(this);
});
}
}
//获取需要禁用的元素
function get_enable_element(parent_element)
{
var enable_element;
//获取子元素
var childElements = parent_element.children;
//获取已启用的元素
for (var i = 0; i < childElements.length; i++)
{
// 检查当前子元素的class属性是否为cbi-tab
if (childElements[i].classList.contains('cbi-tab'))
{
enable_element=childElements[i];
break;
}
}
return enable_element;
}
// 设置标签显示
function set_tab_view(disenable_element,enable_element)
{
//获取tab内容父元素
var tab_context = document.getElementById('dial_log_view');
//禁用tab
disenable_element.classList.remove('cbi-tab');
disenable_element.classList.add('cbi-tab-disabled');
//禁用tab内容
var data_tab_disenable = disenable_element.getAttribute('data-tab');
var tab_context_disenable_element = tab_context.querySelector('div[data-tab="'+data_tab_disenable+'"]');
tab_context_disenable_element.setAttribute('data-tab-active','false');
tab_context_disenable_element.style.display="none";
//启用tab
enable_element.classList.remove('cbi-tab-disabled');
enable_element.classList.add('cbi-tab');
//启用tab内容
var data_tab_enable = enable_element.getAttribute('data-tab');
var tab_context_enable_element = tab_context.querySelector('div[data-tab="'+data_tab_enable+'"]');
tab_context_enable_element.setAttribute('data-tab-active','true');
tab_context_enable_element.style.display="block";
}
// 标签事件处理(更新选中的标签及标签内容)
function tab_event(tab_element)
{
//获取需要禁用的tab元素
var tab_menu = document.getElementById("tab_menu");
var disenable_element=get_enable_element(tab_menu);
if (tab_element != disenable_element) {
set_tab_view(disenable_element,tab_element);
}
}
// 设置滚动条
function set_scroll_top(log_ids)
{
for(var log_id in log_ids)
{
var log_element=document.getElementById(log_id);
if (log_ids[log_id]==-1)
{
log_element.scrollTop = log_element.scrollHeight;
}
else
{
log_element.scrollTop = log_ids[log_id];
}
}
}
// 下载日志
function download_dial_log()
{
// 获取启用的标签名
var enable_element=get_enable_element(tab_menu);
var enable_tab=enable_element.getAttribute("data-tab");
var enable_tab_name=enable_tab.replace("_tab","");
// 获取拨号日志
var log_element=document.getElementById(enable_tab_name+"_log");
var log=log_element.value
// 创建下载链接
var file = new Blob([log], {type: 'text/plain'});
var fileURL = URL.createObjectURL(file);
// 创建超链接并触发点击
var download_link = document.createElement("a");
download_link.href = fileURL;
download_link.download = enable_tab_name+"_dial_log.txt";
download_link.click();
}
// 清理拨号日志
function clean_dial_log()
{
// 获取启用的标签名
var enable_element=get_enable_element(tab_menu);
var enable_tab=enable_element.getAttribute("data-tab");
var enable_tab_name=enable_tab.replace("_tab","");
// 清空页面拨号日志
var log_element=document.getElementById(enable_tab_name+"_log");
log_element.value="";
// 获取拨号日志路径
var path="/tmp/run/modem/"+enable_tab_name+"_dial.cache";
// 清空文件拨号日志
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "clean_dial_log")%>', {"path":path},
function(x, data)
{
// console.log(data);
}
);
}
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_dial_log_info")%>', null,
function(x, data)
{
var dial_log_info=data["dial_log_info"];
var modem_name=data["modem_name"];
var tab_menu=document.getElementById("tab_menu");
var dial_log_div=document.getElementById('dial_log_view');
if (Object.keys(dial_log_info).length!=0)
{
// 新添加标签或覆盖标签
var tab_view = "";
var dial_log_view = "";
var log_ids={};
var enable_tab_name_cache=""; // 缓存已启用标签名
for (var dial_log of dial_log_info)
{
//遍历拨号日志的信息
for ( var key in dial_log)
{
var class_name="cbi-tab-disabled";
var active="false";
var display="none";
var log_style="";
if (tab_menu.hasChildNodes())
{
// 获取启用的标签元素
var enable_element=get_enable_element(tab_menu);
// 设置启用的标签为上一次的启用标签
enable_tab=enable_element.getAttribute("data-tab");
enable_tab_name_cache=enable_tab.replace("_tab","");
if (enable_tab_name_cache==key)
{
class_name="cbi-tab";
active="true";
display="block";
}
var log_element=document.getElementById(key+'_log');
if (log_element!=null)
{
// 设置样式
log_style=log_element.getAttribute("style");
// 判断日志是否更新
var log=log_element.value;
if (dial_log[key]!=log)
{
// 更新的移动滚动条到最下面
log_ids[key+'_log']=-1;
}
else
{
// 记录滚到条位置
log_ids[key+'_log']=log_element.scrollTop;
}
}
}
// 设置拨号日志标签
tab_view+='<li class="'+class_name+'" data-tab="'+key+'_tab"><a>'+modem_name[key].toUpperCase()+' ('+key.replace("modem","")+')</a></li>';
// 设置拨号日志
dial_log_view += '<div class="cbi-section" data-tab="'+key+'_tab" data-tab-title="'+key+'" data-tab-active="'+active+'" style="display: '+display+';">';
dial_log_view += '<div><textarea readonly="readonly" id="'+key+'_log" rows="20" maxlength="160" style="'+log_style+'">'+dial_log[key]+'</textarea></div>';
dial_log_view += '</div>'
}
}
// 添加到页面中
tab_menu.innerHTML=tab_view;
dial_log_div.innerHTML=dial_log_view;
// 设置默认启用的标签(上次启用标签已删除)
var enable_element=document.getElementById(enable_tab_name_cache+"_log");
if (enable_element==null)
{
//设置启用的为第一个标签
enable_element=tab_menu.firstChild;
enable_element.classList.remove('cbi-tab-disabled');
enable_element.classList.add('cbi-tab');
enable_element=dial_log_div.firstChild;
enable_element.setAttribute('data-tab-active','true');
enable_element.style.display="block";
}
//设置滚动条
set_scroll_top(log_ids);
// 设置标签事件
set_tab_event();
// 显示拨号日志(标签、日志内容、滚动条、标签事件加载完成才显示)
document.getElementById("modem_dial_log_field").style.display="block";
}
else
{
var log_view="<strong><%:No dial log%></strong>";
dial_log_div.innerHTML=log_view;
// 隐藏拨号日志
document.getElementById("modem_dial_log_field").style.display="none";
}
}
);
//]]>
</script>
<style type="text/css">
/* AT命令响应 */
textarea {
background:#373737;
border:none;
color:#FFF;
width: 100%;
border-top-width: 2px;
padding-top: 12px;
}
</style>
<fieldset id="modem_dial_log_field" class="cbi-section" style="display: none;">
<div class="cbi-section fade-in">
<!-- <legend><%:Dial Log%></legend> -->
<h3 id="dial_log_title"><%:Dial Log%></h3>
</div>
<!-- <div id="response_label"><%:Response%></div><br/> -->
<table class="table" id="at_command_info">
<tbody>
<tr class="tr">
<td colspan="2" class="td left">
<ul class="cbi-tabmenu" id="tab_menu"></ul>
<div id="dial_log_view">
<!-- <div class="cbi-section" data-tab="modem0_tab" data-tab-title="<%:Modem0%>" data-tab-active="true" style="display: block;">
<div><textarea readonly="readonly" id="response" rows="20" maxlength="160"></textarea></div>
</div> -->
</div>
<div class="cbi-page-actions">
<input class="btn cbi-button cbi-button-link" type="button" value="<%:Download Log%>" onclick="download_dial_log()" alt="<%:Download Log%>" title="<%:Download Log%>">
<input class="cbi-button cbi-button-reset" type="button" value="<%:Clean%>" onclick="clean_dial_log()" alt="<%:Clean%>" title="<%:Clean%>">
</div>
</td>
</tr>
</tbody>
</table>
</fieldset>

View File

@ -0,0 +1,262 @@
<%+header%>
<script type="text/javascript" src="<%=resource%>/xhr.js"></script>
<script type="text/javascript">//<![CDATA[
// 设置状态页面
function set_status_view(status,status_element,translation)
{
if (status=="Loaded") {
status_element.style.color = "green";
}
else if (status=="Not loaded") {
status_element.style.color = "red";
}
status_element.innerHTML=translation[status];
}
// 设置状态
function set_status(info,translation)
{
//遍历信息里面的内核模块
for (var model in info)
{
//获取状态元素
var status_element=document.getElementById(model.replace(".ko","_status"));
// 设置状态页面
set_status_view(info[model],status_element,translation);
}
}
// 设置版本
function set_version(info,translation)
{
//遍历信息里面的插件版本
for (var plugin in info)
{
//获取版本元素
var version_element=document.getElementById(plugin+"_version");
if (info[plugin]=="Unknown") {
version_element.innerHTML=translation[info[plugin]];
version_element.style.color = "goldenrod";
}
else
{
version_element.innerHTML="v"+info[plugin];
version_element.style.color = "green";
}
}
}
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_plugin_info")%>', {},
function(x, data)
{
// 获取翻译
var translation=data["translation"];
// 获取插件信息
var plugin_info=data["plugin_info"];
set_version(plugin_info,translation);
// 获取拨号工具信息
var dial_tool_info=data["dial_tool_info"];
set_version(dial_tool_info,translation);
// 设置通用驱动信息的状态
var general_driver_info=data["general_driver_info"];
set_status(general_driver_info,translation);
// 设置模组USB驱动信息的状态
var usb_driver_info=data["usb_driver_info"];
set_status(usb_driver_info,translation);
// 设置模组PCIE驱动信息的状态
var pcie_driver_info=data["pcie_driver_info"];
set_status(pcie_driver_info,translation);
}
);
//]]>
</script>
<div class="cbi-map" id="cbi-modem-debug">
<h2 id="content" name="content"><%:Plugin Info%></h2>
<div class="cbi-map-descr"><%:View the version information of the plugin%></div>
<head>
<style type="text/css">
div .version {
margin-top: 5px;
}
</style>
</head>
<fieldset class="cbi-section" id="cbi-modem" style="display: block;">
<div class="cbi-section fade-in">
<!-- <legend><%:Plugin Info%></legend> -->
<h3><%:Plugin Info%></h3>
<div class="cbi-section-node">
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title"><%:Plugin Version%></label>
<div class="cbi-value-field">
<div class="version">
<strong id="luci-app-modem_version"></strong>
</div>
<!-- <div class="cbi-value-description">
<%:Select a modem for debugging%>
</div> -->
</div>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="cbi-modem" style="display: block;">
<div class="cbi-section fade-in">
<!-- <legend><%:Dial Tool Info%></legend> -->
<h3><%:Dial Tool Info%></h3>
<div class="cbi-section-node">
<div class="cbi-value">
<label class="cbi-value-title"><%:quectel-CM Version%></label>
<div class="cbi-value-field">
<div class="version">
<strong id="quectel-CM-5G_version"></strong>
</div>
<!-- <div class="cbi-value-description">
<%:Select a modem for debugging%>
</div> -->
</div>
</div>
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title"><%:modemmanager Version%></label>
<div class="cbi-value-field">
<div class="version">
<strong id="modemmanager_version"></strong>
</div>
<!-- <div class="cbi-value-description">
<%:Select a modem for debugging%>
</div> -->
</div>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="cbi-modem" style="display: block;">
<div class="cbi-section fade-in">
<!-- <legend><%:Modem PCIE Driver Info%></legend> -->
<h3><%:Modem General Driver Info%></h3>
<table class="table cbi-section-table">
<tbody>
<tr class="tr cbi-section-table-titles anonymous">
<th class="th cbi-section-table-cell"><%:Driver Type%></th>
<th class="th cbi-section-table-cell"><%:Kernel Model%></th>
<th class="th cbi-section-table-cell"><%:Status%></th>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:USB Network%>" id="usb_network"><%:USB Network%></td>
<td class="td cbi-value-field" data-title="<%:usbnet%>" id="usb_net_kernel_model_name">usbnet.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="usbnet_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:Serial Port%>" id="serial"><%:Serial Port%></td>
<td class="td cbi-value-field" data-title="<%:qcserial%>" id="serial_kernel_model_name">qcserial.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="qcserial_status">-</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<fieldset class="cbi-section" id="cbi-modem" style="display: block;">
<div class="cbi-section fade-in">
<!-- <legend><%:Modem USB Driver Info%></legend> -->
<h3><%:Modem USB Driver Info%></h3>
<table class="table cbi-section-table">
<tbody>
<tr class="tr cbi-section-table-titles anonymous">
<th class="th cbi-section-table-cell"><%:Driver Type%></th>
<th class="th cbi-section-table-cell"><%:Kernel Model%></th>
<th class="th cbi-section-table-cell"><%:Status%></th>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:QMI%>" id="qmi"><%:QMI%></td>
<td class="td cbi-value-field" data-title="<%:qmi_wwan%>" id="qmi_kernel_model_name">qmi_wwan.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="qmi_wwan_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:ECM%>" id="ecm"><%:ECM%></td>
<td class="td cbi-value-field" data-title="<%:cdc_ether%>" id="ecm_kernel_model_name">cdc_ether.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="cdc_ether_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:MBIM%>" id="mbim"><%:MBIM%></td>
<td class="td cbi-value-field" data-title="<%:cdc_mbim%>" id="mbim_kernel_model_name">cdc_mbim.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="cdc_mbim_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:RNDIS%>" id="rndis"><%:RNDIS%></td>
<td class="td cbi-value-field" data-title="<%:rndis_host%>" id="rndis_kernel_model_name">rndis_host.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="rndis_host_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:NCM%>" id="ecm"><%:NCM%></td>
<td class="td cbi-value-field" data-title="<%:cdc_ncm%>" id="ncm_kernel_model_name">cdc_ncm.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="cdc_ncm_status">-</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<fieldset class="cbi-section" id="cbi-modem" style="display: block;">
<div class="cbi-section fade-in">
<!-- <legend><%:Modem PCIE Driver Info%></legend> -->
<h3><%:Modem PCIE Driver Info%></h3>
<table class="table cbi-section-table">
<tbody>
<tr class="tr cbi-section-table-titles anonymous">
<th class="th cbi-section-table-cell"><%:Driver Type%></th>
<th class="th cbi-section-table-cell"><%:Kernel Model%></th>
<th class="th cbi-section-table-cell"><%:Status%></th>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:General%>" id="mhi_net"><%:General%></td>
<td class="td cbi-value-field" data-title="<%:mhi_net%>" id="mhi_net_kernel_model_name">mhi_net.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="mhi_net_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:General%>" id="qrtr_mhi"><%:General%></td>
<td class="td cbi-value-field" data-title="<%:qrtr_mhi%>" id="qrtr_kernel_model_name">qrtr_mhi.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="qrtr_mhi_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:General%>" id="mhi_pci_generic"><%:General%></td>
<td class="td cbi-value-field" data-title="<%:mhi_pci_generic%>" id="mhi_pci_kernel_model_name">mhi_pci_generic.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="mhi_pci_generic_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:General%>" id="mhi_wwan_mbim"><%:General%></td>
<td class="td cbi-value-field" data-title="<%:mhi_wwan_mbim%>" id="mhi_mbim_kernel_model_name">mhi_wwan_mbim.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="mhi_wwan_mbim_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-1">
<td class="td cbi-value-field" data-title="<%:General%>" id="mhi_wwan_ctrl"><%:General%></td>
<td class="td cbi-value-field" data-title="<%:mhi_wwan_ctrl%>" id="mhi_wwan_kernel_model_name">mhi_wwan_ctrl.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="mhi_wwan_ctrl_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:Private%>" id="private_q"><%:Private%></td>
<td class="td cbi-value-field" data-title="<%:pcie_mhi%>" id="pcie_mhi_kernel_model_name">pcie_mhi.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="pcie_mhi_status">-</td>
</tr>
<tr class="tr cbi-section-table-row cbi-rowstyle-2">
<td class="td cbi-value-field" data-title="<%:Private%>" id="private_mtk"><%:Private%></td>
<td class="td cbi-value-field" data-title="<%:mtk_pcie_wwan_m80%>" id="mtk_pcie_wwan_m80_kernel_model_name">mtk_pcie_wwan_m80.ko</td>
<td class="td cbi-value-field" data-title="<%:Status%>" id="mtk_pcie_wwan_m80_status">-</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</div>
<%+footer%>

View File

@ -1,3 +1,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Base Setting" msgid "Base Setting"
msgstr "基本设置" msgstr "基本设置"
@ -43,6 +46,12 @@ msgstr "在此页面给所有模组添加拨号配置"
msgid "Global Config" msgid "Global Config"
msgstr "全局配置" msgstr "全局配置"
msgid "Dial Log"
msgstr "拨号日志"
msgid "Download Log"
msgstr "下载日志"
msgid "connect" msgid "connect"
msgstr "已连接" msgstr "已连接"
@ -495,3 +504,54 @@ msgstr "中国电信"
msgid "46011" msgid "46011"
msgstr "中国电信" msgstr "中国电信"
msgid "Plugin Info"
msgstr "插件信息"
msgid "View the version information of the plugin"
msgstr "查看插件的版本信息"
msgid "Plugin Version"
msgstr "插件版本"
msgid "Dial Tool Info"
msgstr "拨号工具信息"
msgid "quectel-CM Version"
msgstr "quectel-CM 版本"
msgid "modemmanager Version"
msgstr "modemmanager 版本"
msgid "Modem General Driver Info"
msgstr "模组通用信息"
msgid "Driver Type"
msgstr "驱动类型"
msgid "Kernel Model"
msgstr "内核模块"
msgid "USB Network"
msgstr "USB网络"
msgid "Serial Port"
msgstr "串口"
msgid "Loaded"
msgstr "已加载"
msgid "Not loaded"
msgstr "未加载"
msgid "Modem USB Driver Info"
msgstr "模组USB驱动信息"
msgid "Modem PCIE Driver Info"
msgstr "模组PCIE驱动信息"
msgid "General"
msgstr "通用"
msgid "Private"
msgstr "私有"

View File

@ -0,0 +1 @@
zh-cn

View File

@ -20,6 +20,59 @@ fibocom_presets()
sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command" sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command"
} }
#获取DNS
# $1:AT串口
# $2:连接定义
fibocom_get_dns()
{
local at_port="$1"
local define_connect="$2"
[ -z "$define_connect" ] && {
define_connect="1"
}
local public_dns1_ipv4="223.5.5.5"
local public_dns2_ipv4="119.29.29.29"
local public_dns1_ipv6="2400:3200::1" #下一代互联网北京研究中心240C::6666阿里2400:3200::1腾讯2402:4e00::
local public_dns2_ipv6="2402:4e00::"
#获取DNS地址
at_command="AT+GTDNS=${define_connect}"
local response=$(at ${at_port} ${at_command} | grep "+GTDNS: ")
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns1" ] && {
ipv4_dns1="${public_dns1_ipv4}"
}
local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns2" ] && {
ipv4_dns2="${public_dns2_ipv4}"
}
local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns1" ] && {
ipv6_dns1="${public_dns1_ipv6}"
}
local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns2" ] && {
ipv6_dns2="${public_dns2_ipv6}"
}
dns="{
\"dns\":{
\"ipv4_dns1\":\"$ipv4_dns1\",
\"ipv4_dns2\":\"$ipv4_dns2\",
\"ipv6_dns1\":\"$ipv6_dns1\",
\"ipv6_dns2\":\"$ipv6_dns2\"
}
}"
echo "$dns"
}
#获取拨号模式 #获取拨号模式
# $1:AT串口 # $1:AT串口
# $2:平台 # $2:平台
@ -29,7 +82,12 @@ fibocom_get_mode()
local platform="$2" local platform="$2"
at_command="AT+GTUSBMODE?" at_command="AT+GTUSBMODE?"
local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command | grep "+GTUSBMODE:" | sed 's/+GTUSBMODE: //g' | sed 's/\r//g') local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+GTUSBMODE:" | sed 's/+GTUSBMODE: //g' | sed 's/\r//g')
if [ -z "$mode_num" ]; then
echo "unknown"
return
fi
#获取芯片平台 #获取芯片平台
if [ -z "$platform" ]; then if [ -z "$platform" ]; then
@ -88,7 +146,7 @@ fibocom_get_mode()
mode="$mode_num" mode="$mode_num"
;; ;;
esac esac
echo "$mode" echo "${mode}"
} }
#设置拨号模式 #设置拨号模式
@ -97,6 +155,7 @@ fibocom_get_mode()
fibocom_set_mode() fibocom_set_mode()
{ {
local at_port="$1" local at_port="$1"
local mode_config="$2"
#获取芯片平台 #获取芯片平台
local platform local platform
@ -113,7 +172,7 @@ fibocom_set_mode()
local mode_num local mode_num
case "$platform" in case "$platform" in
"qualcomm") "qualcomm")
case "$2" in case "$mode_config" in
"qmi") mode_num="32" ;; "qmi") mode_num="32" ;;
# "gobinet") mode_num="32" ;; # "gobinet") mode_num="32" ;;
"ecm") mode_num="18" ;; "ecm") mode_num="18" ;;
@ -124,7 +183,7 @@ fibocom_set_mode()
esac esac
;; ;;
"unisoc") "unisoc")
case "$2" in case "$mode_config" in
"ecm") mode_num="34" ;; "ecm") mode_num="34" ;;
"mbim") mode_num="40" ;; "mbim") mode_num="40" ;;
"rndis") mode_num="38" ;; "rndis") mode_num="38" ;;
@ -133,7 +192,7 @@ fibocom_set_mode()
esac esac
;; ;;
"mediatek") "mediatek")
case "$2" in case "$mode_config" in
# "mbim") mode_num="40" ;; # "mbim") mode_num="40" ;;
# "rndis") mode_num="40" ;; # "rndis") mode_num="40" ;;
"rndis") mode_num="41" ;; "rndis") mode_num="41" ;;
@ -146,8 +205,8 @@ fibocom_set_mode()
esac esac
#设置模组 #设置模组
at_command="AT+GTUSBMODE=$mode_num" at_command="AT+GTUSBMODE=${mode_num}"
sh ${SCRIPT_DIR}/modem_at.sh $at_port "$at_command" sh ${SCRIPT_DIR}/modem_at.sh ${at_port} "${at_command}"
} }
#获取网络偏好 #获取网络偏好
@ -345,7 +404,7 @@ fibocom_get_sim_status()
{ {
local sim_status local sim_status
case $1 in case $1 in
"") sim_status="unknown" ;; "") sim_status="miss" ;;
*"ERROR"*) sim_status="miss" ;; *"ERROR"*) sim_status="miss" ;;
*"READY"*) sim_status="ready" ;; *"READY"*) sim_status="ready" ;;
*"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;; *"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
@ -413,7 +472,7 @@ fibocom_sim_info()
#IMSI国际移动用户识别码 #IMSI国际移动用户识别码
at_command="AT+CIMI?" at_command="AT+CIMI?"
imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F' ' '{print $2}' | sed 's/"/g' | sed 's/\r//g') imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F' ' '{print $2}' | sed 's/"//g' | sed 's/\r//g')
[ -z "$sim_number" ] && { [ -z "$sim_number" ] && {
imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F'"' '{print $2}') imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F'"' '{print $2}')
} }

View File

@ -72,5 +72,5 @@ dial_log()
#打印日志 #打印日志
local update_time=$(date +"%Y-%m-%d %H:%M:%S") local update_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "${update_time} Send AT command ${at_command} to modem" >> "${path}" echo "[${update_time}] Send AT command ${at_command} to modem" >> "${path}"
} }

View File

@ -10,6 +10,59 @@ MODEM_RUNDIR="/var/run/modem"
#导入组件工具 #导入组件工具
source "${SCRIPT_DIR}/modem_debug.sh" source "${SCRIPT_DIR}/modem_debug.sh"
#重设网络接口
# $1:AT串口
# $4:连接定义
# $5:模组序号
reset_network_interface()
{
local at_port="$1"
local define_connect="$2"
local modem_no="$3"
local interface_name="wwan_5g_${modem_no}"
local interface_name_ipv6="wwan6_5g_${modem_no}"
#获取IPv4地址
at_command="AT+CGPADDR=${define_connect}"
local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F',' '{print $2}' | sed 's/"//g')
#输出日志
# echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem new IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#获取DNS地址
dns=$(fibocom_get_dns ${at_port} ${define_connect})
local ipv4_dns1=$(echo "${dns}" | jq -r '.dns.ipv4_dns1')
local ipv4_dns2=$(echo "${dns}" | jq -r '.dns.ipv4_dns2')
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem IPv4 DNS1: ${ipv4_dns1}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem IPv4 DNS2: ${ipv4_dns2}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#比较的网络接口中的IPv4地址
local ipv4_config=$(uci -q get network.${interface_name}.ipaddr)
if [ "$ipv4_config" == "$ipv4" ]; then
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] IPv4 address is the same as in the network interface, skip" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
else
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface ${interface_name}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#设置静态地址
uci set network.${interface_name}.proto='static'
uci set network.${interface_name}.ipaddr="${ipv4}"
uci set network.${interface_name}.netmask='255.255.255.0'
uci set network.${interface_name}.gateway="${ipv4%.*}.1"
uci set network.${interface_name}.peerdns='0'
uci -q del network.${interface_name}.dns
uci add_list network.${interface_name}.dns="${ipv4_dns1}"
uci add_list network.${interface_name}.dns="${ipv4_dns2}"
uci commit network
service network reload
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface ${interface_name} successful" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
fi
}
#GobiNet拨号 #GobiNet拨号
# $1:AT串口 # $1:AT串口
# $2:制造商 # $2:制造商
@ -54,16 +107,14 @@ ecm_dial()
local define_connect="$3" local define_connect="$3"
#激活 #激活
local at_command="AT+CGACT=1,${define_connect}" # local at_command="AT+CGACT=1,${define_connect}"
#打印日志 # #打印日志
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" # dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
at "${at_port}" "${at_command}" # at "${at_port}" "${at_command}"
sleep 2s
#拨号 #拨号
local at_command at_command
if [ "$manufacturer" = "quectel" ]; then if [ "$manufacturer" = "quectel" ]; then
at_command="AT+QNETDEVCTL=${define_connect},3,1" at_command="AT+QNETDEVCTL=${define_connect},3,1"
elif [ "$manufacturer" = "fibocom" ]; then elif [ "$manufacturer" = "fibocom" ]; then
@ -76,6 +127,8 @@ ecm_dial()
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
at "${at_port}" "${at_command}" at "${at_port}" "${at_command}"
sleep 2s
} }
#RNDIS拨号 #RNDIS拨号
@ -100,25 +153,6 @@ rndis_dial()
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#激活并拨号 #激活并拨号
at "${at_port}" "${at_command}" at "${at_port}" "${at_command}"
#获取IPv4地址
at_command="AT+CGPADDR=${define_connect}"
local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F',' '{print $2}' | sed 's/"//g')
#设置静态地址
local ipv4_config=$(uci -q get network.${interface_name}.ipaddr)
if [ "$ipv4_config" != "$ipv4" ]; then
uci set network.${interface_name}.proto='static'
uci set network.${interface_name}.ipaddr="$ipv4"
uci set network.${interface_name}.netmask='255.255.255.0'
uci set network.${interface_name}.gateway="${ipv4%.*}.1"
uci commit network
service network reload
#启动网络接口
ifup "wwan_5g_${modem_no}"
ifup "wwan6_5g_${modem_no}"
fi
else else
#拨号 #拨号
ecm_dial "${at_port}" "${manufacturer}" ecm_dial "${at_port}" "${manufacturer}"
@ -133,11 +167,11 @@ modemmanager_dial()
local interface_name="$1" local interface_name="$1"
local define_connect="$2" local define_connect="$2"
#激活 # #激活
local at_command="AT+CGACT=1,${define_connect}" # local at_command="AT+CGACT=1,${define_connect}"
#打印日志 # #打印日志
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" # dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
at "${at_port}" "${at_command}" # at "${at_port}" "${at_command}"
#启动网络接口 #启动网络接口
ifup "${interface_name}"; ifup "${interface_name}";
@ -159,6 +193,7 @@ modem_network_task()
local platform=$(uci -q get modem.modem${modem_no}.platform) local platform=$(uci -q get modem.modem${modem_no}.platform)
local define_connect=$(uci -q get modem.modem${modem_no}.define_connect) local define_connect=$(uci -q get modem.modem${modem_no}.define_connect)
local interface_name="wwan_5g_${modem_no}" local interface_name="wwan_5g_${modem_no}"
local interface_name_ipv6="wwan6_5g_${modem_no}"
#重载配置解决AT命令发不出去的问题 #重载配置解决AT命令发不出去的问题
# service modem reload # service modem reload
@ -166,15 +201,21 @@ modem_network_task()
#IPv4地址缓存 #IPv4地址缓存
local ipv4_cache local ipv4_cache
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Start network task" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
while true; do while true; do
#全局 #全局
local enable=$(uci -q get modem.@global[0].enable) local enable=$(uci -q get modem.@global[0].enable)
if [ "$enable" != "1" ]; then if [ "$enable" != "1" ]; then
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] The dialing configuration has been disabled, this network task quit" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
break break
fi fi
#单个模组 #单个模组
enable=$(uci -q get modem.${config_id}.enable) enable=$(uci -q get modem.${config_id}.enable)
if [ "$enable" != "1" ]; then if [ "$enable" != "1" ]; then
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] The modem has disabled dialing, this network task quit" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
break break
fi fi
@ -182,23 +223,26 @@ modem_network_task()
local at_command="AT+CGPADDR=${define_connect}" local at_command="AT+CGPADDR=${define_connect}"
local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F'"' '{print $2}') local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F'"' '{print $2}')
if [ -z "$ipv4" ] || [[ "$ipv4" = *"0.0.0.0"* ]] || [ "$ipv4" != "$ipv4_cache" ]; then
if [ -z "$ipv4" ]; then if [ -z "$ipv4" ]; then
#输出日志
echo "$(date +"%Y-%m-%d %H:%M:%S") redefine connect" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" [ "$mode" = "modemmanager" ] && {
service network modem #拨号工具为modemmanager时不需要重新设置连接定义
sleep 1s continue
else }
#缓存当前IP
ipv4_cache="${ipv4}"
#输出日志
echo "$(date +"%Y-%m-%d %H:%M:%S") Modem${modem_no} current IP : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
fi
#输出日志 #输出日志
echo "$(date +"%Y-%m-%d %H:%M:%S") check or redial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache" echo "[$(date +"%Y-%m-%d %H:%M:%S")] Unable to get IPv4 address" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Redefine connect to ${define_connect}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
service modem reload
# sleep 1s
elif [[ "$ipv4" = *"0.0.0.0"* ]]; then
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} current IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem dial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#拨号
case "$mode" in case "$mode" in
"gobinet") gobinet_dial "${at_port}" "${manufacturer}" "${define_connect}" ;; "gobinet") gobinet_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
"ecm") ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;; "ecm") ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
@ -206,8 +250,32 @@ modem_network_task()
"modemmanager") modemmanager_dial "${interface_name}" "${define_connect}" ;; "modemmanager") modemmanager_dial "${interface_name}" "${define_connect}" ;;
*) ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;; *) ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
esac esac
elif [ "$ipv4" != "$ipv4_cache" ]; then
#第一次缓存IP为空时不输出日志
[ -n "$ipv4_cache" ] && {
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} IPv4 address has changed" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
}
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} current IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#缓存当前IP
ipv4_cache="${ipv4}"
#重新设置网络接口广和通FM350-GL
if [ "$manufacturer" = "fibocom" ] && [ "$platform" = "mediatek" ]; then
reset_network_interface "${at_port}" "${define_connect}" "${modem_no}"
fi fi
[ "$mode" != "modemmanager" ] && {
#重新启动网络接口
ifup "${interface_name}"
ifup "${interface_name_ipv6}"
}
fi
sleep 5s sleep 5s
done done
} }

View File

@ -59,7 +59,7 @@ m_modem_presets()
at "${at_port}" "${at_command}" at "${at_port}" "${at_command}"
#PDP设置 #PDP设置
at_command="AT+CGDCONT=$define_connect,\"IPV4V6\",\"\"" at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"\""
at "${at_port}" "${at_command}" at "${at_port}" "${at_command}"
} }
@ -700,6 +700,7 @@ m_set_modem_port()
local mhi_hwip=$(find ${physical_path} -name mhi_hwip*) local mhi_hwip=$(find ${physical_path} -name mhi_hwip*)
if [ -n "$mhi_hwip" ]; then if [ -n "$mhi_hwip" ]; then
all_port=$(find ${physical_path} -name wwan*) all_port=$(find ${physical_path} -name wwan*)
all_port=$(echo "$all_port" | sed '1,2d')
else else
all_port=$(find ${physical_path} -name mhi_*) all_port=$(find ${physical_path} -name mhi_*)
fi fi

View File

@ -11,6 +11,59 @@ quectel_presets()
# sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command" # sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command"
} }
#获取DNS
# $1:AT串口
# $2:连接定义
quectel_get_dns()
{
local at_port="$1"
local define_connect="$2"
[ -z "$define_connect" ] && {
define_connect="1"
}
local public_dns1_ipv4="223.5.5.5"
local public_dns2_ipv4="119.29.29.29"
local public_dns1_ipv6="2400:3200::1" #下一代互联网北京研究中心240C::6666阿里2400:3200::1腾讯2402:4e00::
local public_dns2_ipv6="2402:4e00::"
#获取DNS地址
at_command="AT+GTDNS=${define_connect}"
local response=$(at ${at_port} ${at_command} | grep "+GTDNS: ")
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns1" ] && {
ipv4_dns1="${public_dns1_ipv4}"
}
local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns2" ] && {
ipv4_dns2="${public_dns2_ipv4}"
}
local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns1" ] && {
ipv6_dns1="${public_dns1_ipv6}"
}
local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns2" ] && {
ipv6_dns2="${public_dns2_ipv6}"
}
dns="{
\"dns\":{
\"ipv4_dns1\":\"$ipv4_dns1\",
\"ipv4_dns2\":\"$ipv4_dns2\",
\"ipv6_dns1\":\"$ipv6_dns1\",
\"ipv6_dns2\":\"$ipv6_dns2\"
}
}"
echo "$dns"
}
#获取拨号模式 #获取拨号模式
# $1:AT串口 # $1:AT串口
# $2:平台 # $2:平台
@ -20,7 +73,12 @@ quectel_get_mode()
local platform="$2" local platform="$2"
at_command='AT+QCFG="usbnet"' at_command='AT+QCFG="usbnet"'
local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command | grep "+QCFG:" | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g') local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+QCFG:" | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
if [ -z "$mode_num" ]; then
echo "unknown"
return
fi
#获取芯片平台 #获取芯片平台
if [ -z "$platform" ]; then if [ -z "$platform" ]; then