1#!/bin/sh 2# echo "This is a script to find the modem type out." 3 4 5modem_act_path=`nvram get usb_modem_act_path` 6node_home=/sys/devices 7home="$node_home/"`cd $node_home && find -name "$modem_act_path" 2>/dev/null` 8modem_enable=`nvram get modem_enable` 9modem_vid=`cat $home/idVendor 2>/dev/null` 10modem_pid=`cat $home/idProduct 2>/dev/null` 11usb_gobi2=`nvram get usb_gobi2` 12 13if [ "$modem_vid" == "" -o "$modem_pid" == "" ]; then 14 echo "type=unknown" 15 nvram set usb_modem_act_type= 16 exit 0 17fi 18 19 20_find_act_type(){ 21 nodes=`cd $home && ls -d $modem_act_path:* 2>/dev/null` 22 23 got_tty=0 24 got_ecm=0 25 got_other=0 26 for node in $nodes; do 27 path=`readlink -f $home/$node/driver 2>/dev/null` 28 29 t=${path##*drivers/} 30 if [ "$t" == "option" -o "$t" == "usbserial" -o "$t" == "usbserial_generic" ]; then 31 got_tty=1 32 continue 33 elif [ "$t" == "cdc_acm" -o "$t" == "acm" ]; then 34 got_tty=1 35 continue 36 elif [ "$t" == "cdc_ether" ]; then 37 got_ecm=1 38 continue 39 elif [ "$t" == "rndis_host" ]; then 40 got_other=1 41 echo "rndis" 42 break 43 elif [ "$t" == "asix" ]; then 44 got_other=1 45 echo "asix" 46 break 47 elif [ "$t" == "qmi_wwan" ]; then 48 got_other=1 49 echo "qmi" 50 break 51 elif [ "$t" == "cdc_ncm" ]; then 52 got_other=1 53 echo "ncm" 54 break 55 elif [ "$t" == "cdc_mbim" ]; then 56 got_other=1 57 echo "mbim" 58 break 59 elif [ "$t" == "GobiNet" ]; then 60 got_other=1 61 echo "gobi" 62 break 63 fi 64 done 65 66 if [ $got_other -ne 1 ]; then 67 if [ $got_tty -eq 1 ]; then 68 echo "tty" 69 elif [ $got_ecm -eq 1 ]; then 70 echo "ecm" 71 else 72 echo "tty" 73 fi 74 fi 75} 76 77if [ "$usb_gobi2" == "1" ]; then 78 type="gobi" 79elif [ "$modem_enable" == "4" ]; then 80 type="wimax" 81# Some dongles are worked strange with QMI. e.q. Huawei EC306. 82elif [ "$modem_enable" == "2" -a "$type" == "qmi" ]; then 83 type="tty" 84elif [ "$modem_vid" == "19d2" -a "$modem_pid" == "1589" ]; then # ZTE MF193A 85 type="tty" 86else 87 type=`_find_act_type` 88fi 89echo "type=$type." 90 91nvram set usb_modem_act_type=$type 92 93