优化拨号连接
This commit is contained in:
parent
e6d49de1ff
commit
4337313ef1
@ -375,33 +375,37 @@ function getDialLogInfo()
|
|||||||
|
|
||||||
local logs={}
|
local logs={}
|
||||||
local names={}
|
local names={}
|
||||||
|
local translation={}
|
||||||
for key in pairs(log_paths) do
|
for key in pairs(log_paths) do
|
||||||
|
|
||||||
local log_path=log_paths[key]
|
local log_path=log_paths[key]
|
||||||
|
|
||||||
if log_path ~= "" then
|
if log_path ~= "" then
|
||||||
--获取模组
|
-- 获取模组
|
||||||
local tmp=string.gsub(log_path, run_path, "")
|
local tmp=string.gsub(log_path, run_path, "")
|
||||||
local modem=string.gsub(tmp, "_dial.cache", "")
|
local modem=string.gsub(tmp, "_dial.cache", "")
|
||||||
local modem_name=uci:get("modem", modem, "name")
|
local modem_name=uci:get("modem", modem, "name")
|
||||||
|
|
||||||
--获取日志内容
|
-- 获取日志内容
|
||||||
local command="cat "..log_path
|
local command="cat "..log_path
|
||||||
log=shell(command)
|
log=shell(command)
|
||||||
|
|
||||||
--排序插入
|
-- 排序插入
|
||||||
modem_log={}
|
modem_log={}
|
||||||
modem_log[modem]=log
|
modem_log[modem]=log
|
||||||
table.insert(logs, modem_log)
|
table.insert(logs, modem_log)
|
||||||
|
|
||||||
|
--设置模组名
|
||||||
names[modem]=modem_name
|
names[modem]=modem_name
|
||||||
|
-- 设置翻译
|
||||||
|
translation[modem_name]=luci.i18n.translate(modem_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 设置值
|
-- 设置值
|
||||||
local data={}
|
local data={}
|
||||||
data["dial_log_info"]=logs
|
data["dial_log_info"]=logs
|
||||||
data["modem_name"]=names
|
data["modem_name_info"]=names
|
||||||
data["translation"]=translation
|
data["translation"]=translation
|
||||||
|
|
||||||
-- 写入Web界面
|
-- 写入Web界面
|
||||||
|
@ -137,7 +137,8 @@
|
|||||||
function(x, data)
|
function(x, data)
|
||||||
{
|
{
|
||||||
var dial_log_info=data["dial_log_info"];
|
var dial_log_info=data["dial_log_info"];
|
||||||
var modem_name=data["modem_name"];
|
var modem_name_info=data["modem_name_info"];
|
||||||
|
var translation=data["translation"];
|
||||||
|
|
||||||
var tab_menu=document.getElementById("tab_menu");
|
var tab_menu=document.getElementById("tab_menu");
|
||||||
var dial_log_div=document.getElementById('dial_log_view');
|
var dial_log_div=document.getElementById('dial_log_view');
|
||||||
@ -195,7 +196,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置拨号日志标签
|
// 设置拨号日志标签
|
||||||
tab_view+='<li class="'+class_name+'" data-tab="'+key+'_tab"><a>'+modem_name[key].toUpperCase()+' ('+key.replace("modem","")+')</a></li>';
|
var modem_name=translation[modem_name_info[key]].toUpperCase();
|
||||||
|
tab_view+='<li class="'+class_name+'" data-tab="'+key+'_tab"><a>'+modem_name+' ('+key.replace("modem","")+')</a></li>';
|
||||||
// 设置拨号日志
|
// 设置拨号日志
|
||||||
dial_log_view += '<div class="cbi-section" data-tab="'+key+'_tab" data-tab-title="'+key+'" data-tab-active="'+active+'" style="display: '+display+';">';
|
dial_log_view += '<div class="cbi-section" data-tab="'+key+'_tab" data-tab-title="'+key+'" data-tab-active="'+active+'" style="display: '+display+';">';
|
||||||
dial_log_view += '<div><textarea readonly="readonly" id="'+key+'_log" rows="20" maxlength="160" style="'+log_style+'">'+dial_log[key]+'</textarea></div>';
|
dial_log_view += '<div><textarea readonly="readonly" id="'+key+'_log" rows="20" maxlength="160" style="'+log_style+'">'+dial_log[key]+'</textarea></div>';
|
||||||
|
@ -39,7 +39,7 @@ fibocom_get_dns()
|
|||||||
|
|
||||||
#获取DNS地址
|
#获取DNS地址
|
||||||
at_command="AT+GTDNS=${define_connect}"
|
at_command="AT+GTDNS=${define_connect}"
|
||||||
local response=$(at ${at_port} ${at_command} | grep "+GTDNS: ")
|
local response=$(at ${at_port} ${at_command} | grep "+GTDNS: " | grep -E '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed -n '1p')
|
||||||
|
|
||||||
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
|
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
|
||||||
[ -z "$ipv4_dns1" ] && {
|
[ -z "$ipv4_dns1" ] && {
|
||||||
|
@ -59,7 +59,7 @@ reset_network_interface()
|
|||||||
service network reload
|
service network reload
|
||||||
|
|
||||||
#输出日志
|
#输出日志
|
||||||
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface ${interface_name} successful" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface successful" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +153,8 @@ rndis_dial()
|
|||||||
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
||||||
#激活并拨号
|
#激活并拨号
|
||||||
at "${at_port}" "${at_command}"
|
at "${at_port}" "${at_command}"
|
||||||
|
|
||||||
|
sleep 3s
|
||||||
else
|
else
|
||||||
#拨号
|
#拨号
|
||||||
ecm_dial "${at_port}" "${manufacturer}"
|
ecm_dial "${at_port}" "${manufacturer}"
|
||||||
@ -234,7 +236,18 @@ modem_network_task()
|
|||||||
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")] 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"
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Redefine connect to ${define_connect}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
||||||
service modem reload
|
service modem reload
|
||||||
# sleep 1s
|
|
||||||
|
#输出日志
|
||||||
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem dial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
|
||||||
|
#拨号(针对获取IPv4返回为空的模组)
|
||||||
|
case "$mode" in
|
||||||
|
"gobinet") gobinet_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
|
||||||
|
"ecm") ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
|
||||||
|
"rndis") rndis_dial "${at_port}" "${manufacturer}" "${platform}" "${define_connect}" "${modem_no}" ;;
|
||||||
|
"modemmanager") modemmanager_dial "${interface_name}" "${define_connect}" ;;
|
||||||
|
*) ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
elif [[ "$ipv4" = *"0.0.0.0"* ]]; then
|
elif [[ "$ipv4" = *"0.0.0.0"* ]]; then
|
||||||
|
|
||||||
#输出日志
|
#输出日志
|
||||||
|
Loading…
x
Reference in New Issue
Block a user