From a9de670c8e72f25c08296f3e5a765061451ad9bc Mon Sep 17 00:00:00 2001 From: Shibby Date: Fri, 12 Oct 2012 10:16:31 +0200 Subject: [PATCH] 3G Modem: Add support for ZTE MF195 - use cdc-acm.ko module - few updates in switch3g script - add ttyACM0 device in basic-network page - hide some fields when 3G modem type is selected --- release/src/router/others/switch3g | 39 ++++++++++++++++++++++++++++---- release/src/router/rc/wan.c | 20 ++++++++++++++-- release/src/router/www/basic-network.asp | 5 ++-- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/release/src/router/others/switch3g b/release/src/router/others/switch3g index 4857c02cbc..4f21628d45 100755 --- a/release/src/router/others/switch3g +++ b/release/src/router/others/switch3g @@ -4,17 +4,33 @@ # Copyright (C) 2011 shibby # +CHECK=`cat /tmp/switch3g.debug` +if [ "$CHECK" -gt 0 ]; then + logger 3G MODEM - previous proces of switch3g still working + exit 0 +fi + PIN=`nvram get modem_pin` IS_PIN=`nvram get modem_pin | wc -w` DEVNR=`nvram get modem_dev` -# is modem ready? +#run process +echo "1" > /tmp/switch3g.debug +# is modem ready? +DEV0=`cat /proc/bus/usb/devices | grep Driver | grep cdc_acm | wc -l` DEV1=`cat /proc/bus/usb/devices | grep Driver | grep option | wc -l` DEV2=`cat /proc/bus/usb/devices | grep Driver | grep sierra | wc -l` DEV3=`cat /proc/bus/usb/devices | grep Driver | grep usbserial | wc -l` -if [ "$DEV1" -gt 0 ]; then +if [ "$DEV0" -gt 0 ]; then + logger 3G MODEM already found - using cdc-acm module + nvram set 3g_module=cdc-acm + if [ "$IS_PIN" == "1" ]; then + echo -e "AT+CPIN=$PIN\r" > /dev/$DEVNR + fi + break; +elif [ "$DEV1" -gt 0 ]; then logger 3G MODEM already found - using option module nvram set 3g_module=option if [ "$IS_PIN" == "1" ]; then @@ -66,12 +82,21 @@ else done #trying option and sierra module first + modprobe cdc-acm modprobe option modprobe sierra sleep 2 - DEV=`cat /proc/bus/usb/devices | grep Driver | grep option | wc -l` + DEV0=`cat /proc/bus/usb/devices | grep Driver | grep cdc_acm | wc -l` + DEV1=`cat /proc/bus/usb/devices | grep Driver | grep option | wc -l` DEV2=`cat /proc/bus/usb/devices | grep Driver | grep sierra | wc -l` - if [ "$DEV" -gt 0 ]; then + if [ "$DEV0" -gt 0 ]; then + logger 3G MODEM ready - using cdc-acm module + nvram set 3g_module=cdc-acm + if [ "$IS_PIN" == "1" ]; then + echo -e "AT+CPIN=$PIN\r" > /dev/$DEVNR + fi + break; + elif [ "$DEV1" -gt 0 ]; then logger 3G MODEM ready - using option module nvram set 3g_module=option if [ "$IS_PIN" == "1" ]; then @@ -86,8 +111,9 @@ else fi break; else - logger 3G MODEM not found by option and sierra module. Trying usbserial ... + logger 3G MODEM not found by cdc-acm, option or sierra module. Trying usbserial ... + #rmmod cdc_acm //we can`t do that. I don`t know why... rmmod sierra rmmod option @@ -167,3 +193,6 @@ fi if [ "$NO" == "1" ]; then logger 3G MODEM not found ... sorry fi + +#end process +echo "0" > /tmp/switch3g.debug diff --git a/release/src/router/rc/wan.c b/release/src/router/rc/wan.c index fa62d4ef99..0845cdfaa1 100644 --- a/release/src/router/rc/wan.c +++ b/release/src/router/rc/wan.c @@ -135,8 +135,6 @@ static int config_pppd(int wan_proto, int num) "defaultroute\n" // Add a default route to the system routing tables, using the peer as the gateway "usepeerdns\n" // Ask the peer for up to 2 DNS server addresses "default-asyncmap\n" // Disable asyncmap negotiation - "nopcomp\n" // Disable protocol field compression - "noaccomp\n" // Disable Address/Control compression "novj\n" // Disable Van Jacobson style TCP/IP header compression "nobsdcomp\n" // Disable BSD-Compress compression "nodeflate\n" // Disable Deflate compression @@ -150,6 +148,24 @@ static int config_pppd(int wan_proto, int num) nvram_get_int("pppoe_lef") ? : 5, nvram_get_int("debug_ppp") ? "debug\n" : ""); +#ifdef LINUX26 +#ifdef TCONFIG_USB + if (nvram_match("wan_proto", "ppp3g") && nvram_match("modem_dev", "ttyACM0") ) { + //don`t write nopcomp and noaccomp options + } else { +#endif +#endif + fprintf(fp, + "nopcomp\n" // Disable protocol field compression + "noaccomp\n" // Disable Address/Control compression + ); +#ifdef LINUX26 +#ifdef TCONFIG_USB + } +#endif +#endif + + if (wan_proto != WP_L2TP) { fprintf(fp, "persist\n" diff --git a/release/src/router/www/basic-network.asp b/release/src/router/www/basic-network.asp index 03ee37b8a1..84db15e8b0 100644 --- a/release/src/router/www/basic-network.asp +++ b/release/src/router/www/basic-network.asp @@ -846,7 +846,6 @@ function verifyFields(focused, quiet) break; case 'ppp3g': vis._ppp_service = 0; - vis._ppp_custom = 0; vis._l2tp_server_ip = 0; vis._pptp_server_ip = 0; vis._f_pptp_dhcp = 0; @@ -854,6 +853,8 @@ function verifyFields(focused, quiet) vis._wan_ipaddr = 0; vis._wan_netmask = 0; vis._lan_gateway = 0; + vis._modem_ipaddr = 0; + vis._f_ppp_mlppp = 0; break; case 'static': vis._l2tp_server_ip = 0; @@ -1537,7 +1538,7 @@ createFieldTable('', [ /* LINUX26-END */ ['disabled','Disabled']], value: nvram.wan_proto }, - { title: 'Modem device', name: 'modem_dev', type: 'select', options: [['ttyUSB0', '/dev/ttyUSB0'],['ttyUSB1', '/dev/ttyUSB1'],['ttyUSB2', '/dev/ttyUSB2'],['ttyUSB3', '/dev/ttyUSB3']], value: nvram.modem_dev }, + { title: 'Modem device', name: 'modem_dev', type: 'select', options: [['ttyUSB0', '/dev/ttyUSB0'],['ttyUSB1', '/dev/ttyUSB1'],['ttyUSB2', '/dev/ttyUSB2'],['ttyUSB3', '/dev/ttyUSB3'],['ttyACM0', '/dev/ttyACM0']], value: nvram.modem_dev }, { title: 'PIN Code', name: 'modem_pin', type: 'text', maxlen: 6, size: 8, value: nvram.modem_pin }, { title: 'Modem init string', name: 'modem_init', type: 'text', maxlen: 25, size: 32, value: nvram.modem_init }, { title: 'APN', name: 'modem_apn', type: 'text', maxlen: 25, size: 32, value: nvram.modem_apn }, -- 2.11.4.GIT