diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh index 5e1ada1..d8cdd78 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh @@ -234,7 +234,6 @@ check_ip() ;; "mediatek") check_ip_command="AT+CGPADDR=3" - stric=1 ;; esac ;; @@ -293,77 +292,32 @@ check_ip() check_mtk_connection() { - local lock_file="${MODEM_RUNDIR}/${modem_config}_dir/mtk_check.lock" - 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 - local test=0 - - if ping -I "$modem_netcard" -c 1 -w 2 1.1.1.1 > /dev/null 2>&1; then - test=1 - 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 + [ "$connection_status" = "0" ] || [ "$connection_status" = "-1" ] && return 0 + if [ "$mtk" -eq 1 ] && [ -n "$ipv4" ] && [ -n "$modem_netcard" ]; then + for i in 1 2; do + if ping -I "$modem_netcard" -w 1 1.1.1.1 >/dev/null 2>&1 || + ping -I "$modem_netcard" -w 2 8.8.8.8 >/dev/null 2>&1; then + break fi - - if [ "$test" -eq 0 ]; then + if [ $i -eq 2 ]; then m_debug "IPv4 connection test failed, will redial" - echo "failed" > "$result_file" - rm -f "$lock_file" return 1 fi - - 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 - local ipv6_test=0 - - if ping6 -I "$modem_netcard" -c 1 -w 2 2400:3200::1 > /dev/null 2>&1; then - ipv6_test=1 - elif ping6 -I "$modem_netcard" -c 1 -w 2 2001:4860:4860::8888 > /dev/null 2>&1; then - ipv6_test=1 + sleep 1 + done + 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 5 ] && [ "$pdp_type" = "ipv4v6" ] && [ -n "$ipv6" ]; then + for i in 1 2; do + if ping6 -I "$modem_netcard" -w 1 2400:3200::1 >/dev/null 2>&1 || + ping6 -I "$modem_netcard" -w 2 2001:4860:4860::8888 >/dev/null 2>&1; then + break fi - - if [ "$ipv6_test" -eq 0 ]; then + if [ $i -eq 2 ]; then m_debug "IPv6 connection test failed, restarting IPv6 interface" - if [ -n "$interface6_name" ]; then - ifdown "$interface6_name" && sleep 2 && ifup "$interface6_name" - m_debug "Restarted IPv6 interface $interface6_name" - fi + [ -n "$interface6_name" ] && ifdown "$interface6_name" && sleep 2 && ifup "$interface6_name" fi - fi - - 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 + sleep 1 + done fi fi return 0 @@ -675,10 +629,9 @@ ecm_hang() at_command='ATI' fi - tmp=$(at "${at_port}" "${at_command}") + fastat "${at_port}" "${at_command}" } - hang() { m_debug "hang up $modem_path driver $driver" @@ -853,24 +806,22 @@ at_dial() esac m_debug "dialing vendor:$manufacturer;platform:$platform; $cgdcont_command ; $at_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 - at "$at_port" "AT+CGACT=0,3" + fastat "$at_port" "AT+CGACT=0,3" mbim_port=$(echo "$at_port" | sed 's/at/mbim/g') umbim -d $mbim_port disconnect - umbim -d $mbim_port connect 0 + sleep 1 + umbim -d $mbim_port connect fi } ip_change_fm350() { m_debug "ip_change_fm350" - local ipv4_config="" - local ipv4_dns1="" - local ipv4_dns2="" - local ipv6_dns1="" - local ipv6_dns2="" - local gateway="" + local public_dns1_ipv4="223.5.5.5" + local public_dns2_ipv4="119.29.29.29" local netmask="255.255.255.0" 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_dns2=$(echo "$config" | grep "ipv4dnsserver:" | tail -n 1 | awk '{print $2}') - if [ "$ipv4_dns1" = "$ipv4_dns2" ]; then - ipv4_dns2="119.29.29.29" - fi - - 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" + [ -z "$ipv4_dns1" ] && ipv4_dns1="$public_dns1_ipv4" + [ -z "$ipv4_dns2" ] && ipv4_dns2="$public_dns2_ipv4" + # m_debug "umbim config: ipv4=$ipv4_config, gateway=$gateway, netmask=$netmask, dns1=$ipv4_dns1, dns2=$ipv4_dns2" else 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" - local public_dns1_ipv4="223.5.5.5" - local public_dns2_ipv4="119.29.29.29" - local public_dns1_ipv6="2400:3200::1" - local public_dns2_ipv6="2402:4e00::" - at_command="AT+GTDNS=3" | 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}') - [ -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}" - } + response=$(at ${at_port} "AT+GTDNS=3") + ipv4_dns=$(echo "$response" | grep "+GTDNS:" | head -1) + ipv4_dns1=$(echo "$ipv4_dns" | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"' | head -1 | tr -d '"') + ipv4_dns2=$(echo "$ipv4_dns" | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"' | tail -1 | tr -d '"') + [ -z "$ipv4_dns1" ] && ipv4_dns1="$public_dns1_ipv4" + [ -z "$ipv4_dns2" ] && ipv4_dns2="$public_dns2_ipv4" uci_ipv4=$(uci -q get network.$interface_name.ipaddr) fi uci set network.${interface_name}.proto='static' @@ -1042,50 +971,34 @@ check_logfile_line() unexpected_response_count=0 at_dial_monitor() { - check_ip at_dial ipv4_cache=$ipv4 - last_mtk_check=0 + ipv6_cache=$ipv6 + sleep 5 while true; do check_ip - if [ $connection_status -eq 0 ];then - at_dial - sleep 3 - elif [ $connection_status -eq -1 ];then - unexpected_response_count=$((unexpected_response_count+1)) - if [ $unexpected_response_count -gt 3 ];then + case $connection_status in + 0) at_dial - unexpected_response_count=0 - fi - sleep 10 - else - check_mtk_if_needed() { - if [ "$mtk_check" = "1" ]; 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 + sleep 3 + ;; + -1) + unexpected_response_count=$((unexpected_response_count+1)) + if [ $unexpected_response_count -gt 3 ]; then + at_dial + unexpected_response_count=0 fi - } - - if [ "$ipv4" != "$ipv4_cache" ]; then - handle_ip_change - ipv6_cache=$ipv6 - ipv4_cache=$ipv4 - continue - fi - sleep 5 - check_mtk_if_needed - sleep 5 - check_mtk_if_needed - sleep 5 - check_mtk_if_needed - fi + sleep 5 + ;; + *) + if [ "$ipv4" != "$ipv4_cache" ] || [ "$ipv6" != "$ipv6_cache" ]; then + handle_ip_change + ipv4_cache=$ipv4 + ipv6_cache=$ipv6 + 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 done } diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh index 5d7f3af..f1f0e8f 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_scan.sh @@ -459,8 +459,9 @@ add() set qmodem.$section_name.path="$modem_path" set qmodem.$section_name.data_interface="$slot_type" set qmodem.$section_name.enable_dial="1" -set qmodem.$section_name.soft_reboot="0" -set qmodem.$section_name.pdp_type="ip" +set qmodem.$section_name.soft_reboot="1" +set qmodem.$section_name.extend_prefix="1" +set qmodem.$section_name.pdp_type="ipv4v6" set qmodem.$section_name.state="enabled" set qmodem.$section_name.metric=$metric EOF diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/fibocom.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/fibocom.sh index 4bb7418..9bbf282 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/fibocom.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/vendor/fibocom.sh @@ -6,7 +6,9 @@ _Author="Siriling Fujr" _Maintainer="Fujr " source /usr/share/qmodem/generic.sh - +vendor_get_disabled_features(){ + json_add_string "" "" +} debug_subject="fibocom_ctrl" #获取拨号模式 @@ -77,7 +79,7 @@ get_mode() json_add_string "$available_mode" "0" fi done - json_close_objectget_imei + json_close_object } #设置拨号模式 @@ -219,7 +221,7 @@ set_network_prefer_nr() esac #设置模组 - at_command="AT+GTACT=$network_prefer_num" + at_command="AT+GTACT=$network_prefer_num,6,3" res=$(at $at_port "$at_command") json_select_object "result" json_add_string "status" "$res" @@ -826,8 +828,8 @@ set_lockband_nr() m_debug "Fibocom set lockband info" get_lockband_config_command="AT+GTACT?" 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 ' ') - local lock_band="$network_prefer_config,$lock_band" + network_prefer_config=$(echo $get_lockband_config_res |cut -d : -f 2| awk -F"," '{print $1}' |tr -d ' ') + local lock_band="$network_prefer_config,6,3,$lock_band" local set_lockband_command="AT+GTACT=$lock_band" res=$(at $at_port $set_lockband_command) }