From e7131d28831887f053a310322cec3fbf204e2875 Mon Sep 17 00:00:00 2001 From: fujr Date: Mon, 13 May 2024 10:33:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E7=BB=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../root/usr/share/modem/modem_util.sh | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/luci-app-modem/root/usr/share/modem/modem_util.sh b/luci-app-modem/root/usr/share/modem/modem_util.sh index 74194b1..a119578 100755 --- a/luci-app-modem/root/usr/share/modem/modem_util.sh +++ b/luci-app-modem/root/usr/share/modem/modem_util.sh @@ -411,6 +411,7 @@ retry_set_modem_config() modem_name="$(handle_special_modem_name ${modem_name})" } + #获取模组信息 local data_interface=$(uci -q get modem.modem${modem_no}.data_interface) local modem_info=$(echo ${modem_support} | jq '.modem_support.'$data_interface'."'$modem_name'"') @@ -462,21 +463,34 @@ m_set_modem_config() #获取模组名称 local modem_name=$(uci -q get modem.modem${modem_no}.name) + if [ "$modem_name" == "unknown" ]; then + #返回空 + modem_name="" + fi [ -z "$modem_name" ] && { local at_command="AT+CGMM?" modem_name=$(at ${at_port} ${at_command} | grep "+CGMM: " | awk -F'"' '{print $2}' | tr 'A-Z' 'a-z' |cut -d ' ' -f 1) + logger -t modem_ttl "try_1_get_modem_name: ${modem_name}" } + + #再一次获取模组名称 [ -z "$modem_name" ] && { - #通过模组id设置型号 - if [ -f "${physical_path}/idVendor" ] && [ -f "${physical_path}/idProduct" ]; then - local manufacturer_id=$(cat "${physical_path}/idVendor") - local product_id=$(cat "${physical_path}/idProduct") - case "$manufacturer_id" in - 2c7c) - modem_name="quectel_generic" - ;; - esac - fi + at_command="AT+CGMM" + modem_name=$(at ${at_port} ${at_command} | grep "+CGMM: " | awk -F': ' '{print $2}' | sed 's/\r//g' | tr 'A-Z' 'a-z') + logger -t modem_ttl "try_2_get_modem_name: ${modem_name}" + } + + #再一次获取模组名称 + [ -z "$modem_name" ] && { + at_command="AT+CGMM" + modem_name=$(at ${at_port} ${at_command} | sed -n '2p' | sed 's/\r//g' | tr 'A-Z' 'a-z') + logger -t modem_ttl "try_3_get_modem_name: ${modem_name}" + } + + #处理特殊的模组名称 + [ -n "$modem_name" ] && { + logger -t modem_ttl "handle_special_modem_name: ${modem_name}" + modem_name="$(handle_special_modem_name ${modem_name})" } #获取模组支持列表