From 5bdd98356fc014b887b75082c433e051b31490c5 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Thu, 7 Mar 2024 09:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0RM520N=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luasrc/model/cbi/modem/index.lua | 2 +- .../model/cbi/modem/quick_commands_config.lua | 2 +- .../luasrc/view/modem/at_command_old.htm | 36 +-- .../luasrc/view/modem/tblsection.htm | 203 +++++++++++++++++ .../luasrc/view/modem/tblsection_command.htm | 208 ++++++++++++++++++ luci-app-modem/po/zh-cn/modem.po | 9 + luci-app-modem/root/etc/config/modem | 16 ++ .../usr/share/modem/custom_at_commands.json | 4 + .../root/usr/share/modem/modem_support.json | 12 + .../usr/share/modem/quectel_at_commands.json | 4 + 10 files changed, 481 insertions(+), 15 deletions(-) create mode 100644 luci-app-modem/luasrc/view/modem/tblsection.htm create mode 100644 luci-app-modem/luasrc/view/modem/tblsection_command.htm diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua index 81d9edc..11a4802 100644 --- a/luci-app-modem/luasrc/model/cbi/modem/index.lua +++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua @@ -20,7 +20,7 @@ m:append(Template("modem/modem_status")) s = m:section(TypedSection, "config", translate("Config List")) s.anonymous = true s.addremove = true -s.template = "cbi/tblsection" +s.template = "modem/tblsection" s.extedit = d.build_url("admin", "network", "modem", "config", "%s") function s.create(uci, t) 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 1d3cb43..68cb9de 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 @@ -15,7 +15,7 @@ s = m:section(TypedSection, "custom-commands", translate("Custom Commands")) s.anonymous = true s.addremove = true s.sortable = true -s.template = "cbi/tblsection" +s.template = "modem/tblsection_command" description = s:option(Value, "description", translate("Description")) description.placeholder = translate("Not Null") diff --git a/luci-app-modem/luasrc/view/modem/at_command_old.htm b/luci-app-modem/luasrc/view/modem/at_command_old.htm index afe4211..fd168fb 100644 --- a/luci-app-modem/luasrc/view/modem/at_command_old.htm +++ b/luci-app-modem/luasrc/view/modem/at_command_old.htm @@ -50,28 +50,35 @@ // 定时触发更新AT串口 XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "modem", "get_at_port")%>', null, - function(x, port) + function(x, data) { + var at_ports=data["at_ports"]; + //获取模块选择框元素 var modem_select = document.getElementById('modem_select'); // 记录所选 var selected=modem_select.value; // 删除原来的选项 modem_select.options.length=0; - // 更新(key:AT串口,value:模块名称) - for (var key in port) + //遍历每一个AT串口 + for (var port of at_ports) { - var option = document.createElement('option'); - option.value = key; - if (port[key].includes("unknown")) + //更新(key:AT串口,value:模块名称) + for (var key in port) { - option.text = port[key].replace("unknown", key); + var option = document.createElement('option'); + option.value = key; + var language=navigator.language; + if (port[key].includes("unknown")) + { + option.text = port[key].replace("unknown", key); + } + else + { + option.text = port[key]; + } + modem_select.appendChild(option); } - else - { - option.text = port[key]; - } - modem_select.appendChild(option); } // 恢复原来的选择 for (let i = 0; i < modem_select.options.length; i++) @@ -84,7 +91,7 @@ } // 界面显示控制 - if (Object.keys(port).length==0) + if (Object.keys(at_ports).length==0) { // 更新提示信息 document.getElementById("info_message").innerHTML="<%:No modems found%>"; @@ -235,7 +242,10 @@
+ +
+
diff --git a/luci-app-modem/luasrc/view/modem/tblsection.htm b/luci-app-modem/luasrc/view/modem/tblsection.htm new file mode 100644 index 0000000..1cba660 --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/tblsection.htm @@ -0,0 +1,203 @@ +<%- +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 + + %>><% + + local i, k + for i, k in ipairs(self.children) do + if not k.optional then + %>><% + + if k.titleref then + %><% + end + + write(k.title) + + if k.titleref then + %><% + end + + %><% + end + end + + if self.sortable or self.extedit or self.addremove then + %><% + end + + %><% + + rowcnt = rowcnt + 1 +end + +function render_descriptions() + if not has_descriptions then + return + end + + %><% + + local i, k + for i, k in ipairs(self.children) do + if not k.optional then + %>><% + + write(k.description) + + %><% + end + end + + if self.sortable or self.extedit or self.addremove then + %><% + end + + %><% + + rowcnt = rowcnt + 1 +end + +-%> + + +
+ <% if self.title and #self.title > 0 then -%> +

<%=self.title%>

+ <%- end %> + <%- if self.sortable then -%> + + <%- end -%> +
<%=self.description%>
+ + <%- + 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" + } + -%> + > + <%- + 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 -%> + + <%- end -%> + + <%- end -%> + + <%- if isempty then -%> + + + + <%- end -%> +
+
+ <%- if self.sortable then -%> + + + <% end; if self.extedit 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 %> + + <%- end -%> +
+
<%:This section contains no values yet%>
+ + <% if self.error then %> +
+ +
+ <% end %> + + <%- if self.addremove then -%> + <% if self.template_addremove then include(self.template_addremove) else -%> +
+ <% if self.anonymous then %> + + <% else %> + <% if self.invalid_cts then -%> +
<%:Invalid%>
+ <%- end %> +
+ +
+ + <% end %> +
+ <%- end %> + <%- end -%> +
+ diff --git a/luci-app-modem/luasrc/view/modem/tblsection_command.htm b/luci-app-modem/luasrc/view/modem/tblsection_command.htm new file mode 100644 index 0000000..92839c8 --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/tblsection_command.htm @@ -0,0 +1,208 @@ +<%- +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 + + %>> + <%:Serial Number%> + <% + local i, k + for i, k in ipairs(self.children) do + if not k.optional then + %>><% + + if k.titleref then + %><% + end + + write(k.title) + + if k.titleref then + %><% + end + + %><% + end + end + + if self.sortable or self.extedit or self.addremove then + %><% + end + + %><% + + rowcnt = rowcnt + 1 +end + +function render_descriptions() + if not has_descriptions then + return + end + + %><% + + local i, k + for i, k in ipairs(self.children) do + if not k.optional then + %>><% + + write(k.description) + + %><% + end + end + + if self.sortable or self.extedit or self.addremove then + %><% + end + + %><% + + rowcnt = rowcnt + 1 +end + +-%> + + +
+ <% if self.title and #self.title > 0 then -%> +

<%=self.title%>

+ <%- end %> + <%- if self.sortable then -%> + + <%- end -%> +
<%=self.description%>
+ + <%- + 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" + } + -%> + > + + <%- + 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 -%> + + <%- end -%> + + <%- end -%> + + <%- if isempty then -%> + + + + <%- end -%> +
+

<%=num%>

+ <% num = num + 1 -%> +
+
+ <%- if self.sortable then -%> + + + <% end; if self.extedit 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 %> + + <%- end -%> +
+
<%:This section contains no values yet%>
+ + <% if self.error then %> +
+ +
+ <% end %> + + <%- if self.addremove then -%> + <% if self.template_addremove then include(self.template_addremove) else -%> +
+ <% if self.anonymous then %> + + <% else %> + <% if self.invalid_cts then -%> +
<%:Invalid%>
+ <%- end %> +
+ +
+ + <% end %> +
+ <%- end %> + <%- end -%> +
+ diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po index 0ff5fb3..f9a7e35 100644 --- a/luci-app-modem/po/zh-cn/modem.po +++ b/luci-app-modem/po/zh-cn/modem.po @@ -124,6 +124,15 @@ msgstr "自定义你的快捷命令" msgid "Custom Commands" msgstr "自定义命令" +msgid "Serial Number" +msgstr "序号" + +msgid "Description" +msgstr "描述" + +msgid "Command" +msgstr "命令" + msgid "Modem Information" msgstr "模组信息" diff --git a/luci-app-modem/root/etc/config/modem b/luci-app-modem/root/etc/config/modem index b6a2665..daa3138 100644 --- a/luci-app-modem/root/etc/config/modem +++ b/luci-app-modem/root/etc/config/modem @@ -119,6 +119,22 @@ 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 '查看当前USB速率 > AT+QCFG="usbspeed"' + option command 'AT+QCFG="usbspeed"' + +config custom-commands + option description '切换为USB2.0 > AT+QCFG="usbspeed","20"' + option command 'AT+QCFG="usbspeed","20"' + +config custom-commands + option description '切换为USB3.1 Gen1(5Gbps) > AT+QCFG="usbspeed","311"' + option command 'AT+QCFG="usbspeed","311"' + +config custom-commands + option description '切换为USB3.1 Gen1(10Gbps) > AT+QCFG="usbspeed","312"' + option command 'AT+QCFG="usbspeed","312"' + config custom-commands option description '重置模组 > AT+CFUN=1,1' option command 'AT+CFUN=1,1' diff --git a/luci-app-modem/root/usr/share/modem/custom_at_commands.json b/luci-app-modem/root/usr/share/modem/custom_at_commands.json index 6c1bcc0..59828de 100644 --- a/luci-app-modem/root/usr/share/modem/custom_at_commands.json +++ b/luci-app-modem/root/usr/share/modem/custom_at_commands.json @@ -29,6 +29,10 @@ {"获取模组温度 > AT+QTEMP":"AT+QTEMP"}, {"切换为USB通信端口 > AT+QCFG=\"data_interface\",0,0":"AT+QCFG=\"data_interface\",0,0"}, {"切换为PCIE通信端口 > AT+QCFG=\"data_interface\",1,0":"AT+QCFG=\"data_interface\",1,0"}, + {"查看当前USB速率 > AT+QCFG=\"usbspeed\"":"AT+QCFG=\"usbspeed\""}, + {"切换为USB2.0 > AT+QCFG=\"usbspeed\",\"20\"":"AT+QCFG=\"usbspeed\",\"20\""}, + {"切换为USB3.1 Gen1(5Gbps) > AT+QCFG=\"usbspeed\",\"311\"":"AT+QCFG=\"usbspeed\",\"311\""}, + {"切换为USB3.1 Gen1(10Gbps) > AT+QCFG=\"usbspeed\",\"312\"":"AT+QCFG=\"usbspeed\",\"312\""}, {"重置模组 > AT+CFUN=1,1":"AT+CFUN=1,1"}, {"****************广和通****************":"ATI"}, {"设置当前使用的为卡1 > AT+GTDUALSIM=0":"AT+GTDUALSIM=0"}, diff --git a/luci-app-modem/root/usr/share/modem/modem_support.json b/luci-app-modem/root/usr/share/modem/modem_support.json index 0836a83..1cfc7a1 100644 --- a/luci-app-modem/root/usr/share/modem/modem_support.json +++ b/luci-app-modem/root/usr/share/modem/modem_support.json @@ -25,6 +25,18 @@ "network_interface":"usb", "modes":["qmi","gobinet","ecm","mbim","rndis","ncm"] }, + "rm520n-cn":{ + "manufacturer":"quectel", + "platform":"qualcomm", + "network_interface":"usb", + "modes":["qmi","gobinet","ecm","mbim","rndis","ncm"] + }, + "rm520n-gl":{ + "manufacturer":"quectel", + "platform":"qualcomm", + "network_interface":"usb", + "modes":["qmi","gobinet","ecm","mbim","rndis","ncm"] + }, "fm650-cn":{ "manufacturer":"fibocom", "platform":"unisoc", diff --git a/luci-app-modem/root/usr/share/modem/quectel_at_commands.json b/luci-app-modem/root/usr/share/modem/quectel_at_commands.json index c43a932..9ebe46f 100644 --- a/luci-app-modem/root/usr/share/modem/quectel_at_commands.json +++ b/luci-app-modem/root/usr/share/modem/quectel_at_commands.json @@ -27,6 +27,10 @@ {"获取模组温度 > AT+QTEMP":"AT+QTEMP"}, {"切换为USB通信端口 > AT+QCFG=\"data_interface\",0,0":"AT+QCFG=\"data_interface\",0,0"}, {"切换为PCIE通信端口 > AT+QCFG=\"data_interface\",1,0":"AT+QCFG=\"data_interface\",1,0"}, + {"查看当前USB速率 > AT+QCFG=\"usbspeed\"":"AT+QCFG=\"usbspeed\""}, + {"切换为USB2.0 > AT+QCFG=\"usbspeed\",\"20\"":"AT+QCFG=\"usbspeed\",\"20\""}, + {"切换为USB3.1 Gen1(5Gbps) > AT+QCFG=\"usbspeed\",\"311\"":"AT+QCFG=\"usbspeed\",\"311\""}, + {"切换为USB3.1 Gen1(10Gbps) > AT+QCFG=\"usbspeed\",\"312\"":"AT+QCFG=\"usbspeed\",\"312\""}, {"重置模组 > AT+CFUN=1,1":"AT+CFUN=1,1"} ] }