From 9da2779e0a21a82dd09384764d1af4d5acd22fc6 Mon Sep 17 00:00:00 2001 From: Shibby Date: Sun, 24 May 2015 14:51:46 +0200 Subject: [PATCH] switch4g: improvements --- release/src/router/others/switch4g | 50 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/release/src/router/others/switch4g b/release/src/router/others/switch4g index 006444114d..e2153c47ee 100755 --- a/release/src/router/others/switch4g +++ b/release/src/router/others/switch4g @@ -71,6 +71,8 @@ else modprobe cdc_ether modprobe cdc_ncm + sleep 5 + # is modem ready? NH=`cat /proc/bus/usb/devices | grep Driver | grep cdc_ncm | wc -l` H=`cat /proc/bus/usb/devices | grep Driver | grep cdc_ether | wc -l` @@ -194,24 +196,36 @@ else done #search WAN interface (usbX or ethX) - HWAN=`dmesg | grep cdc_ether | grep register | grep "'" | cut -d " " -f1 | cut -d ":" -f1` - NHWAN=`dmesg | grep cdc_ncm | grep register | grep "'" | cut -d " " -f1 | cut -d ":" -f1` - - IS_HWAN=`echo $HWAN | wc -w` - IS_NHWAN=`echo NHWAN | wc -w` - - if [ "$IS_HWAN" -gt 0 ]; then - logger 4G MODEM WAN found - Hilink - using $HWAN as WAN - nvram set wan_4g="$HWAN" - nvram set modem_type=hilink - elif [ "$IS_NHWAN" -gt 0 ]; then - logger 4G MODEM WAN found - Non-Hilink - using $NHWAN as WAN - nvram set wan_4g="$NHWAN" - nvram set modem_type=nonhilink - else - logger 4G MODEM WAN not found - exit - break; - fi + FOUND=0 + COUNT=0 + + while [ $FOUND == "0" ]; do + HWAN=`dmesg | grep cdc_ether | grep register | grep "'" | cut -d ":" -f1 | head -n 1` + NHWAN=`dmesg | grep cdc_ncm | grep register | grep "'" | cut -d ":" -f1 | head -n 1` + IS_HWAN=`echo $HWAN | wc -w` + IS_NHWAN=`echo $NHWAN | wc -w` + + if [ "$IS_HWAN" -gt 0 ]; then + logger 4G MODEM WAN found - Hilink - using $HWAN as WAN + nvram set wan_4g="$HWAN" + nvram set modem_type=hilink + FOUND=1 + elif [ "$IS_NHWAN" -gt 0 ]; then + logger 4G MODEM WAN found - Non-Hilink - using $NHWAN as WAN + nvram set wan_4g="$NHWAN" + nvram set modem_type=nonhilink + FOUND=1 + else + if [ "$COUNT" == "5" ]; then + logger 4G MODEM WAN not found - connection process terminated! + exit 0; + else + logger 4G MODEM WAN not found - count: $COUNT + COUNT=`expr $COUNT + 1` + sleep 5 + fi + fi + done #set pin if [ "$IS_PIN" == "1" -a "$NH" -gt 0 ]; then #only for non-hilink -- 2.11.4.GIT