From ed129d6348ea4f4703d658049d7e55ddf59bc590 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Sun, 7 Apr 2024 21:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=95=E5=B1=82=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0FM350=E6=A8=A1=E7=BB=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/luasrc/controller/modem.lua | 80 +- .../luasrc/model/cbi/modem/config.lua | 6 + .../luasrc/model/cbi/modem/index.lua | 5 + .../luasrc/view/modem/modem_debug.htm | 144 ++- luci-app-modem/note/OpenWRT软件开发.md | 157 ++++ .../note/old/view/modem/modem_info.htm | 420 +++++++++ .../note/old/view/modem/modem_status.htm | 124 +++ luci-app-modem/po/zh-cn/modem.po | 458 ---------- luci-app-modem/root/etc/config/modem | 6 +- .../root/etc/hotplug.d/net/20-modem-net | 24 + .../root/etc/hotplug.d/usb/20-modem-usb | 19 + luci-app-modem/root/etc/init.d/modem | 392 ++++---- luci-app-modem/root/etc/init.d/modeminit | 18 +- .../root/etc/uci-defaults/luci-app-modem | 3 +- .../usr/share/modem/custom_at_commands.json | 1 + .../root/usr/share/modem/fibocom.sh | 225 +++-- .../usr/share/modem/fibocom_at_commands.json | 1 + .../root/usr/share/modem/modem_at.sh | 9 +- .../root/usr/share/modem/modem_debug.sh | 41 +- .../root/usr/share/modem/modem_info.sh | 30 +- .../root/usr/share/modem/modem_init.sh | 27 + .../usr/share/modem/modem_network_task.sh | 210 ++++- .../root/usr/share/modem/modem_scan.sh | 187 ++-- .../root/usr/share/modem/modem_support.json | 28 +- .../root/usr/share/modem/modem_task.sh | 9 +- .../root/usr/share/modem/modem_util.sh | 845 ++++++++++++++++++ .../root/usr/share/modem/quectel.sh | 125 ++- .../usr/share/modem/quectel_at_commands.json | 1 + luci-app-modem/root/usr/share/modem/simcom.sh | 4 + 29 files changed, 2705 insertions(+), 894 deletions(-) create mode 100644 luci-app-modem/note/OpenWRT软件开发.md create mode 100644 luci-app-modem/note/old/view/modem/modem_info.htm create mode 100644 luci-app-modem/note/old/view/modem/modem_status.htm delete mode 100644 luci-app-modem/po/zh-cn/modem.po create mode 100644 luci-app-modem/root/etc/hotplug.d/net/20-modem-net create mode 100644 luci-app-modem/root/etc/hotplug.d/usb/20-modem-usb create mode 100644 luci-app-modem/root/usr/share/modem/modem_init.sh create mode 100644 luci-app-modem/root/usr/share/modem/modem_util.sh diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua index 04f1efd..5067038 100644 --- a/luci-app-modem/luasrc/controller/modem.lua +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -54,25 +54,46 @@ end at_command AT命令 ]] function at(at_port,at_command) - local odpall = io.popen("cd "..script_path.." && source "..script_path.."modem_debug.sh && 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 end +--[[ +@Description 获取模组拨号模式 +@Params + at_port AT串口 + manufacturer 制造商 + platform 平台 +]] +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", "") + end + + return mode +end + --[[ @Description 获取模组连接状态 @Params at_port AT串口 manufacturer 制造商 + define_connect 连接定义 ]] -function getModemConnectStatus(at_port,manufacturer) +function getModemConnectStatus(at_port,manufacturer,define_connect) local connect_status="unknown" if at_port and manufacturer~="unknown" then - local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port) + 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", "") @@ -94,7 +115,7 @@ function getModemDeviceInfo(at_port) --获取数据接口 local data_interface=modem_device["data_interface"]:upper() --获取连接状态 - local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"]) + local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"],modem_device["define_connect"]) --设置值 modem_device_info=modem_device @@ -113,10 +134,10 @@ end at_port AT串口 manufacturer 制造商 ]] -function getModemMoreInfo(at_port,manufacturer) +function getModemMoreInfo(at_port,manufacturer,define_connect) --获取模组信息 - local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer) + local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect) local opd = odpall:read("*a") odpall:close() @@ -138,7 +159,7 @@ function getModemInfo() local modem_more_info if at_port then modem_device_info=getModemDeviceInfo(at_port) - modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"]) + modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"],modem_device_info["define_connect"]) end --设置信息 @@ -254,16 +275,21 @@ function getModems() local translation={} uci:foreach("modem", "modem-device", function (modem_device) -- 获取连接状态 - local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"]) + local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"],modem_device["define_connect"]) + -- 获取拨号模式 + local mode=getMode(modem_device["at_port"],modem_device["manufacturer"],modem_device["platform"]) -- 获取翻译 translation[connect_status]=luci.i18n.translate(connect_status) - translation[modem_device["name"]]=luci.i18n.translate(modem_device["name"]) - translation[modem_device["mode"]]=luci.i18n.translate(modem_device["mode"]) + if modem_device["name"] then + translation[modem_device["name"]]=luci.i18n.translate(modem_device["name"]) + end + translation[mode]=luci.i18n.translate(mode) -- 设置值 local modem=modem_device modem["connect_status"]=connect_status + modem["mode"]=mode local modem_tmp={} modem_tmp[modem_device[".name"]]=modem @@ -381,7 +407,7 @@ function getQuickCommands() 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(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() @@ -437,13 +463,13 @@ function setNetworkPrefer() end) --设置模组网络偏好 - local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config) + 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("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port) + 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() @@ -473,13 +499,13 @@ function setMode() end) --设置模组拨号模式 - local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config) + 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("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port) + 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() @@ -509,7 +535,7 @@ function getModeInfo(at_port,manufacturer) end) --获取模组拨号模式 - local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port) + 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", "") @@ -531,7 +557,7 @@ end function getNetworkPreferInfo(at_port,manufacturer) --获取模组网络偏好 - local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port) + local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port) local opd = odpall:read("*a") odpall:close() local network_prefer_info=json.parse(opd) @@ -539,6 +565,23 @@ function getNetworkPreferInfo(at_port,manufacturer) return network_prefer_info end +--[[ +@Description 获取自检信息 +@Params + at_port AT串口 + manufacturer 制造商 +]] +function getSelfTestInfo(at_port,manufacturer) + + --获取模组自检信息 + local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_self_test_info "..at_port) + local opd = odpall:read("*a") + odpall:close() + local self_test_info=json.parse(opd) + + return self_test_info +end + --[[ @Description 获取模组调试信息 ]] @@ -559,15 +602,18 @@ function getModemDebugInfo() --获取值 local mode_info={} local network_prefer_info={} + local self_test_info={} if manufacturer~="unknown" then mode_info=getModeInfo(at_port,manufacturer) network_prefer_info=getNetworkPreferInfo(at_port,manufacturer) + self_test_info=getSelfTestInfo(at_port,manufacturer) end --设置值 local modem_debug_info={} modem_debug_info["mode_info"]=mode_info modem_debug_info["network_prefer_info"]=network_prefer_info + modem_debug_info["self_test_info"]=self_test_info -- 写入Web界面 luci.http.prepare_content("application/json") diff --git a/luci-app-modem/luasrc/model/cbi/modem/config.lua b/luci-app-modem/luasrc/model/cbi/modem/config.lua index 94f5b9a..b8e99b6 100644 --- a/luci-app-modem/luasrc/model/cbi/modem/config.lua +++ b/luci-app-modem/luasrc/model/cbi/modem/config.lua @@ -84,6 +84,12 @@ pdp_type:value("ipv4", translate("IPv4")) pdp_type:value("ipv6", translate("IPv6")) pdp_type:value("ipv4v6", translate("IPv4/IPv6")) +-- 网络桥接 +network_bridge = s:taboption("advanced", Flag, "network_bridge", translate("Network Bridge")) +network_bridge.description = translate("After checking, enable network interface bridge.") +network_bridge.default = "0" +network_bridge.rmempty = false + -- 接入点 apn = s:taboption("advanced", Value, "apn", translate("APN")) apn.default = "" diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua index fc856c3..9afb953 100644 --- a/luci-app-modem/luasrc/model/cbi/modem/index.lua +++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua @@ -68,6 +68,7 @@ o.cfgvalue = function(t, n) return translate(dial_tool) end + o = s:option(DummyValue, "pdp_type", translate("PDP Type")) o.cfgvalue = function(t, n) local pdp_type = (Value.cfgvalue(t, n) or "") @@ -79,6 +80,10 @@ o.cfgvalue = function(t, n) return pdp_type end +o = s:option(Flag, "network_bridge", translate("Network Bridge")) +o.width = "5%" +o.rmempty = false + o = s:option(DummyValue, "apn", translate("APN")) o.cfgvalue = function(t, n) local apn = (Value.cfgvalue(t, n) or "") diff --git a/luci-app-modem/luasrc/view/modem/modem_debug.htm b/luci-app-modem/luasrc/view/modem/modem_debug.htm index d660ffe..5643416 100644 --- a/luci-app-modem/luasrc/view/modem/modem_debug.htm +++ b/luci-app-modem/luasrc/view/modem/modem_debug.htm @@ -182,6 +182,8 @@ document.getElementById("cbi-mode").style.display="none"; //隐藏网络偏好界面 document.getElementById("cbi-network-prefer").style.display="none"; + //隐藏模组自检界面 + document.getElementById("cbi-modem-self-test").style.display="none"; //隐藏AT界面 document.getElementById("cbi-at").style.display="none"; } @@ -208,6 +210,8 @@ document.getElementById("cbi-mode").style.display="none"; //隐藏网络偏好界面 document.getElementById("cbi-network-prefer").style.display="none"; + //隐藏模组自检界面 + document.getElementById("cbi-modem-self-test").style.display="none"; } // 全功能界面 @@ -217,6 +221,8 @@ document.getElementById("cbi-mode").style.display="block"; //显示网络偏好界面 document.getElementById("cbi-network-prefer").style.display="block"; + //显示模组自检界面 + document.getElementById("cbi-modem-self-test").style.display="block"; //隐藏提示信息 document.getElementById("cbi-info").style.display="none"; } @@ -320,12 +326,14 @@ //拨号模式 if (function_name=="mode") { - //模式选项 - document.getElementById('mode_option_qmi').disabled=status; - document.getElementById('mode_option_ecm').disabled=status; - document.getElementById('mode_option_mbim').disabled=status; - document.getElementById('mode_option_rndis').disabled=status; - document.getElementById('mode_option_ncm').disabled=status; + modes=["qmi","ecm","mbim","rndis","ncm"] + for(mode of modes) + { + mode_element=document.getElementById('mode_option_'+mode) + if (mode_element!=null) { + mode_element.disabled=status; + } + } //模式按钮 document.getElementById('mode_button').disabled=status; @@ -484,6 +492,49 @@ } } + // 设置模组自检信息 + function set_modem_self_test_info(self_test_info) + { + // console.log(self_test_info); + + //获取模组自检 + // var self_test=self_test_info["self_test"]; + + // //获取自检视图 + // var self_test_view=set_current_self_test_view(self_test); + // //获取 + // var self_test_view=set_current_self_test_view(self_test); + + // //设置当前电压信息 + // document.getElementById('current_voltage').innerHTML=current_self_test_view; + document.getElementById('current_voltage').innerHTML=self_test_info/1000; + + // 设置电压状态 + var state = ''; + var css = ''; + if (self_test_info<3135) + { + state = "<%:Abnormal%>"; + color = "red"; + } + else if (self_test_info>3135 && self_test_info<3300) + { + state = "<%:Low%>"; + color = "goldenrod"; + } + else //大于3300(3.3V) + { + state = "<%:Normal%>"; + color = "green"; + } + var voltage_status=document.getElementById('voltage_status'); + voltage_status.innerHTML=state; + voltage_status.style.color=color + + // //设置当前温度信息 + // document.getElementById('current_temperature').innerHTML=current_self_test_view; + } + // 设置网络偏好 function set_network_prefer() { @@ -543,6 +594,7 @@ { var mode_info=data["mode_info"]; var network_prefer_info=data["network_prefer_info"]; + var self_test_info=data["self_test_info"]; if (Object.keys(mode_info).length==0||Object.keys(network_prefer_info).length==0) { //显示未适配模组界面 not_adapted_modems_view(); @@ -555,6 +607,9 @@ //设置网络偏好信息 set_network_prefer_info(network_prefer_info,debug_params.first_cache); + //设置模组自检信息 + set_modem_self_test_info(self_test_info); + //设置第一次获取数据标志 debug_params.first_cache=false; @@ -599,6 +654,9 @@ get_quick_commands(); } modem_select_cache=select_modem_name; + + //设置第一次获取数据标志 + debug_params.first_cache=true; } //获取模组调试信息 @@ -693,6 +751,54 @@ + + + + + +