From 6cdec2d910b8ed7841bddeef29cb2b92430bb2ff Mon Sep 17 00:00:00 2001 From: ling <1042585959@qq.com> Date: Tue, 30 Apr 2024 16:57:32 +0800 Subject: [PATCH] =?UTF-8?q?debug=E7=95=8C=E9=9D=A2=EF=BC=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E8=AE=BE=E7=BD=AE=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/luci-app-modem/Makefile | 7 +- applications/luci-app-modem/README.md | 1 + .../luasrc/model/cbi/modem/modem_config.lua | 34 +++- .../luasrc/view/modem/modem_debug.htm | 41 +++-- .../luasrc/view/modem/modem_info.htm | 2 +- .../luasrc/view/modem/modem_scan.htm | 2 +- applications/luci-app-modem/po/zh-cn/modem.po | 92 +++++----- .../luci-app-modem/po/zh_Hans/modem.po | 161 ++++++++++-------- .../luci-app-modem/root/etc/init.d/modem | 19 +++ .../root/usr/share/modem/modem_util.sh | 22 +++ 10 files changed, 236 insertions(+), 145 deletions(-) diff --git a/applications/luci-app-modem/Makefile b/applications/luci-app-modem/Makefile index ffe0c1f..d58ae76 100644 --- a/applications/luci-app-modem/Makefile +++ b/applications/luci-app-modem/Makefile @@ -9,8 +9,11 @@ LUCI_PKGARCH:=all PKG_VERSION:=1.4.3 PKG_LICENSE:=GPLv3 PKG_LINCESE_FILES:=LICENSE -PKF_MAINTAINER:=siriling -LUCI_DEPENDS:= \ +PKF_MAINTAINER:=Siriling +LUCI_DEPENDS:=+luci-compat \ + +usbutils \ + +pciutils \ + +quectel-CM-5G \ +sms-tool \ +jq \ diff --git a/applications/luci-app-modem/README.md b/applications/luci-app-modem/README.md index e39ae03..b288eff 100644 --- a/applications/luci-app-modem/README.md +++ b/applications/luci-app-modem/README.md @@ -36,6 +36,7 @@ | 移远通信 | RM520N-CN | 高通 | USB | RMNET,ECM,MBIM,RNDIS,NCM | | 移远通信 | RM520N-GL | 高通 | USB | RMNET,ECM,MBIM,RNDIS,NCM | | 移远通信 | RM500Q-GL | 高通 | PCIE | RMNET,MBIM | +| 移远通信 | RG500Q-EA | 高通 | PCIE | RMNET,MBIM | | 移远通信 | RM502Q-GL | 高通 | PCIE | RMNET,MBIM | | 移远通信 | RG520N-EU | 高通 | PCIE | RMNET,MBIM | | 广和通 | FM650-CN | 紫光展锐 | USB | ECM,MBIM,RNDIS,NCM | diff --git a/applications/luci-app-modem/luasrc/model/cbi/modem/modem_config.lua b/applications/luci-app-modem/luasrc/model/cbi/modem/modem_config.lua index 48c2261..e43e318 100644 --- a/applications/luci-app-modem/luasrc/model/cbi/modem/modem_config.lua +++ b/applications/luci-app-modem/luasrc/model/cbi/modem/modem_config.lua @@ -18,22 +18,42 @@ end --[[ @Description 获取支持的模组信息 +@Params + data_interface 数据接口 ]] -function getSupportModems() +function getSupportModems(data_interface) local command="cat "..script_path.."modem_support.json" local result=json.parse(shell(command)) - return result["modem_support"]["usb"] + return result["modem_support"][data_interface] end --[[ @Description 按照制造商给模组分类 -@Params - support_modem 支持的模组 ]] -function getManufacturers(support_modem) +function getManufacturers() local manufacturers={} + + -- 获取支持的模组 + local support_modem=getSupportModems("usb") + -- USB + for modem in pairs(support_modem) do + local manufacturer=support_modem[modem]["manufacturer"] + if manufacturers[manufacturer] then + -- 直接插入 + table.insert(manufacturers[manufacturer],modem) + else + -- 不存在先创建一个空表 + local tmp={} + table.insert(tmp,modem) + manufacturers[manufacturer]=tmp + end + end + + -- 获取支持的模组 + local support_modem=getSupportModems("pcie") + -- PCIE for modem in pairs(support_modem) do local manufacturer=support_modem[modem]["manufacturer"] @@ -103,10 +123,8 @@ name = s:option(ListValue, "name", translate("Modem Name")) name.placeholder = translate("Not Null") name.rmempty = false --- 获取支持的模组 -local support_modem=getSupportModems() -- 按照制造商给模组分类 -local manufacturers=getManufacturers(support_modem) +local manufacturers=getManufacturers() for key in pairs(manufacturers) do local modems=manufacturers[key] diff --git a/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm b/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm index 75cd96c..b2c3a00 100644 --- a/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm +++ b/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm @@ -472,7 +472,7 @@ } // 设置拨号模式信息 - function set_mode_info(mode_info,first_cache) + function set_mode_info(mode_info) { //获取当前拨号模式 var current_mode=mode_info["mode"]; @@ -490,9 +490,10 @@ //设置当前拨号模式 document.getElementById('current_mode').innerHTML=current_mode_view; - if (first_cache) + //设置支持的拨号模式 + var first_cache=document.getElementById("first_cache"); + if (first_cache.checked) { - //设置支持的拨号模式 var mode_option_view=''; for(mode of modes) { @@ -511,7 +512,7 @@ element=document.getElementById('mode_option_'+current_mode).checked=true; //设置第一次获取数据标志 - first_cache=false; + first_cache.checked=false; } } @@ -571,7 +572,7 @@ } // 设置网络偏好信息 - function set_network_prefer_info(network_prefer_info,first_cache) + function set_network_prefer_info(network_prefer_info) { //获取模组网络偏好 var network_prefer=network_prefer_info["network_prefer"]; @@ -583,7 +584,8 @@ document.getElementById('current_prefer').innerHTML=current_prefer_view; //设置偏好选项和复选框 - if (first_cache) + var first_cache=document.getElementById("first_cache"); + if (first_cache.checked) { if (network_prefer["3G"]&&network_prefer["4G"]&&network_prefer["5G"]) { @@ -612,7 +614,7 @@ } //设置第一次获取数据标志 - first_cache=false; + first_cache.checked=false; } } @@ -738,7 +740,7 @@ } // 获取模组调试信息 - function get_modem_debug_info(debug_params) + function get_modem_debug_info() { //获取选中的模组 var at_port = document.getElementById("modem_select").value; @@ -762,7 +764,7 @@ } //设置模式信息 - set_mode_info(mode_info,debug_params.first_cache); + set_mode_info(mode_info); } ); } @@ -778,7 +780,7 @@ } //设置网络偏好信息 - set_network_prefer_info(network_prefer_info,debug_params.first_cache); + set_network_prefer_info(network_prefer_info); } ); } @@ -806,7 +808,7 @@ { //缓存当前选择的模组 var modem_select_cache=""; - var debug_params={first_cache:true,view:0}; + var debug_params={view:0}; return function(x, data) { var at_ports=data["at_ports"]; @@ -846,11 +848,11 @@ modem_select_cache=select_modem_name; //设置第一次获取数据标志 - debug_params.first_cache=true; + document.getElementById("first_cache").checked=true; } //获取模组调试信息 - get_modem_debug_info(debug_params); + get_modem_debug_info(); } //设置界面 @@ -953,7 +955,7 @@

<%:Modem Select%>

-
+
@@ -964,6 +966,17 @@
+
diff --git a/applications/luci-app-modem/luasrc/view/modem/modem_info.htm b/applications/luci-app-modem/luasrc/view/modem/modem_info.htm index 6061267..c95041f 100644 --- a/applications/luci-app-modem/luasrc/view/modem/modem_info.htm +++ b/applications/luci-app-modem/luasrc/view/modem/modem_info.htm @@ -533,7 +533,7 @@ end else if (key=="SCS") { value=value+" kHz"; } - cell_info_view+=''+translation[key]+' ('+key+')'+value+''; + cell_info_view+=''+translation[key]+''+value+''; break; } } diff --git a/applications/luci-app-modem/luasrc/view/modem/modem_scan.htm b/applications/luci-app-modem/luasrc/view/modem/modem_scan.htm index a0ccc91..e2f9edd 100644 --- a/applications/luci-app-modem/luasrc/view/modem/modem_scan.htm +++ b/applications/luci-app-modem/luasrc/view/modem/modem_scan.htm @@ -41,6 +41,6 @@ function modem_scan()
- <%:The automatic configuration modem is triggered only at startup, otherwise, manual scanning is necessary%> + <%:The automatic configuration modem is triggered only at modem startup, otherwise, manual scanning is necessary%>
<%+cbi/valuefooter%> diff --git a/applications/luci-app-modem/po/zh-cn/modem.po b/applications/luci-app-modem/po/zh-cn/modem.po index e59b853..86e6f26 100644 --- a/applications/luci-app-modem/po/zh-cn/modem.po +++ b/applications/luci-app-modem/po/zh-cn/modem.po @@ -395,112 +395,112 @@ msgid "WCDMA Mode" msgstr "WCDMA 模式" msgid "MCC" -msgstr "移动国家代码" +msgstr "移动国家代码 (MCC)" msgid "MNC" -msgstr "移动网络代码" +msgstr "移动网络代码 (MNC)" msgid "Duplex Mode" -msgstr "双工模式" +msgstr "双工模式 (Duplex Mode)" msgid "LAC" -msgstr "位置区码" +msgstr "位置区码 (LAC)" msgid "Cell ID" -msgstr "小区ID" +msgstr "小区ID (Cell ID)" msgid "Physical Cell ID" -msgstr "物理小区ID" +msgstr "物理小区ID (Physical Cell ID)" msgid "TAC" -msgstr "跟踪区编码" +msgstr "跟踪区编码 (TAC)" msgid "ARFCN" -msgstr "绝对射频信道号" +msgstr "绝对射频信道号 (ARFCN)" msgid "EARFCN" -msgstr "E-UTRA绝对射频信道号" +msgstr "E-UTRA绝对射频信道号 (EARFCN)" msgid "UARFCN" -msgstr "UTRA绝对射频信道号" +msgstr "UTRA绝对射频信道号 (UARFCN)" msgid "Band" -msgstr "频段" +msgstr "频段 (Band)" msgid "Freq band indicator" -msgstr "频带指示" +msgstr "频带指示 (Freq band indicator)" msgid "UL Bandwidth" -msgstr "上行带宽" +msgstr "上行带宽 (UL Bandwidth)" msgid "DL Bandwidth" -msgstr "下行带宽" +msgstr "下行带宽 (DL Bandwidth)" msgid "RSRP" -msgstr "参考信号接收功率" +msgstr "参考信号接收功率 (RSRP)" msgid "RSRQ" -msgstr "参考信号接收质量" +msgstr "参考信号接收质量 (RSRQ)" msgid "RSSI" -msgstr "接收信号强度指示" +msgstr "接收信号强度指示 (RSSI)" msgid "SINR" -msgstr "信号与干扰加噪声比" +msgstr "信号与干扰加噪声比 (SINR)" msgid "RxLev" -msgstr "接收信号功率" +msgstr "接收信号功率 (RxLev)" msgid "RSSNR" -msgstr "信号干扰比" +msgstr "信号干扰比 (RSSNR)" msgid "SCS" -msgstr "NR子载波间隔" +msgstr "NR子载波间隔 (SCS)" msgid "CQI" -msgstr "信道质量指示" +msgstr "信道质量指示 (CQI)" msgid "TX Power" -msgstr "TX 功率" +msgstr "TX 功率 (TX Power)" msgid "Srxlev" -msgstr "服务小区接收信号功率" +msgstr "服务小区接收信号功率 (Srxlev)" msgid "PSC" -msgstr "主扰码" +msgstr "主扰码 (PSC)" msgid "RAC" -msgstr "路由区域码" +msgstr "路由区域码 (RAC)" msgid "RSCP" -msgstr "接收信号码功率" +msgstr "接收信号码功率 (RSCP)" -msgid "每比特能量与干扰功率密度(干扰比)之比" -msgstr "Eb/Io" +msgid "Eb/Io" +msgstr "每比特能量与干扰功率密度(干扰比)之比" -msgid "每比特能量与噪声功率密度(噪声比)之比" -msgstr "Eb/No" +msgid "Eb/No" +msgstr "每比特能量与噪声功率密度(噪声比)之比" -msgid "每码片能量与干扰功率密度(干扰比)之比" -msgstr "Ec/Io" +msgid "Ec/Io" +msgstr "每码片能量与干扰功率密度(干扰比)之比" -msgid "每码片能量与噪声功率密度(噪声比)之比" -msgstr "Ec/No" +msgid "Ec/No" +msgstr "每码片能量与噪声功率密度(噪声比)之比" msgid "Physical Channel" -msgstr "物理信道" +msgstr "物理信道 (Physical Channel)" msgid "Spreading Factor" -msgstr "扩频因子" +msgstr "扩频因子 (Spreading Factor)" msgid "Slot" -msgstr "插槽格式" +msgstr "插槽格式 (Slot)" msgid "Speech Code" -msgstr "语音编码" +msgstr "语音编码 (Speech Code)" msgid "Compression Mode" -msgstr "压缩模式" +msgstr "压缩模式 (Compression Mode)" msgid "CHN-CMCC" msgstr "中国移动" @@ -539,16 +539,16 @@ msgid "46011" msgstr "中国电信" msgid "Excellent" -msgstr "非常好" +msgstr "优秀" msgid "Good" -msgstr "好" +msgstr "良好" msgid "Fair" msgstr "一般" msgid "Bad" -msgstr "差" +msgstr "较差" msgid "Plugin Config" msgstr "插件配置" @@ -565,8 +565,8 @@ msgstr "扫描" msgid "Scaning modem..." msgstr "正在扫描中..." -msgid "The automatic configuration modem is triggered only at startup, otherwise, manual scanning is necessary" -msgstr "自动配置模组只有在启动的时候才会触发,其他情况需要手动点击扫描" +msgid "The automatic configuration modem is triggered only at modem startup, otherwise, manual scanning is necessary" +msgstr "自动配置模组只有在模组启动的时候才会触发,其他情况需要手动点击扫描" msgid "Manual Configuration" msgstr "手动配置" @@ -575,7 +575,7 @@ msgid "Enable the manual configuration of modem information" msgstr "启用手动配置模组信息" msgid "(After enable, the automatic scanning and configuration function for modem information will be disabled)" -msgstr "(启用后将禁用自动扫描配置模组信息功能)" +msgstr "(启用后将禁用自动扫描并配置模组信息功能)" msgid "Plugin Info" msgstr "插件信息" diff --git a/applications/luci-app-modem/po/zh_Hans/modem.po b/applications/luci-app-modem/po/zh_Hans/modem.po index ac455aa..86e6f26 100644 --- a/applications/luci-app-modem/po/zh_Hans/modem.po +++ b/applications/luci-app-modem/po/zh_Hans/modem.po @@ -352,6 +352,18 @@ msgstr "网络信息" msgid "Network Type" msgstr "网络类型" +msgid "CQI UL" +msgstr "上行信道质量指示" + +msgid "CQI DL" +msgstr "下行信道质量指示" + +msgid "AMBR UL" +msgstr "上行访问最大比特率" + +msgid "AMBR DL" +msgstr "下行访问最大比特率" + msgid "Tx Rate" msgstr "上传速率" @@ -383,109 +395,112 @@ msgid "WCDMA Mode" msgstr "WCDMA 模式" msgid "MCC" -msgstr "移动国家代码" +msgstr "移动国家代码 (MCC)" msgid "MNC" -msgstr "移动网络代码" +msgstr "移动网络代码 (MNC)" msgid "Duplex Mode" -msgstr "双工模式" +msgstr "双工模式 (Duplex Mode)" msgid "LAC" -msgstr "位置区码" +msgstr "位置区码 (LAC)" msgid "Cell ID" -msgstr "小区ID" +msgstr "小区ID (Cell ID)" msgid "Physical Cell ID" -msgstr "物理小区ID" +msgstr "物理小区ID (Physical Cell ID)" msgid "TAC" -msgstr "跟踪区编码" +msgstr "跟踪区编码 (TAC)" msgid "ARFCN" -msgstr "绝对射频信道号" +msgstr "绝对射频信道号 (ARFCN)" msgid "EARFCN" -msgstr "E-UTRA绝对射频信道号" +msgstr "E-UTRA绝对射频信道号 (EARFCN)" msgid "UARFCN" -msgstr "UTRA绝对射频信道号" +msgstr "UTRA绝对射频信道号 (UARFCN)" msgid "Band" -msgstr "频段" +msgstr "频段 (Band)" msgid "Freq band indicator" -msgstr "频带指示" +msgstr "频带指示 (Freq band indicator)" msgid "UL Bandwidth" -msgstr "上行带宽" +msgstr "上行带宽 (UL Bandwidth)" msgid "DL Bandwidth" -msgstr "下行带宽" +msgstr "下行带宽 (DL Bandwidth)" msgid "RSRP" -msgstr "参考信号接收功率" +msgstr "参考信号接收功率 (RSRP)" msgid "RSRQ" -msgstr "参考信号接收质量" +msgstr "参考信号接收质量 (RSRQ)" msgid "RSSI" -msgstr "接收信号强度指示" +msgstr "接收信号强度指示 (RSSI)" msgid "SINR" -msgstr "信号与干扰加噪声比" - -msgid "RSSNR" -msgstr "信号干扰比" - -msgid "SCS" -msgstr "NR子载波间隔" - -msgid "CQI" -msgstr "信道质量指示" - -msgid "TX Power" -msgstr "TX 功率" - -msgid "PSC" -msgstr "主扰码" - -msgid "RAC" -msgstr "路由区域码" - -msgid "RSCP" -msgstr "接收信号码功率" - -msgid "每比特能量与干扰功率密度(干扰比)之比" -msgstr "Eb/Io" - -msgid "每比特能量与噪声功率密度(噪声比)之比" -msgstr "Eb/No" - -msgid "每码片能量与干扰功率密度(干扰比)之比" -msgstr "Ec/Io" - -msgid "每码片能量与噪声功率密度(噪声比)之比" -msgstr "Ec/No" - -msgid "Physical Channel" -msgstr "物理信道" - -msgid "Spreading Factor" -msgstr "扩频因子" - -msgid "Slot" -msgstr "插槽格式" - -msgid "Speech Code" -msgstr "语音编码" - -msgid "Compression Mode" -msgstr "压缩模式" +msgstr "信号与干扰加噪声比 (SINR)" msgid "RxLev" -msgstr "接收信号功率" +msgstr "接收信号功率 (RxLev)" + +msgid "RSSNR" +msgstr "信号干扰比 (RSSNR)" + +msgid "SCS" +msgstr "NR子载波间隔 (SCS)" + +msgid "CQI" +msgstr "信道质量指示 (CQI)" + +msgid "TX Power" +msgstr "TX 功率 (TX Power)" + +msgid "Srxlev" +msgstr "服务小区接收信号功率 (Srxlev)" + +msgid "PSC" +msgstr "主扰码 (PSC)" + +msgid "RAC" +msgstr "路由区域码 (RAC)" + +msgid "RSCP" +msgstr "接收信号码功率 (RSCP)" + +msgid "Eb/Io" +msgstr "每比特能量与干扰功率密度(干扰比)之比" + +msgid "Eb/No" +msgstr "每比特能量与噪声功率密度(噪声比)之比" + +msgid "Ec/Io" +msgstr "每码片能量与干扰功率密度(干扰比)之比" + +msgid "Ec/No" +msgstr "每码片能量与噪声功率密度(噪声比)之比" + +msgid "Physical Channel" +msgstr "物理信道 (Physical Channel)" + +msgid "Spreading Factor" +msgstr "扩频因子 (Spreading Factor)" + +msgid "Slot" +msgstr "插槽格式 (Slot)" + +msgid "Speech Code" +msgstr "语音编码 (Speech Code)" + +msgid "Compression Mode" +msgstr "压缩模式 (Compression Mode)" msgid "CHN-CMCC" msgstr "中国移动" @@ -524,16 +539,16 @@ msgid "46011" msgstr "中国电信" msgid "Excellent" -msgstr "非常好" +msgstr "优秀" msgid "Good" -msgstr "好" +msgstr "良好" msgid "Fair" msgstr "一般" msgid "Bad" -msgstr "差" +msgstr "较差" msgid "Plugin Config" msgstr "插件配置" @@ -550,8 +565,8 @@ msgstr "扫描" msgid "Scaning modem..." msgstr "正在扫描中..." -msgid "The automatic configuration modem is triggered only at startup, otherwise, manual scanning is necessary" -msgstr "自动配置模组只有在启动的时候才会触发,其他情况需要手动点击扫描" +msgid "The automatic configuration modem is triggered only at modem startup, otherwise, manual scanning is necessary" +msgstr "自动配置模组只有在模组启动的时候才会触发,其他情况需要手动点击扫描" msgid "Manual Configuration" msgstr "手动配置" @@ -560,7 +575,7 @@ msgid "Enable the manual configuration of modem information" msgstr "启用手动配置模组信息" msgid "(After enable, the automatic scanning and configuration function for modem information will be disabled)" -msgstr "(启用后将禁用自动扫描配置模组信息功能)" +msgstr "(启用后将禁用自动扫描并配置模组信息功能)" msgid "Plugin Info" msgstr "插件信息" diff --git a/applications/luci-app-modem/root/etc/init.d/modem b/applications/luci-app-modem/root/etc/init.d/modem index 09fd5bc..b917635 100755 --- a/applications/luci-app-modem/root/etc/init.d/modem +++ b/applications/luci-app-modem/root/etc/init.d/modem @@ -197,9 +197,28 @@ set_interface() esac } +#设置移远模组MAC地址 +set_quectel_mac() +{ + local mac_address="$(cat /sys/class/net/${network}/address)" + local null_mac="00:00:00:00:00:00" + [ -z "$mac_address" ] || [ "$mac_address" = "$null_mac" ] && { + #方法一(lua) + # local mac_address=$(lua -e 'math.randomseed(os.time()); for i=1,6 do io.write(string.format("%02X", math.random(0, 255))); if i < 6 then io.write(":") end; end') + #方法二(shell) + mac_address="$(generate_mac_address)" + ifconfig "${network}" hw ether "${mac_address}" + } +} + #移远拨号工具 quectel_cm() { + #获取制造商 + local manufacturer=$(uci -q get modem.modem${modem_no}.manufacturer) + #移远500系列模组特殊处理(解决在6.x内核下缺失MAC地址使用制造商驱动导致拨号异常问题) + [ "$manufacturer" = "quectel" ] && set_quectel_mac + #拨号 procd_open_instance procd_set_param command "quectel-CM" diff --git a/applications/luci-app-modem/root/usr/share/modem/modem_util.sh b/applications/luci-app-modem/root/usr/share/modem/modem_util.sh index 48867e5..a54a0bd 100755 --- a/applications/luci-app-modem/root/usr/share/modem/modem_util.sh +++ b/applications/luci-app-modem/root/usr/share/modem/modem_util.sh @@ -24,6 +24,23 @@ m_log() logger -p "daemon.${level}" -t "Modem[$$]" "hotplug: $*" } +#生成16进制数 +generate_hex() { + echo "$(openssl rand -hex 1)" +} + +#生成随机MAC地址 +generate_mac_address() { + local mac="" + for i in $(seq 1 6); do + mac="${mac}$(generate_hex)" + if [[ $i != 6 ]]; then + mac="${mac}:" + fi + done + echo "$mac" +} + #上报USB事件 # $1:事件行为(add,remove,bind) # $2:类型 @@ -347,6 +364,11 @@ handle_special_modem_name() modem_name="fm350-gl" } + #RM500U-CNV + [[ "$modem_name" = *"rm500u-cn"* ]] && { + modem_name="rm500u-cn" + } + echo "$modem_name" }