From 398dad1789d8b5aef9d440fcc1572a81f67d474c Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Fri, 2 Feb 2024 11:01:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=81=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/luasrc/controller/modem.lua | 2 +- .../model/cbi/modem/quick_commands_config.lua | 53 +++++++++++++++++++ .../root/usr/share/modem/fibocom.sh | 47 ++++++++++++---- .../root/usr/share/modem/quectel.sh | 47 ++++++++++++---- 4 files changed, 128 insertions(+), 21 deletions(-) create mode 100644 luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua index 982d5c4..5d27909 100644 --- a/luci-app-modem/luasrc/controller/modem.lua +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -36,7 +36,7 @@ function index() 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 + entry({"admin", "network", "modem", "quick_commands_config"},cbi("modem/quick_commands_config"),translate("自定义快捷命令配置"),40).leaf = true end --[[ 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 new file mode 100644 index 0000000..48960d5 --- /dev/null +++ b/luci-app-modem/luasrc/model/cbi/modem/quick_commands_config.lua @@ -0,0 +1,53 @@ +-- Copyright 2020-2021 Rafa� Wabik (IceG) - From eko.one.pl forum +-- Licensed to the GNU General Public License v3.0. + +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.") + +-- 自定义命令 -- +s = m:section(TypedSection, "custom_at_commands", translate("Custom AT Commands")) +s.anonymous = true +s.addremove = true +s.template = "cbi/tblsection" + +description = s:option(Value, "description", translate("Description")) +description.placeholder = "" +description.rmempty = false +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 + +return m diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh index c6f8cdb..3007056 100755 --- a/luci-app-modem/root/usr/share/modem/fibocom.sh +++ b/luci-app-modem/root/usr/share/modem/fibocom.sh @@ -65,21 +65,48 @@ get_mode() # $2:拨号模式配置 set_mode() { + local at_port="$1" + + #获取芯片平台 + local platform + local modem_number=$(uci -q get modem.global.modem_number) + for i in $(seq 0 $((modem_number-1))); do + local at_port_tmp=$(uci -q get modem.modem$i.at_port) + if [ "$at_port" = "$at_port_tmp" ]; then + platform=$(uci -q get modem.modem$i.platform) + break + fi + done + #获取拨号模式配置 local mode_num - - case "$2" in - "qmi") mode_num="32" ;; - # "gobinet") mode_num="32" ;; - "ecm") mode_num="18" ;; - "mbim") mode_num="30" ;; - "rndis") mode_num="24" ;; - "ncm") mode_num="18" ;; - *) mode_num="32" ;; + case "$platform" in + "qualcomm") + case "$2" in + "qmi") mode_num="32" ;; + # "gobinet") mode_num="32" ;; + "ecm") mode_num="18" ;; + "mbim") mode_num="30" ;; + "rndis") mode_num="24" ;; + "ncm") mode_num="18" ;; + *) mode_num="32" ;; + esac + ;; + "unisoc") + case "$2" in + "ecm") mode_num="34" ;; + "mbim") mode_num="40" ;; + "rndis") mode_num="38" ;; + "ncm") mode_num="36" ;; + *) mode_num="34" ;; + esac + ;; + *) + mode_num="32" + ;; esac #设置模组 - local at_port="$1" at_command="AT+GTUSBMODE=$mode_num" sh $current_dir/modem_at.sh $at_port "$at_command" } diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh index 78f18cb..b6f85e7 100755 --- a/luci-app-modem/root/usr/share/modem/quectel.sh +++ b/luci-app-modem/root/usr/share/modem/quectel.sh @@ -54,21 +54,48 @@ get_mode() # $2:拨号模式配置 set_mode() { + local at_port="$1" + + #获取芯片平台 + local platform + local modem_number=$(uci -q get modem.global.modem_number) + for i in $(seq 0 $((modem_number-1))); do + local at_port_tmp=$(uci -q get modem.modem$i.at_port) + if [ "$at_port" = "$at_port_tmp" ]; then + platform=$(uci -q get modem.modem$i.platform) + break + fi + done + #获取拨号模式配置 local mode_num - - case "$2" in - "qmi") mode_num="0" ;; - # "gobinet") mode_num="0" ;; - "ecm") mode_num="1" ;; - "mbim") mode_num="2" ;; - "rndis") mode_num="3" ;; - "ncm") mode_num="5" ;; - *) mode_num="0" ;; + case "$platform" in + "qualcomm") + case "$2" in + "qmi") mode_num="0" ;; + # "gobinet") mode_num="0" ;; + "ecm") mode_num="1" ;; + "mbim") mode_num="2" ;; + "rndis") mode_num="3" ;; + "ncm") mode_num="5" ;; + *) mode_num="0" ;; + esac + ;; + "unisoc") + case "$2" in + "ecm") mode_num="1" ;; + "mbim") mode_num="2" ;; + "rndis") mode_num="3" ;; + "ncm") mode_num="5" ;; + *) mode_num="0" ;; + esac + ;; + *) + mode_num="0" + ;; esac #设置模组 - local at_port="$1" at_command='AT+QCFG="usbnet",'$mode_num sh $current_dir/modem_at.sh $at_port "$at_command" }