===== MT7620 3G Dongle 設定 =====
==== Ralink 3G dongle 設定 ====
1. SDK enable 3G, please refer SDK(SDK4100) (11.40) p.141~p.145
2. 3G 功能在 WAN 中, 即 Static IP, DHCP, PPPoE, L2TP, PPTP, 3G 同時僅能選一項功能
3. 選 3G 時, 有指定 dongle 型號及自動偵測
4. 連線參數:
APN: Internet
Dial Number: *99#
重點程式:
* internet.c
* internet.sh
* autoconn3G.sh
* 3g.sh
* usb_modeswitch
\\
==== 3G dongle 運作原理 ====
1. wan.asp 會先 submit 到 /goform/setWan
source code: source\user\goahead\src\internet.c
/* goform/setWan */
static void setWan(webs_t wp, char_t *path, char_t *query)
{
...
#ifdef CONFIG_USER_3G
else if (!strncmp(ctype, "3G", 3)) {
//usb3g_mode = websGetVar(wp, T("OPMode3G"), T(""));
usb3g_dev = websGetVar(wp, T("Dev3G"), T(""));
usb3g_apn = websGetVar(wp, T("APN3G"), T(""));
usb3g_pin = websGetVar(wp, T("PIN3G"), T(""));
usb3g_dial = websGetVar(wp, T("Dial3G"), T(""));
usb3g_user = websGetVar(wp, T("User3G"), T(""));
usb3g_pass = websGetVar(wp, T("Password3G"), T(""));
//nvram_bufset(RT2860_NVRAM, "wan_3g_opmode", usb3g_mode);
nvram_bufset(RT2860_NVRAM, "wan_3g_dev", usb3g_dev);
nvram_bufset(RT2860_NVRAM, "wan_3g_apn", usb3g_apn);
nvram_bufset(RT2860_NVRAM, "wan_3g_pin", usb3g_pin);
nvram_bufset(RT2860_NVRAM, "wan_3g_dial", usb3g_dial);
nvram_bufset(RT2860_NVRAM, "wan_3g_user", usb3g_user);
nvram_bufset(RT2860_NVRAM, "wan_3g_pass", usb3g_pass);
nvram_bufset(RT2860_NVRAM, "wanConnectionMode", ctype);
}
#endif
.
.
.
initInternet();
.
.
.
#ifdef CONFIG_USER_3G
else if (!strncmp(ctype, "3G", 3)) {
websWrite(wp, T("3G device: %s
\n"), usb3g_dev);
websWrite(wp, T("APN: %s
\n"), usb3g_apn);
websWrite(wp, T("PIN: %s
\n"), usb3g_pin);
websWrite(wp, T("Dial Number: %s
\n"), usb3g_dial);
websWrite(wp, T("Username: %s
\n"), usb3g_user);
websWrite(wp, T("Password: %s
\n"), usb3g_pass);
}
#endif
}
2. 以上程式會執行 internet.sh, 而internet.sh 會執行 autoconn3G.sh
3. autoconn3G.sh 將從系統 USB 裝置中, 與支援列表中找出對應的 dongle, 對將型號傳給 3g.sh, 由3g.sh 將dongle 轉成 modem 後連線.
.
.
.
SUPPORT_3G="12D1:1001:HUAWEI-E169
12D1:1003:HUAWEI-E220
0408:EA02:MU-Q101
0408:1000:MU-Q101
0AF0:6971:OPTION-ICON225
1AB7:5700:DATANG-M5731
1AB7:5731:DATANG-M5731
FEED:5678:MobilePeak-Titan
FEED:0001:MobilePeak-Titan
1A8D:1000:BandLuxe-C270
1A8D:1009:BandLuxe-C270"
.
.
.
DEV=`nvram_get 2860 wan_3g_dev`
cat /proc/bus/usb/devices | sed -n '/.* Vendor=.* ProdID=.*/p' | sed -e 's/.*Vendor=\(.*\) ProdID=\(.*\) Rev.*/\1:\2/' | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' > $DEV_FILE
for i in `cat "$DEV_FILE"`
do
for j in $SUPPORT_3G
do
k=`echo $j | sed -e 's/\(.*\):\(.*\):.*/\1:\2/'`
if [ $i = $k ]; then
k=`echo $j | sed -e 's/.*:.*:\(.*\)$/\1/'`
if [ $DEV = "Auto" ] || [ $DEV = "" ] || [ $k = $DEV ] ; then
3g.sh $k
rm -f $DEV_FILE
rm -f $LOCK_FILE
exit 1
fi
fi
done
done
.
.
.
4. 3g.sh 將依型號, 指定 conf file 轉換 USB to Modem
.
.
.
#change 3G dongle state to modem
if [ "$dev" = "MU-Q101" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_MU-Q101.conf
elif [ "$dev" = "HUAWEI-E169" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_HUAWEI-E169.conf
elif [ "$dev" = "HUAWEI-E220" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_HUAWEI-E220.conf
elif [ "$dev" = "BandLuxe-C270" ]; then
sdparm --command=eject /dev/sr0
sdparm --command=eject /dev/sg0
elif [ "$dev" = "MobilePeak-Titan" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_MobilePeak-Titan.conf
elif [ "$dev" = "OPTION-ICON225" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_OPTION-ICON225.conf
elif [ "$dev" = "DATANG-M5731" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_DATANG-M5731.conf
#else
#other supported devcies
fi
.
.
.
5. usb_modeswitch conf file list, 可以從 source\user\usb_modeswitch-0.9.5\usb_modeswitch.conf 找出, 並寫成一支conf file.
########################################################
# Huawei E220 (aka "Vodafone EasyBox II", aka "T-Mobile wnw Box Micro")
# Huawei E270
# Huawei E870
#
# Two options: 1. removal of "usb-storage" 2. the special control
# message found by Miroslav Bobovsky
#
# Contributor: Hans Kurent, Denis Sutter
DefaultVendor= 0x12d1;
DefaultProduct= 0x1003
# choose one of these:
DetachStorageOnly=1
HuaweiMode=1
6. 指定modem的port, 並撥號連線
.
.
.
#create ppp call script for 3G connection
if [ "$dev" = "MU-Q101" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "HUAWEI-E169" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "HUAWEI-E220" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "BandLuxe-C270" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "MobilePeak-Titan" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "DATANG-M5731" ]; then
modem_f=ttyUSB0
else
#other supported devcies
modem_f=ttyUSB0
fi
.
.
.
if [ "$dev" != "OPTION-ICON225" ]; then
config-3g-ppp.sh -p $pass -u $user -m $modem_f -c Generic_conn.scr -d Generic_disconn.scr
pppd call 3g
elif [ "$dev" = "OPTION-ICON225" ]; then
if [ "$apn" != "" ]; then
echo "APN=$apn" > /etc/conninfo.ini
else
echo "APN=internet" > /etc/conninfo.ini
fi
if [ "$pin" != "" ]; then
echo "PIN=$pin" >> /etc/conninfo.ini
fi
echo "USER=$user" >> /etc/conninfo.ini
echo "PASS=$pass" >> /etc/conninfo.ini
hso_connect.sh up
fi
.
.
.
==== 新增 3G Dongle Support ====
- 由 cat /proc/bus/usb/devices 或 由 usb_modeswitch.conf 找出其 Dongle 的 VID/PID
- 將其 VID/PID 加入 autoconn3G.sh
SUPPORT_3G="12D1:1001:HUAWEI-E169
12D1:1003:HUAWEI-E220
0408:EA02:MU-Q101
0408:1000:MU-Q101
0AF0:6971:OPTION-ICON225
1AB7:5700:DATANG-M5731
1AB7:5731:DATANG-M5731
FEED:5678:MobilePeak-Titan
FEED:0001:MobilePeak-Titan
1A8D:1000:BandLuxe-C270
1A8D:1009:BandLuxe-C270"
- 及3g.sh
#change 3G dongle state to modem
if [ "$dev" = "MU-Q101" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_MU-Q101.conf
elif [ "$dev" = "HUAWEI-E169" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_HUAWEI-E169.conf
elif [ "$dev" = "HUAWEI-E220" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_HUAWEI-E220.conf
elif [ "$dev" = "BandLuxe-C270" ]; then
sdparm --command=eject /dev/sr0
sdparm --command=eject /dev/sg0
elif [ "$dev" = "MobilePeak-Titan" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_MobilePeak-Titan.conf
elif [ "$dev" = "OPTION-ICON225" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_OPTION-ICON225.conf
elif [ "$dev" = "DATANG-M5731" ]; then
usb_modeswitch -c /etc_ro/usb/usb_modeswitch_DATANG-M5731.conf
#else
#other supported devcies
fi
.
.
.
#create ppp call script for 3G connection
if [ "$dev" = "MU-Q101" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "HUAWEI-E169" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "HUAWEI-E220" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "BandLuxe-C270" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "MobilePeak-Titan" ]; then
modem_f=ttyUSB0
elif [ "$dev" = "DATANG-M5731" ]; then
modem_f=ttyUSB0
else
#other supported devcies
modem_f=ttyUSB0
fi
- 再產生一份 conf file 例:usb_modeswitch_HUAWEI-E220.conf, 放入 source\user\usb_modeswitch-0.9.5\conf
- 連線時, 選自動偵測即可.