OpenWrt connect to UMTS with Huawei E620 3G USB Modem

# install packages
opkg update
opkg install usbutils
opkg install kmod-usb-serial kmod-usb2 kmod-usb-uhci kmod-usb-ohci
opkg install ppp kmod-ppp
opkg install huaweiaktbbo
opkg install comgt
opkg install usb-modeswitch usb-modeswitch-data
 
# OPTIONAL, webgui support for 3g
opkg install luci-proto-3g
 
# list USB devices
lsusb
 
# OUTPUT:
Bus 001 Device 002: ID 12d1:1520 Huawei Technologies Co., Ltd. K3765 HSPA
 
# load serial module on boot
VENDOR=$(lsusb | grep Huawei | cut -d" " -f6 | cut -d":" -f1)
PRODUCT=$(lsusb | grep Huawei | cut -d" " -f6 | cut -d":" -f2)
echo "usbserial vendor=0x${VENDOR} product=0x${PRODUCT}" > /etc/modules.d/60-usb-serial
 
# remove "***1" from ATD command
cp /etc/chatscripts/3g.chat /etc/chatscripts/3g.chat.org
sed -i "s|\*\*\*1||g" /etc/chatscripts/3g.chat
sed -i 's/  \+/ /g' /etc/chatscripts/3g.chat
 
# create umts interface
uci del network.umts
uci set network.umts=interface
uci set network.umts.proto=3g
uci set network.umts.service=umts
uci set network.umts.device=/dev/ttyUSB0
uci set network.umts.apn=pinternet.interkom.de
#uci set network.umts.username=''
#uci set network.umts.password=''
uci set firewall.@zone[1].network='wan umts'
uci commit network
#ifup umts
 
# ann new network to firewall
vi /etc/config/firewall
config 'zone'
add
option 'network' 'wan ppp0'  
 
# reboot openwrt
reboot
 
# connect to 3g network
ifup ppp0
 
# config files
/etc/chatscripts/3g.chat
/etc/modules.d/60-usb-serial
/etc/config/network
/etc/config/firewall
 
# view logs
logread
 
# switch usb storrage to modem device
usb_modeswitch -c /etc/usb_modeswitch.d/12d1:1001
 
# Info / Debug
gcom -d /dev/ttyUSB0 info
 
# view log
logread -f
 
 
# check modem
gcom -d /dev/ttyUSB0 info
 
# connect to 3G network (O2 Germany)
cat <<EOF>> /etc/config/network
config 'interface' 'ppp0'
        option 'ifname' 'ppp0'
        #option 'pincode' '1234'
        option 'device' '/dev/ttyUSB0'
        option 'apn' 'pinternet.interkom.de'
        option 'service' 'umts'
        option 'proto' '3g'
EOF
 
usb_modeswitch -v 12d1 -p 1465 -c /etc/usb_modeswitch.d/12d1:1520
 
# download packages offline
wget https://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/ -O /tmp/downloads.openwrt.org.list
 
PACKAGES="chat_2.4.5-8 comgt_0.32-21 huaweiaktbbo_1 kmod-atm_3.3.8-1 kmod-pppoa_3.3.8-1 kmod-ppp-synctty_3.3.8-1 kmod-usb2_3.3.8-1 kmod-usb-ohci_3.3.8-1 kmod-usb-serial-ark3116_3.3.8-1 kmod-usb-uhci_3.3.8-1 librt_0.9.33.2-1 libusb_0.1.12-3 libusb-1.0_1.0.9-1 linux-atm_2.5.2-4 luci-proto-3g_0.11.1-1 ppp-mod-pppoa_2.4.5-8 usb-modeswitch_1.2.3-2 usb-modeswitch-data_20120120-1 usbutils_005-1"
 
for FILE in ${PACKAGES}; do
    # fixme
    IPK=$(grep "\"${FILE}" /tmp/downloads.openwrt.org.list | cut -d ">" -f2  | cut -d "<" -f1 )
    wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/${IPK}
done
 
 
 
 
 
 
 
# Links
http://josefsson.org/openwrt/dongle.html
http://wiki.openwrt.org/doc/recipes/3gdongle
http://wiki.ubuntuusers.de/USB_ModeSwitch
http://chtaube.eu/tech/openwrt/tl-mr3020.html