luci-app-modem:refine fm350 dial apn selection

This commit is contained in:
padavanonly
2025-05-25 17:48:42 +08:00
parent 8882f97e46
commit 512316f742
6 changed files with 36 additions and 16 deletions

View File

@@ -3,4 +3,4 @@ config global 'global'
option enable_dial '1'
option modem_number '0'
option manual_configuration '0'
option network_interface_alias '1'
option network_interface_alias '1'

View File

@@ -467,7 +467,7 @@ fibocom_sim_info()
#ISP互联网服务提供商
at_command="AT+COPS?"
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+COPS" | awk -F'"' '{print $2}')
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+COPS" | awk -F'"' '{print $2}'| tr -d '\r\n' | xargs)
if [ "$isp" = "4E2D56FD8054901A" ]; then
isp="CHN-UNICOM"
fi

View File

@@ -347,19 +347,17 @@ info_to_json()
#获取模组信息
get_modem_info()
{
update_time=$(date +"%Y-%m-%d %H:%M:%S")
update_time=$(date +"%Y-%m-%d %H:%M:%S")
debug "检查模组的AT串口"
#获取模块AT串口
if [ -z "$at_port" ]; then
debug "模组没有AT串口"
return
fi
#检查模块状态(是否处于重启,重置,串口异常状态)
local at_command="ATI"
local response=$(at ${at_port} ${at_command})
if [[ "$response" = *"failed"* ]] || [[ "$response" = *"$at_port"* ]]; then
local response=$(timeout 10 at ${at_port} ${at_command})
if [[ $? -ne 0 ]] || [[ "$response" = *"failed"* ]] || [[ "$response" = *"$at_port"* ]]; then
debug "模组AT串口未就绪"
return
fi
@@ -387,7 +385,7 @@ get_modem_info()
# $4:连接定义
modem_info()
{
#初值化模组信息
#初值化模组信息
debug "初值化模组信息"
init_modem_info
debug "初值化模组信息完成"

View File

@@ -160,14 +160,37 @@ rndis_dial()
#手动拨号广和通FM350-GL
if [ "$manufacturer" = "fibocom" ] && [ "$platform" = "mediatek" ]; then
local at_command="AT+COPS?"
isp=$(at ${at_port} ${at_command} | grep "+COPS" | awk -F'"' '{print $2}' | tr -d '\r\n' | xargs)
if [ "$isp" = "4E2D56FD8054901A" ]; then
isp="CHN-UNICOM"
fi
local at_command="AT+CGACT=1,${define_connect}"
if [[ "$isp" == "CHN-CMCC" || "$isp" == "CMCC" || "$isp" == "46000" || "$isp" == "CHINA MOBILE"]]; then
at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"cbnet\""
at "$at_port" "$at_command"
echo "matching ISP: [$isp]" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
elif [[ "$isp" == "CHN-UNICOM" || "$isp" == "UNICOM" || "$isp" == "46001" ]]; then
at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"3gnet\""
at "$at_port" "$at_command"
echo "matching ISP: [$isp]" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
elif [[ "$isp" == "CHN-CT" || "$isp" == "CT" || "$isp" == "46011" || "$isp" == "CHINA TELECOM"]]; then
at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"ctnet\""
at "$at_port" "$at_command"
echo "matching ISP: [$isp]" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
else
echo "No matching ISP: [$isp]" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"cbnet\""
at "$at_port" "$at_command"
echo "matching ISP: [$isp]" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
fi
sleep 3s
local at_command="AT+CGACT=1,${define_connect}"
#打印日志
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
#激活并拨号
sleep 3s
at "${at_port}" "${at_command}"
sleep 3s
else
#拨号
ecm_dial "${at_port}" "${manufacturer}" "${define_connect}"
@@ -253,7 +276,6 @@ modem_network_task()
#拨号工具为modemmanager时不需要重新设置连接定义
continue
}
#输出日志
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Unable to get IPv4 address" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Redefine connect to ${define_connect}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"

View File

@@ -22,4 +22,4 @@ modem_scan_task()
done
}
modem_scan_task
modem_scan_task

View File

@@ -635,13 +635,13 @@ tdtech_sim_info()
#ISP互联网服务提供商
at_command="AT+COPS?"
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+COPS" | awk -F'"' '{print $2}')
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+COPS" | awk -F'"' '{print $2}'| tr -d '\r\n' | xargs)
if [ "$isp" = "4E2D56FD8054901A" ]; then
isp="CHN-UNICOM"
fi
if [ -z "$isp" ]; then
at_command="AT+EONS?"
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} "${at_command}" | grep "+EONS" | awk -F'"' '{print $2}')
at_command="AT^EONS=1"
isp=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} "${at_command}" | grep "^EONS" | awk -F'"' '{print $2}')
if [ "$isp" = "4E2D56FD8054901A" ]; then
isp="CHN-UNICOM"
fi