perf: enhance mtk experience
This commit is contained in:
parent
d813c0be80
commit
ef55ccb262
@ -234,7 +234,6 @@ check_ip()
|
|||||||
;;
|
;;
|
||||||
"mediatek")
|
"mediatek")
|
||||||
check_ip_command="AT+CGPADDR=3"
|
check_ip_command="AT+CGPADDR=3"
|
||||||
stric=1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -293,77 +292,32 @@ check_ip()
|
|||||||
|
|
||||||
check_mtk_connection()
|
check_mtk_connection()
|
||||||
{
|
{
|
||||||
local lock_file="${MODEM_RUNDIR}/${modem_config}_dir/mtk_check.lock"
|
[ "$connection_status" = "0" ] || [ "$connection_status" = "-1" ] && return 0
|
||||||
local result_file="${MODEM_RUNDIR}/${modem_config}_dir/mtk_check_result"
|
|
||||||
|
|
||||||
if [ -f "$lock_file" ]; then
|
|
||||||
local lock_time=$(stat -c %Y "$lock_file" 2>/dev/null || echo 0)
|
|
||||||
local current_time=$(cat /proc/uptime | awk '{print int($1)}')
|
|
||||||
if [ $((current_time - lock_time)) -lt 5 ]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
rm -f "$lock_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
touch "$lock_file"
|
|
||||||
|
|
||||||
(
|
|
||||||
if [ "$mtk" -eq 1 ] && [ -n "$ipv4" ] && [ -n "$modem_netcard" ]; then
|
if [ "$mtk" -eq 1 ] && [ -n "$ipv4" ] && [ -n "$modem_netcard" ]; then
|
||||||
local test=0
|
for i in 1 2; do
|
||||||
|
if ping -I "$modem_netcard" -w 1 1.1.1.1 >/dev/null 2>&1 ||
|
||||||
if ping -I "$modem_netcard" -c 1 -w 2 1.1.1.1 > /dev/null 2>&1; then
|
ping -I "$modem_netcard" -w 2 8.8.8.8 >/dev/null 2>&1; then
|
||||||
test=1
|
break
|
||||||
elif ping -I "$modem_netcard" -c 1 -w 2 8.8.8.8 > /dev/null 2>&1; then
|
|
||||||
test=1
|
|
||||||
elif [ -n "$gateway" ] && ping -I "$modem_netcard" -c 1 -w 2 "$gateway" > /dev/null 2>&1; then
|
|
||||||
test=1
|
|
||||||
fi
|
fi
|
||||||
|
if [ $i -eq 2 ]; then
|
||||||
if [ "$test" -eq 0 ]; then
|
|
||||||
m_debug "IPv4 connection test failed, will redial"
|
m_debug "IPv4 connection test failed, will redial"
|
||||||
echo "failed" > "$result_file"
|
|
||||||
rm -f "$lock_file"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
local ifup_time=$(ubus call network.interface.$interface6_name status 2>/dev/null | jsonfilter -e '@.uptime' 2>/dev/null || echo 0)
|
local ifup_time=$(ubus call network.interface.$interface6_name status 2>/dev/null | jsonfilter -e '@.uptime' 2>/dev/null || echo 0)
|
||||||
if [ -n "$ifup_time" ] && [ "$ifup_time" -gt 10 ] && { [ "$pdp_type" = "ipv4v6" ] || [ "$pdp_type" = "IPV4V6" ]; } && [ -n "$ipv6" ]; then
|
if [ -n "$ifup_time" ] && [ "$ifup_time" -gt 5 ] && [ "$pdp_type" = "ipv4v6" ] && [ -n "$ipv6" ]; then
|
||||||
local ipv6_test=0
|
for i in 1 2; do
|
||||||
|
if ping6 -I "$modem_netcard" -w 1 2400:3200::1 >/dev/null 2>&1 ||
|
||||||
if ping6 -I "$modem_netcard" -c 1 -w 2 2400:3200::1 > /dev/null 2>&1; then
|
ping6 -I "$modem_netcard" -w 2 2001:4860:4860::8888 >/dev/null 2>&1; then
|
||||||
ipv6_test=1
|
break
|
||||||
elif ping6 -I "$modem_netcard" -c 1 -w 2 2001:4860:4860::8888 > /dev/null 2>&1; then
|
|
||||||
ipv6_test=1
|
|
||||||
fi
|
fi
|
||||||
|
if [ $i -eq 2 ]; then
|
||||||
if [ "$ipv6_test" -eq 0 ]; then
|
|
||||||
m_debug "IPv6 connection test failed, restarting IPv6 interface"
|
m_debug "IPv6 connection test failed, restarting IPv6 interface"
|
||||||
if [ -n "$interface6_name" ]; then
|
[ -n "$interface6_name" ] && ifdown "$interface6_name" && sleep 2 && ifup "$interface6_name"
|
||||||
ifdown "$interface6_name" && sleep 2 && ifup "$interface6_name"
|
|
||||||
m_debug "Restarted IPv6 interface $interface6_name"
|
|
||||||
fi
|
fi
|
||||||
fi
|
sleep 1
|
||||||
fi
|
done
|
||||||
|
|
||||||
echo "success" > "$result_file"
|
|
||||||
else
|
|
||||||
echo "skipped" > "$result_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$lock_file"
|
|
||||||
) &
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
read_mtk_check_result()
|
|
||||||
{
|
|
||||||
local result_file="${MODEM_RUNDIR}/${modem_config}_dir/mtk_check_result"
|
|
||||||
if [ -f "$result_file" ]; then
|
|
||||||
local result=$(cat "$result_file")
|
|
||||||
if [ "$result" = "failed" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@ -675,10 +629,9 @@ ecm_hang()
|
|||||||
at_command='ATI'
|
at_command='ATI'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(at "${at_port}" "${at_command}")
|
fastat "${at_port}" "${at_command}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hang()
|
hang()
|
||||||
{
|
{
|
||||||
m_debug "hang up $modem_path driver $driver"
|
m_debug "hang up $modem_path driver $driver"
|
||||||
@ -853,24 +806,22 @@ at_dial()
|
|||||||
esac
|
esac
|
||||||
m_debug "dialing vendor:$manufacturer;platform:$platform; $cgdcont_command ; $at_command"
|
m_debug "dialing vendor:$manufacturer;platform:$platform; $cgdcont_command ; $at_command"
|
||||||
at "${at_port}" "${cgdcont_command}"
|
at "${at_port}" "${cgdcont_command}"
|
||||||
at "$at_port" "$at_command"
|
fastat "$at_port" "$at_command"
|
||||||
|
[ "$mtk" -eq 1 ] && sleep 2
|
||||||
if [ "$driver" = "mtk_pcie" ];then
|
if [ "$driver" = "mtk_pcie" ];then
|
||||||
at "$at_port" "AT+CGACT=0,3"
|
fastat "$at_port" "AT+CGACT=0,3"
|
||||||
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
|
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
|
||||||
umbim -d $mbim_port disconnect
|
umbim -d $mbim_port disconnect
|
||||||
umbim -d $mbim_port connect 0
|
sleep 1
|
||||||
|
umbim -d $mbim_port connect
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_change_fm350()
|
ip_change_fm350()
|
||||||
{
|
{
|
||||||
m_debug "ip_change_fm350"
|
m_debug "ip_change_fm350"
|
||||||
local ipv4_config=""
|
local public_dns1_ipv4="223.5.5.5"
|
||||||
local ipv4_dns1=""
|
local public_dns2_ipv4="119.29.29.29"
|
||||||
local ipv4_dns2=""
|
|
||||||
local ipv6_dns1=""
|
|
||||||
local ipv6_dns2=""
|
|
||||||
local gateway=""
|
|
||||||
local netmask="255.255.255.0"
|
local netmask="255.255.255.0"
|
||||||
|
|
||||||
if [ "$driver" = "mtk_pcie" ]; then
|
if [ "$driver" = "mtk_pcie" ]; then
|
||||||
@ -882,43 +833,21 @@ ip_change_fm350()
|
|||||||
|
|
||||||
ipv4_dns1=$(echo "$config" | grep "ipv4dnsserver:" | head -n 1 | awk '{print $2}')
|
ipv4_dns1=$(echo "$config" | grep "ipv4dnsserver:" | head -n 1 | awk '{print $2}')
|
||||||
ipv4_dns2=$(echo "$config" | grep "ipv4dnsserver:" | tail -n 1 | awk '{print $2}')
|
ipv4_dns2=$(echo "$config" | grep "ipv4dnsserver:" | tail -n 1 | awk '{print $2}')
|
||||||
if [ "$ipv4_dns1" = "$ipv4_dns2" ]; then
|
[ -z "$ipv4_dns1" ] && ipv4_dns1="$public_dns1_ipv4"
|
||||||
ipv4_dns2="119.29.29.29"
|
[ -z "$ipv4_dns2" ] && ipv4_dns2="$public_dns2_ipv4"
|
||||||
fi
|
# m_debug "umbim config: ipv4=$ipv4_config, gateway=$gateway, netmask=$netmask, dns1=$ipv4_dns1, dns2=$ipv4_dns2"
|
||||||
|
|
||||||
ipv6_dns1=$(echo "$config" | grep "ipv6dnsserver:" | head -n 1 | awk '{print $2}')
|
|
||||||
ipv6_dns2=$(echo "$config" | grep "ipv6dnsserver:" | tail -n 1 | awk '{print $2}')
|
|
||||||
|
|
||||||
m_debug "umbim config: ipv4=$ipv4_config, gateway=$gateway, netmask=$netmask, dns1=$ipv4_dns1, dns2=$ipv4_dns2"
|
|
||||||
else
|
else
|
||||||
at_command="AT+CGPADDR=3"
|
at_command="AT+CGPADDR=3"
|
||||||
ipv4_config=$(at ${at_port} ${at_command} | cut -d, -f2 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
|
response=$(at ${at_port} ${at_command})
|
||||||
|
ipv4_config=$(echo "$response" | grep "+CGPADDR:" | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"' | head -1 | tr -d '"')
|
||||||
gateway="${ipv4_config%.*}.1"
|
gateway="${ipv4_config%.*}.1"
|
||||||
|
|
||||||
local public_dns1_ipv4="223.5.5.5"
|
response=$(at ${at_port} "AT+GTDNS=3")
|
||||||
local public_dns2_ipv4="119.29.29.29"
|
ipv4_dns=$(echo "$response" | grep "+GTDNS:" | head -1)
|
||||||
local public_dns1_ipv6="2400:3200::1"
|
ipv4_dns1=$(echo "$ipv4_dns" | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"' | head -1 | tr -d '"')
|
||||||
local public_dns2_ipv6="2402:4e00::"
|
ipv4_dns2=$(echo "$ipv4_dns" | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"' | tail -1 | tr -d '"')
|
||||||
at_command="AT+GTDNS=3" | grep "+GTDNS: "| grep -E '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed -n '1p'
|
[ -z "$ipv4_dns1" ] && ipv4_dns1="$public_dns1_ipv4"
|
||||||
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
|
[ -z "$ipv4_dns2" ] && ipv4_dns2="$public_dns2_ipv4"
|
||||||
[ -z "$ipv4_dns1" ] && {
|
|
||||||
ipv4_dns1="${public_dns1_ipv4}"
|
|
||||||
}
|
|
||||||
|
|
||||||
local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
|
|
||||||
[ -z "$ipv4_dns2" ] && {
|
|
||||||
ipv4_dns2="${public_dns2_ipv4}"
|
|
||||||
}
|
|
||||||
|
|
||||||
local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
|
|
||||||
[ -z "$ipv6_dns1" ] && {
|
|
||||||
ipv6_dns1="${public_dns1_ipv6}"
|
|
||||||
}
|
|
||||||
|
|
||||||
local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
|
|
||||||
[ -z "$ipv6_dns2" ] && {
|
|
||||||
ipv6_dns2="${public_dns2_ipv6}"
|
|
||||||
}
|
|
||||||
uci_ipv4=$(uci -q get network.$interface_name.ipaddr)
|
uci_ipv4=$(uci -q get network.$interface_name.ipaddr)
|
||||||
fi
|
fi
|
||||||
uci set network.${interface_name}.proto='static'
|
uci set network.${interface_name}.proto='static'
|
||||||
@ -1042,50 +971,34 @@ check_logfile_line()
|
|||||||
unexpected_response_count=0
|
unexpected_response_count=0
|
||||||
at_dial_monitor()
|
at_dial_monitor()
|
||||||
{
|
{
|
||||||
check_ip
|
|
||||||
at_dial
|
at_dial
|
||||||
ipv4_cache=$ipv4
|
ipv4_cache=$ipv4
|
||||||
last_mtk_check=0
|
ipv6_cache=$ipv6
|
||||||
|
sleep 5
|
||||||
while true; do
|
while true; do
|
||||||
check_ip
|
check_ip
|
||||||
if [ $connection_status -eq 0 ];then
|
case $connection_status in
|
||||||
|
0)
|
||||||
at_dial
|
at_dial
|
||||||
sleep 3
|
sleep 3
|
||||||
elif [ $connection_status -eq -1 ];then
|
;;
|
||||||
|
-1)
|
||||||
unexpected_response_count=$((unexpected_response_count+1))
|
unexpected_response_count=$((unexpected_response_count+1))
|
||||||
if [ $unexpected_response_count -gt 3 ]; then
|
if [ $unexpected_response_count -gt 3 ]; then
|
||||||
at_dial
|
at_dial
|
||||||
unexpected_response_count=0
|
unexpected_response_count=0
|
||||||
fi
|
fi
|
||||||
sleep 10
|
sleep 5
|
||||||
else
|
;;
|
||||||
check_mtk_if_needed() {
|
*)
|
||||||
if [ "$mtk_check" = "1" ]; then
|
if [ "$ipv4" != "$ipv4_cache" ] || [ "$ipv6" != "$ipv6_cache" ]; then
|
||||||
current_time=$(cat /proc/uptime | awk '{print int($1)}')
|
|
||||||
if [ "$mtk" -eq 1 ]; then
|
|
||||||
check_mtk_connection
|
|
||||||
read_mtk_check_result
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
at_dial
|
|
||||||
fi
|
|
||||||
last_mtk_check=$current_time
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$ipv4" != "$ipv4_cache" ]; then
|
|
||||||
handle_ip_change
|
handle_ip_change
|
||||||
ipv6_cache=$ipv6
|
|
||||||
ipv4_cache=$ipv4
|
ipv4_cache=$ipv4
|
||||||
continue
|
ipv6_cache=$ipv6
|
||||||
fi
|
|
||||||
sleep 5
|
|
||||||
check_mtk_if_needed
|
|
||||||
sleep 5
|
|
||||||
check_mtk_if_needed
|
|
||||||
sleep 5
|
|
||||||
check_mtk_if_needed
|
|
||||||
fi
|
fi
|
||||||
|
[ "$mtk_check" -eq 1 ] && { sleep 5; check_mtk_connection || { fastat "$at_port" "AT+CGACT=0,3" && at_dial; }; } || sleep 15
|
||||||
|
;;
|
||||||
|
esac
|
||||||
check_logfile_line
|
check_logfile_line
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -459,8 +459,9 @@ add()
|
|||||||
set qmodem.$section_name.path="$modem_path"
|
set qmodem.$section_name.path="$modem_path"
|
||||||
set qmodem.$section_name.data_interface="$slot_type"
|
set qmodem.$section_name.data_interface="$slot_type"
|
||||||
set qmodem.$section_name.enable_dial="1"
|
set qmodem.$section_name.enable_dial="1"
|
||||||
set qmodem.$section_name.soft_reboot="0"
|
set qmodem.$section_name.soft_reboot="1"
|
||||||
set qmodem.$section_name.pdp_type="ip"
|
set qmodem.$section_name.extend_prefix="1"
|
||||||
|
set qmodem.$section_name.pdp_type="ipv4v6"
|
||||||
set qmodem.$section_name.state="enabled"
|
set qmodem.$section_name.state="enabled"
|
||||||
set qmodem.$section_name.metric=$metric
|
set qmodem.$section_name.metric=$metric
|
||||||
EOF
|
EOF
|
||||||
|
@ -6,7 +6,9 @@ _Author="Siriling Fujr"
|
|||||||
_Maintainer="Fujr <fjrcn@outlook.com>"
|
_Maintainer="Fujr <fjrcn@outlook.com>"
|
||||||
source /usr/share/qmodem/generic.sh
|
source /usr/share/qmodem/generic.sh
|
||||||
|
|
||||||
|
vendor_get_disabled_features(){
|
||||||
|
json_add_string "" ""
|
||||||
|
}
|
||||||
|
|
||||||
debug_subject="fibocom_ctrl"
|
debug_subject="fibocom_ctrl"
|
||||||
#获取拨号模式
|
#获取拨号模式
|
||||||
@ -77,7 +79,7 @@ get_mode()
|
|||||||
json_add_string "$available_mode" "0"
|
json_add_string "$available_mode" "0"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
json_close_objectget_imei
|
json_close_object
|
||||||
}
|
}
|
||||||
|
|
||||||
#设置拨号模式
|
#设置拨号模式
|
||||||
@ -219,7 +221,7 @@ set_network_prefer_nr()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
#设置模组
|
#设置模组
|
||||||
at_command="AT+GTACT=$network_prefer_num"
|
at_command="AT+GTACT=$network_prefer_num,6,3"
|
||||||
res=$(at $at_port "$at_command")
|
res=$(at $at_port "$at_command")
|
||||||
json_select_object "result"
|
json_select_object "result"
|
||||||
json_add_string "status" "$res"
|
json_add_string "status" "$res"
|
||||||
@ -826,8 +828,8 @@ set_lockband_nr()
|
|||||||
m_debug "Fibocom set lockband info"
|
m_debug "Fibocom set lockband info"
|
||||||
get_lockband_config_command="AT+GTACT?"
|
get_lockband_config_command="AT+GTACT?"
|
||||||
get_lockband_config_res=$(at $at_port $get_lockband_config_command)
|
get_lockband_config_res=$(at $at_port $get_lockband_config_command)
|
||||||
network_prefer_config=$(echo $get_lockband_config_res |cut -d : -f 2| awk -F"," '{ print $1","$2","$3}' |tr -d ' ')
|
network_prefer_config=$(echo $get_lockband_config_res |cut -d : -f 2| awk -F"," '{print $1}' |tr -d ' ')
|
||||||
local lock_band="$network_prefer_config,$lock_band"
|
local lock_band="$network_prefer_config,6,3,$lock_band"
|
||||||
local set_lockband_command="AT+GTACT=$lock_band"
|
local set_lockband_command="AT+GTACT=$lock_band"
|
||||||
res=$(at $at_port $set_lockband_command)
|
res=$(at $at_port $set_lockband_command)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user