From ed6cb6cd134424c5a97c8f7c29377cb2c7489a9d Mon Sep 17 00:00:00 2001 From: Jeremy Chadwick Date: Tue, 3 Jan 2017 15:42:51 +0700 Subject: [PATCH] Don't send AT+CGDCONT if APN field is empty Some 3G modems/ISPs) don't require an APN, and the PDP context set AT command returns ERROR in this scenario. Allow users to empty the APN field in the GUI to disable sending the AT+CGDCONT command. This is needed for BSNL EVDO (India) customers. Reference: http://www.linksysinfo.org/index.php?threads/how-to-edit-file-on-tomato-firmware.73090/ Reference: http://m2msupport.net/m2msupport/atcgdcont-define-pdp-context/ --- release/src-rt-6.x.4708/router/rc/wan.c | 14 ++++++++++++-- release/src-rt-6.x.4708/router/www/basic-network.asp | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/release/src-rt-6.x.4708/router/rc/wan.c b/release/src-rt-6.x.4708/router/rc/wan.c index b4394d2d68..aa1d5714be 100644 --- a/release/src-rt-6.x.4708/router/rc/wan.c +++ b/release/src-rt-6.x.4708/router/rc/wan.c @@ -234,10 +234,20 @@ static int config_pppd(int wan_proto, int num) "OK \"AT\"\n" "OK \"AT&FE0V1X1&D2&C1S0=0\"\n" "OK \"AT\"\n" - "OK 'AT+CGDCONT=1,\"IP\",\"%s\"'\n" + ); + + /* Only send the AT+CGDCONT (define PDP context) command to set + * the APN if modem_apn is defined and non-empty. Some ISPs + * (ex. BSNL EVDO in India) don't need this (the modem returns + * ERROR if issued). + */ + if (((p = nvram_get("modem_apn")) != NULL) && (*p)) { + fprintf(cfp, "OK 'AT+CGDCONT=1,\"IP\",\"%s\"'\n", p); + } + + fprintf(cfp, "OK \"ATDT%s\"\n" "CONNECT \\c\n", - nvram_safe_get("modem_apn"), nvram_safe_get("modem_init") ); fclose(cfp); diff --git a/release/src-rt-6.x.4708/router/www/basic-network.asp b/release/src-rt-6.x.4708/router/www/basic-network.asp index 1e336fe31b..be8166a012 100644 --- a/release/src-rt-6.x.4708/router/www/basic-network.asp +++ b/release/src-rt-6.x.4708/router/www/basic-network.asp @@ -1660,7 +1660,7 @@ createFieldTable('', [ { title: 'Modem device', name: 'modem_dev', type: 'select', options: [['ttyUSB0', '/dev/ttyUSB0'],['ttyUSB1', '/dev/ttyUSB1'],['ttyUSB2', '/dev/ttyUSB2'],['ttyUSB3', '/dev/ttyUSB3'],['ttyUSB4', '/dev/ttyUSB4'],['ttyUSB5', '/dev/ttyUSB5'],['ttyUSB6', '/dev/ttyUSB6'],['ttyACM0', '/dev/ttyACM0']], value: nvram.modem_dev }, { title: 'PIN Code', name: 'modem_pin', type: 'text', maxlen: 6, size: 8, value: nvram.modem_pin, suffix: ' (advised to turn off PIN Code)' }, { 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 }, + { title: 'APN', name: 'modem_apn', type: 'text', maxlen: 25, size: 32, suffix: ' (if empty, AT+CGDCONT will not be sent)', value: nvram.modem_apn }, { title: 'Username', name: 'ppp_username', type: 'text', maxlen: 60, size: 64, value: nvram.ppp_username }, { title: 'Password', name: 'ppp_passwd', type: 'password', maxlen: 60, size: 64, peekaboo: 1, value: nvram.ppp_passwd }, { title: 'Service Name', name: 'ppp_service', type: 'text', maxlen: 50, size: 64, value: nvram.ppp_service }, -- 2.11.4.GIT