opkg update opkg install comgt kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan
usb-modeswitch luci-proto-3g
APN internet
phone *99***1#
cat /sys/kernel/debug/usb/devices
to check vender xxxx pid xxxx
echo "2001 7d00" > /sys/bus/usb-serial/drivers/option1/new_id
vi /etc/chatscripts/3g.chat
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 20
"" "AT+CSQ"
"" "AT&F"
OK "ATE1"
OK 'AT+CGDCONT=1,"IP","$USE_APN"'
SAY "Calling UMTS/GPRS"
TIMEOUT 60
OK "ATD$DIALNUMBER"
CONNECT ' '
vi /etc/config/network
config interface '3G_wan'
option ifname 'ppp0'
option proto '3g'
option service 'umts'
vi /etc/hotplug.d/usb/20-usbmode
#!/bin/sh
BINARY="gcom -d /dev/ttyUSB1"
RTL8188SU_PRODID="2001/7d00/200"
if [ "${PRODUCT}" = "${RTL8188SU_PRODID}" ]; then
if [ "${ACTION}" = "add" ]; then
${BINARY}
logger -t Hotplug DWM-156 Regiter network
fi
fi
vi /etc/hotplug.d/usb/10-usb_debug
#!/bin/sh
logger -t DEBUG "hotplug usb: action='$ACTION' devicename='$DEVICENAME' devname='$DEVNAME' devpath='$DEVPATH' product='$PRODUCT' type='$TYPE' interface='$INTERFACE'"
Start up openwrt
echo "2001 7d00" > /sys/bus/usb-serial/drivers/option1/new_id
echo "$(date "+%m%d%Y %T") : boot" >> log 2>&1
exit 0
vi /bin/test.sh
wget -s http://www.google.com
if [[ $? -eq 0 ]]; then
echo "$(date "+%m%d%Y %T") : 3g online" >> /log 2>&1
else
echo "$(date "+%m%d%Y %T") : 3g down" >> /log 2>&1
# turn off USB power
echo 0 > /sys/devices/virtual/gpio/gpio8/value
# let things settle
sleep 2
# turn on USB power
echo 1 > /sys/devices/virtual/gpio/gpio8/value
# restart the interface
fi
chmod 777 /bin/test.sh
schedule task
*/2 * * * * test.sh