添加自定义快捷命令功能

This commit is contained in:
ling 2024-02-29 17:58:28 +08:00
parent 8c9c819a1c
commit 75abd1f7b9
7 changed files with 247 additions and 46 deletions

View File

@ -31,12 +31,10 @@ function index()
entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), 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", "set_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true entry({"admin", "network", "modem", "set_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true
entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).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
--AT快捷命令配置
--entry({"admin", "network", "modem", "quick_commands_config"},cbi("modem/quick_commands_config"),translate("自定义快捷命令配置"),40).leaf = true
end end
--[[ --[[
@ -357,11 +355,23 @@ function getQuickCommands()
quick_option="custom" quick_option="custom"
end end
--获取模组AT命令 local quick_commands={}
local odpall = io.popen("cd "..script_path.." && source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer) local commands={}
local opd = odpall:read("*a") if quick_option=="auto" then
odpall:close() --获取模组AT命令
local quick_commands=json.parse(opd) -- local odpall = io.popen("cd "..script_path.." && 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)
else
uci:foreach("modem", "custom-commands", function (custom_commands)
local command={}
command[custom_commands["description"]]=custom_commands["command"]
table.insert(commands,command)
end)
quick_commands["quick_commands"]=commands
end
-- 写入Web界面 -- 写入Web界面
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")

View File

@ -1,9 +1,9 @@
local d = require "luci.dispatcher" local dispatcher = require "luci.dispatcher"
local uci = require "luci.model.uci".cursor() local uci = require "luci.model.uci".cursor()
local http = require "luci.http" local http = require "luci.http"
m = Map("modem", translate("Modem Config")) m = Map("modem", translate("Modem Config"))
m.redirect = d.build_url("admin", "network", "modem","index") m.redirect = dispatcher.build_url("admin", "network", "modem","index")
s = m:section(NamedSection, arg[1], "config", "") s = m:section(NamedSection, arg[1], "config", "")
s.addremove = false s.addremove = false

View File

@ -1,53 +1,30 @@
-- Copyright 2020-2021 Rafa<66> Wabik (IceG) - From eko.one.pl forum -- Copyright 2024 Siriling <siriling@qq.com>
-- Licensed to the GNU General Public License v3.0.
local dispatcher = require "luci.dispatcher" local dispatcher = require "luci.dispatcher"
local fs = require "nixio.fs" local fs = require "nixio.fs"
local http = require "luci.http" local http = require "luci.http"
local uci = require "luci.model.uci".cursor() local uci = require "luci.model.uci".cursor()
local AT_FILE_PATH = "/etc/modem/custom_at_commands.json" m = Map("modem")
m.title = translate("Custom quick commands")
m = Map("sms_tool") m.description = translate("Customize your quick commands")
m.title = translate("Configuration sms-tool") m.redirect = dispatcher.build_url("admin", "network", "modem","modem_debug")
m.description = translate("Configuration panel for sms_tool and gui application.")
-- 自定义命令 -- -- 自定义命令 --
s = m:section(TypedSection, "custom_at_commands", translate("Custom AT Commands")) s = m:section(TypedSection, "custom-commands", translate("Custom Commands"))
s.anonymous = true s.anonymous = true
s.addremove = true s.addremove = true
s.sortable = true
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
description = s:option(Value, "description", translate("Description")) description = s:option(Value, "description", translate("Description"))
description.placeholder = "" description.placeholder = translate("Not Null")
description.rmempty = false description.rmempty = true
description.optional = false description.optional = false
command = s:option(Value, "command", translate("Command")) command = s:option(Value, "command", translate("Command"))
-- command.placeholder = "" command.placeholder = translate("Not Null")
command.rmempty = false command.rmempty = true
-- command.optional = false command.optional = false
function command.cfgvalue(self, section)
local custom_commands=fs.readfile(AT_FILE_PATH)
return "模组信息 > ATI"
end
-- RAW File --
s = m:section(NamedSection, 'general' , "sms_tool" , translate(""))
s.anonymous = true
local tat = s:option(TextValue, "user_at", translate("User AT Commands"), translate("Each line must have the following format: 'AT Command name;AT Command'. Save to file '/etc/config/atcmds.user'."))
tat.rows = 20
tat.rmempty = true
function tat.cfgvalue(self, section)
return fs.readfile(AT_FILE_PATH)
end
function tat.write(self, section, value)
value = value:gsub("\r\n", "\n")
fs.writefile(AT_FILE_PATH, value)
end
return m return m

View File

@ -824,6 +824,7 @@
<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'">
<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%>"> <input class="cbi-button cbi-button-reset" type="button" value="<%:Clean%>" onclick="clean_response()" alt="<%:Clean%>" title="<%:Clean%>">
</div> </div>
</td> </td>

View File

@ -115,6 +115,15 @@ msgstr "响应"
msgid "Return to old page" msgid "Return to old page"
msgstr "返回旧界面" msgstr "返回旧界面"
msgid "Custom quick commands"
msgstr "自定义快捷命令"
msgid "Customize your quick commands"
msgstr "自定义你的快捷命令"
msgid "Custom Commands"
msgstr "自定义命令"
msgid "Modem Information" msgid "Modem Information"
msgstr "模组信息" msgstr "模组信息"

View File

@ -2,3 +2,207 @@
config global 'global' config global 'global'
option enable '1' option enable '1'
option modem_number '0' option modem_number '0'
config custom-commands
option description '****************通用****************'
option command 'ATI'
config custom-commands
option description '模组信息 > ATI'
option command 'ATI'
config custom-commands
option description '查询SIM卡状态 > AT+CPIN?'
option command 'AT+CSQ'
config custom-commands
option description '查询此时信号强度 > AT+CSQ'
option command 'AT+CSQ'
config custom-commands
option description '查询网络信息 > AT+COPS?'
option command 'AT+COPS?'
config custom-commands
option description '查询PDP信息 > AT+CGDCONT?'
option command 'AT+CGDCONT?'
config custom-commands
option description '最小功能模式 > AT+CFUN=0'
option command 'AT+CFUN=0'
config custom-commands
option description '全功能模式 > AT+CFUN=1'
option command 'AT+CFUN=1'
config custom-commands
option description '****************移远****************'
option command 'ATI'
config custom-commands
option description 'SIM卡状态上报 > AT+QSIMSTAT?'
option command 'AT+QSIMSTAT?'
config custom-commands
option description '设置当前使用的为卡1 > AT+QUIMSLOT=1'
option command 'AT+QUIMSLOT=1'
config custom-commands
option description '设置当前使用的为卡2 > AT+QUIMSLOT=2'
option command 'AT+QUIMSLOT=2'
config custom-commands
option description '查询网络信息 > AT+QNWINFO'
option command 'AT+QNWINFO'
config custom-commands
option description '查询载波聚合参数 > AT+QCAINFO'
option command 'AT+QCAINFO'
config custom-commands
option description '查询当前拨号模式 > AT+QCFG="usbnet"'
option command 'AT+QCFG="usbnet"'
config custom-commands
option description 'QMI/GobiNet拨号 > AT+QCFG="usbnet",0'
option command 'AT+QCFG="usbnet",0'
config custom-commands
option description 'ECM拨号 > AT+QCFG="usbnet",1'
option command 'AT+QCFG="usbnet",1'
config custom-commands
option description 'MBIM拨号 > AT+QCFG="usbnet",2'
option command 'AT+QCFG="usbnet",2'
config custom-commands
option description 'RNDIS拨号 > AT+QCFG="usbnet",3'
option command 'AT+QCFG="usbnet",3'
config custom-commands
option description 'NCM拨号 > AT+QCFG="usbnet",5'
option command 'AT+QCFG="usbnet",5'
config custom-commands
option description '锁4G > AT+QNWPREFCFG="mode_pref",LTE'
option command 'AT+QNWPREFCFG="mode_pref",LTE'
config custom-commands
option description '锁5G > AT+QNWPREFCFG="mode_pref",NR5G'
option command 'AT+QNWPREFCFG="mode_pref",NR5G'
config custom-commands
option description '恢复自动搜索网络 > AT+QNWPREFCFG="mode_pref",AUTO'
option command 'AT+QNWPREFCFG="mode_pref",AUTO'
config custom-commands
option description '查询模组IMEI > AT+CGSN'
option command 'AT+CGSN'
config custom-commands
option description '查询模组IMEI > AT+GSN'
option command 'AT+GSN'
config custom-commands
option description '更改模组IMEI > AT+EGMR=1,7,"IMEI"'
option command 'AT+EGMR=1,7,"在此设置IMEI"'
config custom-commands
option description '获取模组温度 > AT+QTEMP'
option command 'AT+QTEMP'
config custom-commands
option description '切换为USB通信端口 > AT+QCFG="data_interface",0,0'
option command 'AT+QCFG="data_interface",0,0'
config custom-commands
option description '切换为PCIE通信端口 > AT+QCFG="data_interface",1,0'
option command 'AT+QCFG="data_interface",1,0'
config custom-commands
option description '重置模组 > AT+CFUN=1,1'
option command 'AT+CFUN=1,1'
config custom-commands
option description '****************广和通****************'
option command 'ATI'
config custom-commands
option description '设置当前使用的为卡1 > AT+GTDUALSIM=0'
option command 'AT+GTDUALSIM=0'
config custom-commands
option description '设置当前使用的为卡2 > AT+GTDUALSIM=1'
option command 'AT+GTDUALSIM=1'
config custom-commands
option description 'ECM手动拨号 > AT+GTRNDIS=1,1'
option command 'AT+GTRNDIS=1,1'
config custom-commands
option description 'ECM拨号断开 > AT+GTRNDIS=0,1'
option command 'AT+GTRNDIS=0,1'
config custom-commands
option description '查询当前端口模式 > AT+GTUSBMODE?'
option command 'AT+GTUSBMODE?'
config custom-commands
option description 'QMI/GobiNet拨号 > AT+GTUSBMODE=32'
option command 'AT+GTUSBMODE=32'
config custom-commands
option description 'ECM拨号 > AT+GTUSBMODE=18'
option command 'AT+GTUSBMODE=18'
config custom-commands
option description 'MBIM拨号 > AT+GTUSBMODE=30'
option command 'AT+GTUSBMODE=30'
config custom-commands
option description 'RNDIS拨号 > AT+GTUSBMODE=24'
option command 'AT+GTUSBMODE=24'
config custom-commands
option description 'NCM拨号 > AT+GTUSBMODE=18'
option command 'AT+GTUSBMODE=18'
config custom-commands
option description '锁4G > AT+GTACT=2":"AT+GTACT=2'
option command 'AT+GTACT=2'
config custom-commands
option description '锁5G > AT+GTACT=14'
option command 'AT+GTACT=14'
config custom-commands
option description '恢复自动搜索网络 > AT+GTACT=20'
option command 'AT+GTACT=20'
config custom-commands
option description '查询当前连接的网络类型 > AT+PSRAT?'
option command 'AT+PSRAT?'
config custom-commands
option description '查询模组IMEI > AT+CGSN?'
option command 'AT+CGSN?'
config custom-commands
option description '查询模组IMEI > AT+GSN?'
option command 'AT+GSN?'
config custom-commands
option description '更改模组IMEI > AT+GTSN=1,7,"IMEI"'
option command 'AT+GTSN=1,7,"在此设置IMEI"'
config custom-commands
option description '报告一次当前BBIC的温度 > AT+MTSM=1,6'
option command 'AT+MTSM=1,6'
config custom-commands
option description '报告一次当前射频的温度 > AT+MTSM=1,7'
option command 'AT+MTSM=1,7'
config custom-commands
option description '重置模组 > AT+CFUN=15'
option command 'AT+CFUN=15'