From 75abd1f7b9029a16a2171cd99055e120e686db96 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Thu, 29 Feb 2024 17:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E5=91=BD=E4=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/luasrc/controller/modem.lua | 28 ++- .../luasrc/model/cbi/modem/config.lua | 4 +- .../model/cbi/modem/quick_commands_config.lua | 47 ++-- .../luasrc/view/modem/modem_debug.htm | 1 + luci-app-modem/po/zh-cn/modem.po | 9 + luci-app-modem/root/etc/config/modem | 204 ++++++++++++++++++ .../share}/modem/custom_at_commands.json | 0 7 files changed, 247 insertions(+), 46 deletions(-) rename luci-app-modem/root/{etc => usr/share}/modem/custom_at_commands.json (100%) diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua index b2ba8e4..b2ef176 100644 --- a/luci-app-modem/luasrc/controller/modem.lua +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -31,12 +31,10 @@ function index() 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_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true + entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).leaf = true --AT命令旧界面 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 --[[ @@ -357,12 +355,24 @@ function getQuickCommands() quick_option="custom" end - --获取模组AT命令 - local odpall = io.popen("cd "..script_path.." && source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer) - local opd = odpall:read("*a") - odpall:close() - local quick_commands=json.parse(opd) - + local quick_commands={} + local commands={} + if quick_option=="auto" then + --获取模组AT命令 + -- 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界面 luci.http.prepare_content("application/json") luci.http.write_json(quick_commands) diff --git a/luci-app-modem/luasrc/model/cbi/modem/config.lua b/luci-app-modem/luasrc/model/cbi/modem/config.lua index d40cb70..dd4fa10 100644 --- a/luci-app-modem/luasrc/model/cbi/modem/config.lua +++ b/luci-app-modem/luasrc/model/cbi/modem/config.lua @@ -1,9 +1,9 @@ -local d = require "luci.dispatcher" +local dispatcher = require "luci.dispatcher" local uci = require "luci.model.uci".cursor() local http = require "luci.http" 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.addremove = false diff --git a/luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua b/luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua index 48960d5..1d3cb43 100644 --- a/luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua +++ b/luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua @@ -1,53 +1,30 @@ --- Copyright 2020-2021 Rafa� Wabik (IceG) - From eko.one.pl forum --- Licensed to the GNU General Public License v3.0. +-- Copyright 2024 Siriling local dispatcher = require "luci.dispatcher" local fs = require "nixio.fs" local http = require "luci.http" local uci = require "luci.model.uci".cursor() -local AT_FILE_PATH = "/etc/modem/custom_at_commands.json" - -m = Map("sms_tool") -m.title = translate("Configuration sms-tool") -m.description = translate("Configuration panel for sms_tool and gui application.") +m = Map("modem") +m.title = translate("Custom quick commands") +m.description = translate("Customize your quick commands") +m.redirect = dispatcher.build_url("admin", "network", "modem","modem_debug") -- 自定义命令 -- -s = m:section(TypedSection, "custom_at_commands", translate("Custom AT Commands")) +s = m:section(TypedSection, "custom-commands", translate("Custom Commands")) s.anonymous = true s.addremove = true +s.sortable = true s.template = "cbi/tblsection" description = s:option(Value, "description", translate("Description")) -description.placeholder = "" -description.rmempty = false +description.placeholder = translate("Not Null") +description.rmempty = true description.optional = false command = s:option(Value, "command", translate("Command")) --- command.placeholder = "" -command.rmempty = false --- command.optional = false - -function command.cfgvalue(self, section) - local custom_commands=fs.readfile(AT_FILE_PATH) - return "模组信息 > ATI" -end - --- RAW File -- -s = m:section(NamedSection, 'general' , "sms_tool" , translate("")) -s.anonymous = true - -local tat = s:option(TextValue, "user_at", translate("User AT Commands"), translate("Each line must have the following format: 'AT Command name;AT Command'. Save to file '/etc/config/atcmds.user'.")) -tat.rows = 20 -tat.rmempty = true - -function tat.cfgvalue(self, section) - return fs.readfile(AT_FILE_PATH) -end - -function tat.write(self, section, value) - value = value:gsub("\r\n", "\n") - fs.writefile(AT_FILE_PATH, value) -end +command.placeholder = translate("Not Null") +command.rmempty = true +command.optional = false return m diff --git a/luci-app-modem/luasrc/view/modem/modem_debug.htm b/luci-app-modem/luasrc/view/modem/modem_debug.htm index 0ad9fca..5c31d8a 100644 --- a/luci-app-modem/luasrc/view/modem/modem_debug.htm +++ b/luci-app-modem/luasrc/view/modem/modem_debug.htm @@ -824,6 +824,7 @@
+
diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po index 22d698f..0ff5fb3 100644 --- a/luci-app-modem/po/zh-cn/modem.po +++ b/luci-app-modem/po/zh-cn/modem.po @@ -115,6 +115,15 @@ msgstr "响应" msgid "Return to old page" msgstr "返回旧界面" +msgid "Custom quick commands" +msgstr "自定义快捷命令" + +msgid "Customize your quick commands" +msgstr "自定义你的快捷命令" + +msgid "Custom Commands" +msgstr "自定义命令" + msgid "Modem Information" msgstr "模组信息" diff --git a/luci-app-modem/root/etc/config/modem b/luci-app-modem/root/etc/config/modem index 05474a3..b6a2665 100644 --- a/luci-app-modem/root/etc/config/modem +++ b/luci-app-modem/root/etc/config/modem @@ -2,3 +2,207 @@ config global 'global' option enable '1' 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' \ No newline at end of file diff --git a/luci-app-modem/root/etc/modem/custom_at_commands.json b/luci-app-modem/root/usr/share/modem/custom_at_commands.json similarity index 100% rename from luci-app-modem/root/etc/modem/custom_at_commands.json rename to luci-app-modem/root/usr/share/modem/custom_at_commands.json