更新
This commit is contained in:
parent
50259c0a6d
commit
458db0c993
@ -5,6 +5,7 @@ local fs = require "nixio.fs"
|
||||
local json = require("luci.jsonc")
|
||||
uci = luci.model.uci.cursor()
|
||||
local script_path="/usr/share/modem/"
|
||||
local run_path="/tmp/run/modem/"
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/modem") then
|
||||
@ -22,19 +23,20 @@ function index()
|
||||
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", "get_modems"}, call("getModems"), nil).leaf = true
|
||||
entry({"admin", "network", "modem", "get_dial_log_info"}, call("getDialLogInfo"), nil).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", "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", "quick_commands_config"}, cbi("modem/quick_commands_config")).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", "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", "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
|
||||
|
||||
--AT命令旧界面
|
||||
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
|
||||
@ -50,6 +52,18 @@ function hasLetters(str)
|
||||
return string.find(str, pattern) ~= nil
|
||||
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命令
|
||||
@Params
|
||||
@ -57,11 +71,29 @@ end
|
||||
at_command AT命令
|
||||
]]
|
||||
function at(at_port,at_command)
|
||||
local odpall = io.popen("source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command)
|
||||
local odp = odpall:read("*a")
|
||||
odpall:close()
|
||||
odp=string.gsub(odp, "\r", "")
|
||||
return odp
|
||||
local command="source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command
|
||||
local result=shell(command)
|
||||
result=string.gsub(result, "\r", "")
|
||||
return result
|
||||
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
|
||||
|
||||
--[[
|
||||
@ -75,15 +107,33 @@ function getMode(at_port,manufacturer,platform)
|
||||
local mode="unknown"
|
||||
|
||||
if at_port and manufacturer~="unknown" then
|
||||
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform)
|
||||
opd = odpall:read("*a")
|
||||
odpall:close()
|
||||
mode = string.gsub(opd, "\n", "")
|
||||
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform
|
||||
local result=shell(command)
|
||||
mode=string.gsub(result, "\n", "")
|
||||
end
|
||||
|
||||
return mode
|
||||
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 获取模组连接状态
|
||||
@Params
|
||||
@ -96,10 +146,9 @@ function getModemConnectStatus(at_port,manufacturer,define_connect)
|
||||
local connect_status="unknown"
|
||||
|
||||
if at_port and manufacturer~="unknown" then
|
||||
local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect)
|
||||
opd = odpall:read("*a")
|
||||
odpall:close()
|
||||
connect_status = string.gsub(opd, "\n", "")
|
||||
local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect
|
||||
local result=shell(command)
|
||||
connect_status=string.gsub(result, "\n", "")
|
||||
end
|
||||
|
||||
return connect_status
|
||||
@ -140,12 +189,11 @@ end
|
||||
function getModemMoreInfo(at_port,manufacturer,define_connect)
|
||||
|
||||
--获取模组信息
|
||||
local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect)
|
||||
local opd = odpall:read("*a")
|
||||
odpall:close()
|
||||
local command="sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect
|
||||
local result=shell(command)
|
||||
|
||||
--设置值
|
||||
local modem_more_info=json.parse(opd)
|
||||
local modem_more_info=json.parse(result)
|
||||
return modem_more_info
|
||||
end
|
||||
|
||||
@ -309,6 +357,24 @@ function getModems()
|
||||
luci.http.write_json(data)
|
||||
end
|
||||
|
||||
--[[
|
||||
@Description 获取拨号日志信息
|
||||
]]
|
||||
function getDialLogInfo()
|
||||
|
||||
local command="find "..run_path.." -name \"modem*_dial.cache\""
|
||||
local result=shell(command)
|
||||
|
||||
-- 设置值
|
||||
local data={}
|
||||
data["dial_log_info"]=result
|
||||
-- data["translation"]=translation
|
||||
|
||||
-- 写入Web界面
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(data)
|
||||
end
|
||||
|
||||
--[[
|
||||
@Description 模块列表状态函数
|
||||
]]
|
||||
@ -380,6 +446,160 @@ function getATPort()
|
||||
luci.http.write_json(data)
|
||||
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 获取快捷命令
|
||||
]]
|
||||
@ -391,15 +611,7 @@ function getQuickCommands()
|
||||
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 manufacturer=getManufacturer(at_port)
|
||||
|
||||
--未适配模组时,快捷命令选项为自定义
|
||||
if manufacturer=="unknown" then
|
||||
@ -410,11 +622,11 @@ function getQuickCommands()
|
||||
local commands={}
|
||||
if quick_option=="auto" then
|
||||
--获取模组AT命令
|
||||
-- local odpall = io.popen(source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer)
|
||||
local odpall = io.popen("cat "..script_path..manufacturer.."_at_commands.json")
|
||||
local opd = odpall:read("*a")
|
||||
odpall:close()
|
||||
quick_commands=json.parse(opd)
|
||||
-- local command="source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer
|
||||
local command="cat "..script_path..manufacturer.."_at_commands.json"
|
||||
local result=shell(command)
|
||||
quick_commands=json.parse(result)
|
||||
|
||||
else
|
||||
uci:foreach("modem", "custom-commands", function (custom_commands)
|
||||
local command={}
|
||||
@ -447,207 +659,6 @@ function sendATCommand()
|
||||
luci.http.write_json(response)
|
||||
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 获取模组调试信息
|
||||
]]
|
||||
@ -655,15 +666,7 @@ end
|
||||
-- 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 manufacturer=getManufacturer(at_port)
|
||||
|
||||
-- --获取值
|
||||
-- local mode_info={}
|
||||
|
@ -93,6 +93,9 @@ o.cfgvalue = function(t, n)
|
||||
return apn
|
||||
end
|
||||
|
||||
-- 添加模块拨号日志
|
||||
m:append(Template("modem/modem_dial_log"))
|
||||
|
||||
-- m:append(Template("modem/list_status"))
|
||||
|
||||
return m
|
||||
|
@ -913,7 +913,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 终端 */
|
||||
/* AT命令响应 */
|
||||
textarea {
|
||||
background:#373737;
|
||||
border:none;
|
||||
|
@ -0,0 +1,36 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_dial_log_info")%>', null,
|
||||
function(x, data)
|
||||
{
|
||||
console.log(data);
|
||||
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
/* AT命令响应 */
|
||||
textarea {
|
||||
background:#373737;
|
||||
border:none;
|
||||
color:#FFF;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 默认隐藏模块状态 -->
|
||||
<fieldset id="modem_dial_log_field" class="cbi-section" style="display: block;">
|
||||
<div class="cbi-section fade-in">
|
||||
<!-- <legend><%:AT Command%></legend> -->
|
||||
<h3 id="dial_log_title"><%:Dial Log%></h3>
|
||||
<!-- <div id="response_label"><%:Response%></div><br/> -->
|
||||
<div><textarea readonly="readonly" id="response" rows="20" maxlength="160"></textarea></div>
|
||||
<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="<%:Custom quick commands%>" onclick="location.href='/cgi-bin/luci/admin/network/modem/quick_commands_config'">
|
||||
<input class="cbi-button cbi-button-reset" type="button" value="<%:Clean%>" onclick="clean_response()" alt="<%:Clean%>" title="<%:Clean%>">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
@ -1,203 +0,0 @@
|
||||
<%-
|
||||
local rowcnt = 0
|
||||
|
||||
function rowstyle()
|
||||
rowcnt = rowcnt + 1
|
||||
if rowcnt % 2 == 0 then
|
||||
return " cbi-rowstyle-1"
|
||||
else
|
||||
return " cbi-rowstyle-2"
|
||||
end
|
||||
end
|
||||
|
||||
function width(o)
|
||||
if o.width then
|
||||
if type(o.width) == 'number' then
|
||||
return ' style="width:%dpx"' % o.width
|
||||
end
|
||||
return ' style="width:%s"' % o.width
|
||||
end
|
||||
return ''
|
||||
end
|
||||
|
||||
local has_titles = false
|
||||
local has_descriptions = false
|
||||
|
||||
local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
|
||||
local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
|
||||
|
||||
local i, k
|
||||
for i, k in pairs(self.children) do
|
||||
if not k.typename then
|
||||
k.typename = k.template and k.template:gsub("^.+/", "") or ""
|
||||
end
|
||||
|
||||
if not has_titles and k.title and #k.title > 0 then
|
||||
has_titles = true
|
||||
end
|
||||
|
||||
if not has_descriptions and k.description and #k.description > 0 then
|
||||
has_descriptions = true
|
||||
end
|
||||
end
|
||||
|
||||
function render_titles()
|
||||
if not has_titles then
|
||||
return
|
||||
end
|
||||
|
||||
%><tr class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>><%
|
||||
|
||||
local i, k
|
||||
for i, k in ipairs(self.children) do
|
||||
if not k.optional then
|
||||
%><th class="th cbi-section-table-cell"<%=
|
||||
width(k) .. attr('data-widget', k.typename) %>><%
|
||||
|
||||
if k.titleref then
|
||||
%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%
|
||||
end
|
||||
|
||||
write(k.title)
|
||||
|
||||
if k.titleref then
|
||||
%></a><%
|
||||
end
|
||||
|
||||
%></th><%
|
||||
end
|
||||
end
|
||||
|
||||
if self.sortable or self.extedit or self.addremove then
|
||||
%><th class="th cbi-section-table-cell cbi-section-actions"></th><%
|
||||
end
|
||||
|
||||
%></tr><%
|
||||
|
||||
rowcnt = rowcnt + 1
|
||||
end
|
||||
|
||||
function render_descriptions()
|
||||
if not has_descriptions then
|
||||
return
|
||||
end
|
||||
|
||||
%><tr class="tr cbi-section-table-descr <%=anonclass%>"><%
|
||||
|
||||
local i, k
|
||||
for i, k in ipairs(self.children) do
|
||||
if not k.optional then
|
||||
%><th class="th cbi-section-table-cell"<%=
|
||||
width(k) .. attr("data-widget", k.typename) %>><%
|
||||
|
||||
write(k.description)
|
||||
|
||||
%></th><%
|
||||
end
|
||||
end
|
||||
|
||||
if self.sortable or self.extedit or self.addremove then
|
||||
%><th class="th cbi-section-table-cell cbi-section-actions"></th><%
|
||||
end
|
||||
|
||||
%></tr><%
|
||||
|
||||
rowcnt = rowcnt + 1
|
||||
end
|
||||
|
||||
-%>
|
||||
|
||||
<!-- tblsection -->
|
||||
<div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
|
||||
<% if self.title and #self.title > 0 then -%>
|
||||
<h3><%=self.title%></h3>
|
||||
<%- end %>
|
||||
<%- if self.sortable then -%>
|
||||
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
|
||||
<%- end -%>
|
||||
<div class="cbi-section-descr"><%=self.description%></div>
|
||||
<table class="table cbi-section-table">
|
||||
<%-
|
||||
render_titles()
|
||||
render_descriptions()
|
||||
|
||||
local isempty, section, i, k = true, nil, nil
|
||||
for i, k in ipairs(self:cfgsections()) do
|
||||
isempty = false
|
||||
section = k
|
||||
|
||||
local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
|
||||
local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
|
||||
local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
|
||||
local scope = {
|
||||
valueheader = "cbi/cell_valueheader",
|
||||
valuefooter = "cbi/cell_valuefooter"
|
||||
}
|
||||
-%>
|
||||
<tr class="tr cbi-section-table-row<%=colorclass%>" id="cbi-<%=self.config%>-<%=section%>"<%=sectiontitle%>>
|
||||
<%-
|
||||
local node
|
||||
for k, node in ipairs(self.children) do
|
||||
if not node.optional then
|
||||
node:render(section, scope or {})
|
||||
end
|
||||
end
|
||||
-%>
|
||||
|
||||
<%- if self.sortable or self.extedit or self.addremove then -%>
|
||||
<td class="td cbi-section-table-cell nowrap cbi-section-actions">
|
||||
<div>
|
||||
<%- if self.sortable then -%>
|
||||
<input class="btn cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>" />
|
||||
<input class="btn cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>" />
|
||||
<% end; if self.extedit then -%>
|
||||
<input class="btn cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
|
||||
<%- if type(self.extedit) == "string" then
|
||||
%> onclick="location.href='<%=self.extedit:format(section)%>'"
|
||||
<%- elseif type(self.extedit) == "function" then
|
||||
%> onclick="location.href='<%=self:extedit(section)%>'"
|
||||
<%- end
|
||||
%> alt="<%:Edit%>" title="<%:Edit%>" />
|
||||
<% end; if self.addremove then %>
|
||||
<input class="btn cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
|
||||
<%- end -%>
|
||||
</div>
|
||||
</td>
|
||||
<%- end -%>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
|
||||
<%- if isempty then -%>
|
||||
<tr class="tr cbi-section-table-row placeholder">
|
||||
<td class="td"><em><%:This section contains no values yet%></em></td>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
</table>
|
||||
|
||||
<% if self.error then %>
|
||||
<div class="cbi-section-error">
|
||||
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
|
||||
<li><%=pcdata(e):gsub("\n","<br />")%></li>
|
||||
<%- end end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%- if self.addremove then -%>
|
||||
<% if self.template_addremove then include(self.template_addremove) else -%>
|
||||
<div class="cbi-section-create cbi-tblsection-create">
|
||||
<% if self.anonymous then %>
|
||||
<input class="btn cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
|
||||
<% else %>
|
||||
<% if self.invalid_cts then -%>
|
||||
<div class="cbi-section-error"><%:Invalid%></div>
|
||||
<%- end %>
|
||||
<div>
|
||||
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" onkeyup="cbi_validate_named_section_add(this)"/>
|
||||
</div>
|
||||
<input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" disabled="" />
|
||||
<% end %>
|
||||
</div>
|
||||
<%- end %>
|
||||
<%- end -%>
|
||||
</div>
|
||||
<!-- /tblsection -->
|
@ -1,208 +0,0 @@
|
||||
<%-
|
||||
local rowcnt = 0
|
||||
|
||||
function rowstyle()
|
||||
rowcnt = rowcnt + 1
|
||||
if rowcnt % 2 == 0 then
|
||||
return " cbi-rowstyle-1"
|
||||
else
|
||||
return " cbi-rowstyle-2"
|
||||
end
|
||||
end
|
||||
|
||||
function width(o)
|
||||
if o.width then
|
||||
if type(o.width) == 'number' then
|
||||
return ' style="width:%dpx"' % o.width
|
||||
end
|
||||
return ' style="width:%s"' % o.width
|
||||
end
|
||||
return ''
|
||||
end
|
||||
|
||||
local has_titles = false
|
||||
local has_descriptions = false
|
||||
|
||||
local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
|
||||
local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
|
||||
|
||||
local i, k
|
||||
for i, k in pairs(self.children) do
|
||||
if not k.typename then
|
||||
k.typename = k.template and k.template:gsub("^.+/", "") or ""
|
||||
end
|
||||
|
||||
if not has_titles and k.title and #k.title > 0 then
|
||||
has_titles = true
|
||||
end
|
||||
|
||||
if not has_descriptions and k.description and #k.description > 0 then
|
||||
has_descriptions = true
|
||||
end
|
||||
end
|
||||
|
||||
function render_titles()
|
||||
if not has_titles then
|
||||
return
|
||||
end
|
||||
|
||||
%><tr class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>>
|
||||
<th class="th cbi-section-table-cell"><%:Serial Number%></th>
|
||||
<%
|
||||
local i, k
|
||||
for i, k in ipairs(self.children) do
|
||||
if not k.optional then
|
||||
%><th class="th cbi-section-table-cell"<%=
|
||||
width(k) .. attr('data-widget', k.typename) %>><%
|
||||
|
||||
if k.titleref then
|
||||
%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%
|
||||
end
|
||||
|
||||
write(k.title)
|
||||
|
||||
if k.titleref then
|
||||
%></a><%
|
||||
end
|
||||
|
||||
%></th><%
|
||||
end
|
||||
end
|
||||
|
||||
if self.sortable or self.extedit or self.addremove then
|
||||
%><th class="th cbi-section-table-cell cbi-section-actions"></th><%
|
||||
end
|
||||
|
||||
%></tr><%
|
||||
|
||||
rowcnt = rowcnt + 1
|
||||
end
|
||||
|
||||
function render_descriptions()
|
||||
if not has_descriptions then
|
||||
return
|
||||
end
|
||||
|
||||
%><tr class="tr cbi-section-table-descr <%=anonclass%>"><%
|
||||
|
||||
local i, k
|
||||
for i, k in ipairs(self.children) do
|
||||
if not k.optional then
|
||||
%><th class="th cbi-section-table-cell"<%=
|
||||
width(k) .. attr("data-widget", k.typename) %>><%
|
||||
|
||||
write(k.description)
|
||||
|
||||
%></th><%
|
||||
end
|
||||
end
|
||||
|
||||
if self.sortable or self.extedit or self.addremove then
|
||||
%><th class="th cbi-section-table-cell cbi-section-actions"></th><%
|
||||
end
|
||||
|
||||
%></tr><%
|
||||
|
||||
rowcnt = rowcnt + 1
|
||||
end
|
||||
|
||||
-%>
|
||||
|
||||
<!-- tblsection -->
|
||||
<div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
|
||||
<% if self.title and #self.title > 0 then -%>
|
||||
<h3><%=self.title%></h3>
|
||||
<%- end %>
|
||||
<%- if self.sortable then -%>
|
||||
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
|
||||
<%- end -%>
|
||||
<div class="cbi-section-descr"><%=self.description%></div>
|
||||
<table class="table cbi-section-table">
|
||||
<%-
|
||||
render_titles()
|
||||
render_descriptions()
|
||||
|
||||
local num = 1
|
||||
local isempty, section, i, k = true, nil, nil
|
||||
for i, k in ipairs(self:cfgsections()) do
|
||||
isempty = false
|
||||
section = k
|
||||
|
||||
local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
|
||||
local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
|
||||
local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
|
||||
local scope = {
|
||||
valueheader = "cbi/cell_valueheader",
|
||||
valuefooter = "cbi/cell_valuefooter"
|
||||
}
|
||||
-%>
|
||||
<tr class="tr cbi-section-table-row<%=colorclass%>" id="cbi-<%=self.config%>-<%=section%>"<%=sectiontitle%>>
|
||||
<td class="td cbi-value-field" data-title="<%:Serial Number%>">
|
||||
<p><%=num%></p>
|
||||
<% num = num + 1 -%>
|
||||
</td>
|
||||
<%-
|
||||
local node
|
||||
for k, node in ipairs(self.children) do
|
||||
if not node.optional then
|
||||
node:render(section, scope or {})
|
||||
end
|
||||
end
|
||||
-%>
|
||||
<%- if self.sortable or self.extedit or self.addremove then -%>
|
||||
<td class="td cbi-section-table-cell nowrap cbi-section-actions">
|
||||
<div>
|
||||
<%- if self.sortable then -%>
|
||||
<input class="btn cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>" />
|
||||
<input class="btn cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>" />
|
||||
<% end; if self.extedit then -%>
|
||||
<input class="btn cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
|
||||
<%- if type(self.extedit) == "string" then
|
||||
%> onclick="location.href='<%=self.extedit:format(section)%>'"
|
||||
<%- elseif type(self.extedit) == "function" then
|
||||
%> onclick="location.href='<%=self:extedit(section)%>'"
|
||||
<%- end
|
||||
%> alt="<%:Edit%>" title="<%:Edit%>" />
|
||||
<% end; if self.addremove then %>
|
||||
<input class="btn cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
|
||||
<%- end -%>
|
||||
</div>
|
||||
</td>
|
||||
<%- end -%>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
|
||||
<%- if isempty then -%>
|
||||
<tr class="tr cbi-section-table-row placeholder">
|
||||
<td class="td"><em><%:This section contains no values yet%></em></td>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
</table>
|
||||
|
||||
<% if self.error then %>
|
||||
<div class="cbi-section-error">
|
||||
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
|
||||
<li><%=pcdata(e):gsub("\n","<br />")%></li>
|
||||
<%- end end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%- if self.addremove then -%>
|
||||
<% if self.template_addremove then include(self.template_addremove) else -%>
|
||||
<div class="cbi-section-create cbi-tblsection-create">
|
||||
<% if self.anonymous then %>
|
||||
<input class="btn cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
|
||||
<% else %>
|
||||
<% if self.invalid_cts then -%>
|
||||
<div class="cbi-section-error"><%:Invalid%></div>
|
||||
<%- end %>
|
||||
<div>
|
||||
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" onkeyup="cbi_validate_named_section_add(this)"/>
|
||||
</div>
|
||||
<input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" disabled="" />
|
||||
<% end %>
|
||||
</div>
|
||||
<%- end %>
|
||||
<%- end -%>
|
||||
</div>
|
||||
<!-- /tblsection -->
|
Loading…
x
Reference in New Issue
Block a user