From 37f24701400b19b277052bf09b8695809c219219 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Tue, 16 Apr 2024 08:37:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/icons/{delsms.png => sms.png} | Bin .../resources/icons/{delsms2.png => sms2.png} | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename luci-app-modem/htdocs/luci-static/resources/icons/{delsms.png => sms.png} (100%) rename luci-app-modem/htdocs/luci-static/resources/icons/{delsms2.png => sms2.png} (100%) diff --git a/luci-app-modem/htdocs/luci-static/resources/icons/delsms.png b/luci-app-modem/htdocs/luci-static/resources/icons/sms.png similarity index 100% rename from luci-app-modem/htdocs/luci-static/resources/icons/delsms.png rename to luci-app-modem/htdocs/luci-static/resources/icons/sms.png diff --git a/luci-app-modem/htdocs/luci-static/resources/icons/delsms2.png b/luci-app-modem/htdocs/luci-static/resources/icons/sms2.png similarity index 100% rename from luci-app-modem/htdocs/luci-static/resources/icons/delsms2.png rename to luci-app-modem/htdocs/luci-static/resources/icons/sms2.png From 1145bf688f0bd124cee34bf28103ba7774752dc6 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Tue, 16 Apr 2024 10:14:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-modem/Makefile b/luci-app-modem/Makefile index da6e3a3..4d93be9 100644 --- a/luci-app-modem/Makefile +++ b/luci-app-modem/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-modem LUCI_TITLE:=LuCI support for Modem LUCI_PKGARCH:=all -PKG_VERSION:=1.2.0 +PKG_VERSION:=1.3.0 PKG_LICENSE:=GPLv3 PKG_LINCESE_FILES:=LICENSE PKF_MAINTAINER:=siriling From 74b22dbc219a254a462845a3ef2496f7fe056531 Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Tue, 16 Apr 2024 15:48:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-modem/luasrc/controller/modem.lua | 473 ++++++++++----------- 1 file changed, 228 insertions(+), 245 deletions(-) diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua index 61f7b53..89a23b2 100644 --- a/luci-app-modem/luasrc/controller/modem.lua +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -26,15 +26,15 @@ function index() --模块调试 entry({"admin", "network", "modem", "modem_debug"},template("modem/modem_debug"),translate("Modem Debug"),30).leaf = true - entry({"admin", "network", "modem", "get_quick_commands"}, call("getQuickCommands"), nil).leaf = true - entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true - entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true + entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).leaf = true entry({"admin", "network", "modem", "get_mode_info"}, call("getModeInfo"), nil).leaf = true entry({"admin", "network", "modem", "set_mode"}, call("setMode"), nil).leaf = true entry({"admin", "network", "modem", "get_network_prefer_info"}, call("getNetworkPreferInfo"), nil).leaf = true entry({"admin", "network", "modem", "set_network_prefer"}, call("setNetworkPrefer"), nil).leaf = true entry({"admin", "network", "modem", "get_self_test_info"}, call("getSelfTestInfo"), nil).leaf = true - entry({"admin", "network", "modem", "quick_commands_config"}, cbi("modem/quick_commands_config")).leaf = true + entry({"admin", "network", "modem", "get_quick_commands"}, call("getQuickCommands"), nil).leaf = true + entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true + -- entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true --AT命令旧界面 entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true @@ -50,6 +50,18 @@ function hasLetters(str) return string.find(str, pattern) ~= nil end +--[[ +@Description 执行Shell脚本 +@Params + command sh命令 +]] +function shell(command) + local odpall = io.popen(command) + local odp = odpall:read("*a") + odpall:close() + return odp +end + --[[ @Description 执行AT命令 @Params @@ -57,11 +69,29 @@ end at_command AT命令 ]] function 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 + local command="source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command + local result=shell(command) + result=string.gsub(result, "\r", "") + return result +end + +--[[ +@Description 获取制造商 +@Params + at_port AT串口 +]] +function getManufacturer(at_port) + + local manufacturer + uci:foreach("modem", "modem-device", function (modem_device) + --设置模组AT串口 + if at_port == modem_device["at_port"] then + manufacturer=modem_device["manufacturer"] + return true --跳出循环 + end + end) + + return manufacturer end --[[ @@ -75,15 +105,33 @@ 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", "") + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform + local result=shell(command) + mode=string.gsub(result, "\n", "") end return mode end +--[[ +@Description 获取模组支持的拨号模式 +@Params + at_port AT串口 +]] +function getModes(at_port) + + local modes + uci:foreach("modem", "modem-device", function (modem_device) + --设置模组AT串口 + if at_port == modem_device["at_port"] then + modes=modem_device["modes"] + return true --跳出循环 + end + end) + + return modes +end + --[[ @Description 获取模组连接状态 @Params @@ -96,10 +144,9 @@ function getModemConnectStatus(at_port,manufacturer,define_connect) local connect_status="unknown" if at_port and manufacturer~="unknown" then - 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", "") + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect + local result=shell(command) + connect_status=string.gsub(result, "\n", "") end return connect_status @@ -140,12 +187,11 @@ end function getModemMoreInfo(at_port,manufacturer,define_connect) --获取模组信息 - local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect) - local opd = odpall:read("*a") - odpall:close() + local command="sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect + local result=shell(command) --设置值 - local modem_more_info=json.parse(opd) + local modem_more_info=json.parse(result) return modem_more_info end @@ -380,6 +426,160 @@ function getATPort() luci.http.write_json(data) end +--[[ +@Description 获取拨号模式信息 +]] +function getModeInfo() + local at_port = http.formvalue("port") + + --获取值 + local mode_info={} + uci:foreach("modem", "modem-device", function (modem_device) + --设置模组AT串口 + if at_port == modem_device["at_port"] then + + --获取制造商 + local manufacturer=modem_device["manufacturer"] + if manufacturer=="unknown" then + return true --跳出循环 + end + + --获取支持的拨号模式 + local modes=modem_device["modes"] + + --获取模组拨号模式 + local mode=getMode(at_port,manufacturer,modem_device["platform"]) + + --设置模式信息 + mode_info["mode"]=mode + mode_info["modes"]=modes + + return true --跳出循环 + end + end) + + --设置值 + local modem_debug_info={} + modem_debug_info["mode_info"]=mode_info + + -- 写入Web界面 + luci.http.prepare_content("application/json") + luci.http.write_json(modem_debug_info) +end + +--[[ +@Description 设置拨号模式 +]] +function setMode() + local at_port = http.formvalue("port") + local mode_config = http.formvalue("mode_config") + + --获取制造商 + local manufacturer=getManufacturer(at_port) + + --设置模组拨号模式 + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config + shell(command) + + --获取设置好后的模组拨号模式 + local mode + if at_port and manufacturer and manufacturer~="unknown" then + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port + local result=shell(command) + mode=string.gsub(result, "\n", "") + end + + -- 写入Web界面 + luci.http.prepare_content("application/json") + luci.http.write_json(mode) +end + +--[[ +@Description 获取网络偏好信息 +]] +function getNetworkPreferInfo() + local at_port = http.formvalue("port") + + --获取制造商 + local manufacturer=getManufacturer(at_port) + + --获取值 + local network_prefer_info + if manufacturer~="unknown" then + --获取模组网络偏好 + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port + local result=shell(command) + network_prefer_info=json.parse(result) + end + + --设置值 + local modem_debug_info={} + modem_debug_info["network_prefer_info"]=network_prefer_info + + -- 写入Web界面 + luci.http.prepare_content("application/json") + luci.http.write_json(modem_debug_info) +end + +--[[ +@Description 设置网络偏好 +]] +function setNetworkPrefer() + local at_port = http.formvalue("port") + local network_prefer_config = json.stringify(http.formvalue("prefer_config")) + + --获取制造商 + local manufacturer=getManufacturer(at_port) + + --设置模组网络偏好 + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config + shell(command) + + --获取设置好后的模组网络偏好 + local network_prefer={} + if at_port and manufacturer and manufacturer~="unknown" then + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port + local result=shell(command) + network_prefer=json.parse(result) + end + + -- 写入Web界面 + luci.http.prepare_content("application/json") + luci.http.write_json(network_prefer) +end + +--[[ +@Description 获取自检信息 +]] +function getSelfTestInfo() + local at_port = http.formvalue("port") + + --获取制造商 + local manufacturer=getManufacturer(at_port) + + --获取值 + local self_test_info={} + if manufacturer~="unknown" then + --获取模组电压 + local command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_voltage "..at_port + local result=shell(command) + self_test_info["voltage"]=json.parse(result) + + --获取模组温度 + command="source "..script_path..manufacturer..".sh && "..manufacturer.."_get_temperature "..at_port + result=shell(command) + self_test_info["temperature"]=json.parse(result) + end + + --设置值 + local modem_debug_info={} + modem_debug_info["self_test_info"]=self_test_info + + -- 写入Web界面 + luci.http.prepare_content("application/json") + luci.http.write_json(modem_debug_info) +end + --[[ @Description 获取快捷命令 ]] @@ -391,15 +591,7 @@ function getQuickCommands() local at_port = http.formvalue("port") --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) + local manufacturer=getManufacturer(at_port) --未适配模组时,快捷命令选项为自定义 if manufacturer=="unknown" then @@ -410,11 +602,11 @@ function getQuickCommands() local commands={} if quick_option=="auto" then --获取模组AT命令 - -- 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() - quick_commands=json.parse(opd) + -- local command="source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer + local command="cat "..script_path..manufacturer.."_at_commands.json" + local result=shell(command) + quick_commands=json.parse(result) + else uci:foreach("modem", "custom-commands", function (custom_commands) local command={} @@ -447,207 +639,6 @@ function sendATCommand() luci.http.write_json(response) end ---[[ -@Description 设置网络偏好 -]] -function setNetworkPrefer() - local at_port = http.formvalue("port") - local network_prefer_config = json.stringify(http.formvalue("prefer_config")) - - --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) - - --设置模组网络偏好 - 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("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port) - local opd = odpall:read("*a") - network_prefer=json.parse(opd) - odpall:close() - end - - -- 写入Web界面 - luci.http.prepare_content("application/json") - luci.http.write_json(network_prefer) -end - ---[[ -@Description 设置拨号模式 -]] -function setMode() - local at_port = http.formvalue("port") - local mode_config = http.formvalue("mode_config") - - --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) - - --设置模组拨号模式 - 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("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port) - mode = odpall:read("*a") - mode=string.gsub(mode, "\n", "") - odpall:close() - end - - -- 写入Web界面 - luci.http.prepare_content("application/json") - luci.http.write_json(mode) -end - ---[[ -@Description 获取拨号模式信息 -]] -function getModeInfo() - local at_port = http.formvalue("port") - - --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) - - --获取值 - local mode_info={} - if manufacturer~="unknown" then - - --获取支持的拨号模式 - local modes - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - modes=modem_device["modes"] - return true --跳出循环 - end - end) - - --获取模组拨号模式 - 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", "") - - --设置模式信息 - mode_info["mode"]=mode - mode_info["modes"]=modes - end - - --设置值 - local modem_debug_info={} - modem_debug_info["mode_info"]=mode_info - - -- 写入Web界面 - luci.http.prepare_content("application/json") - luci.http.write_json(modem_debug_info) -end - ---[[ -@Description 获取网络偏好信息 -]] -function getNetworkPreferInfo() - local at_port = http.formvalue("port") - - --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) - - --获取值 - local network_prefer_info - if manufacturer~="unknown" then - --获取模组网络偏好 - local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port) - local opd = odpall:read("*a") - odpall:close() - network_prefer_info=json.parse(opd) - end - - --设置值 - local modem_debug_info={} - modem_debug_info["network_prefer_info"]=network_prefer_info - - -- 写入Web界面 - luci.http.prepare_content("application/json") - luci.http.write_json(modem_debug_info) -end - ---[[ -@Description 获取自检信息 -]] -function getSelfTestInfo() - local at_port = http.formvalue("port") - - --获取制造商 - local manufacturer - uci:foreach("modem", "modem-device", function (modem_device) - --设置模组AT串口 - if at_port == modem_device["at_port"] then - --获取制造商 - manufacturer=modem_device["manufacturer"] - return true --跳出循环 - end - end) - - --获取值 - local self_test_info={} - if manufacturer~="unknown" then - --获取模组电压 - local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_voltage "..at_port) - local opd = odpall:read("*a") - odpall:close() - self_test_info["voltage"]=json.parse(opd) - - --获取模组温度 - local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_temperature "..at_port) - local opd = odpall:read("*a") - odpall:close() - self_test_info["temperature"]=json.parse(opd) - end - - --设置值 - local modem_debug_info={} - modem_debug_info["self_test_info"]=self_test_info - - -- 写入Web界面 - luci.http.prepare_content("application/json") - luci.http.write_json(modem_debug_info) -end - --[[ @Description 获取模组调试信息 ]] @@ -655,15 +646,7 @@ end -- local at_port = http.formvalue("port") -- --获取制造商 --- local manufacturer --- uci:foreach("modem", "modem-device", function (modem_device) --- --设置模组AT串口 --- if at_port == modem_device["at_port"] then --- --获取制造商 --- manufacturer=modem_device["manufacturer"] --- return true --跳出循环 --- end --- end) +-- local manufacturer=getManufacturer(at_port) -- --获取值 -- local mode_info={}