7 var callTTYDevices
= rpc
.declare({
9 method
: 'getTTYDevices',
10 params
: [ 'with_cdc', 'with_tts' ],
11 expect
: { result
: [] }
14 network
.registerPatternVirtual(/^3g-.+$/);
16 function write_keepalive(section_id
, value
) {
17 var f_opt
= this.map
.lookupOption('_keepalive_failure', section_id
),
18 i_opt
= this.map
.lookupOption('_keepalive_interval', section_id
),
19 f
= (f_opt
!= null) ? +f_opt
[0].formvalue(section_id
) : null,
20 i
= (i_opt
!= null) ? +i_opt
[0].formvalue(section_id
) : null;
22 if (f
== null || f
== '' || isNaN(f
))
25 if (i
== null || i
== '' || isNaN(i
) || i
< 1)
29 uci
.set('network', section_id
, 'keepalive', '%d %d'.format(f
, i
));
31 uci
.unset('network', section_id
, 'keepalive');
34 return network
.registerProtocol('3g', {
36 return _('UMTS/GPRS/EV-DO');
39 getIfname: function() {
40 return this._ubus('l3_device') || '3g-%s'.format(this.sid
);
43 getOpkgPackage: function() {
47 isFloating: function() {
51 isVirtual: function() {
55 getDevices: function() {
59 containsDevice: function(ifname
) {
60 return (network
.getIfnameOf(ifname
) == this.getIfname());
63 renderFormOptions: function(s
) {
66 o
= s
.taboption('general', form
.Value
, 'device', _('Modem device'));
68 o
.load = function(section_id
) {
69 return callTTYDevices(false, true).then(L
.bind(function(devices
) {
70 if (Array
.isArray(devices
))
71 for (var i
= 0; i
< devices
.length
; i
++)
72 this.value(devices
[i
]);
74 return form
.Value
.prototype.load
.apply(this, [section_id
]);
78 o
= s
.taboption('general', form
.Value
, 'service', _('Service Type'));
79 o
.value('', _('-- Please choose --'));
80 o
.value('umts', 'UMTS/GPRS');
81 o
.value('umts_only', _('UMTS only'));
82 o
.value('gprs_only', _('GPRS only'));
83 o
.value('evdo', 'CDMA/EV-DO');
85 s
.taboption('general', form
.Value
, 'apn', _('APN'));
86 s
.taboption('general', form
.Value
, 'pincode', _('PIN'));
87 s
.taboption('general', form
.Value
, 'username', _('PAP/CHAP username'));
89 o
= s
.taboption('general', form
.Value
, 'password', _('PAP/CHAP password'));
92 o
= s
.taboption('general', form
.Value
, 'dialnumber', _('Dial number'));
93 o
.placeholder
= '*99***1#';
95 if (L
.hasSystemFeature('ipv6')) {
96 o
= s
.taboption('advanced', form
.ListValue
, 'ipv6', _('Obtain IPv6-Address'));
97 o
.value('auto', _('Automatic'));
98 o
.value('0', _('Disabled'));
99 o
.value('1', _('Manual'));
103 o
= s
.taboption('advanced', form
.Value
, 'delay', _('Modem init timeout'), _('Maximum amount of seconds to wait for the modem to become ready'));
104 o
.placeholder
= '10';
105 o
.datatype
= 'min(1)';
107 o
= s
.taboption('advanced', form
.Flag
, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
108 o
.default = o
.enabled
;
110 o
= s
.taboption('advanced', form
.Value
, 'metric', _('Use gateway metric'));
112 o
.datatype
= 'uinteger';
113 o
.depends('defaultroute', '1');
115 o
= s
.taboption('advanced', form
.Flag
, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
116 o
.default = o
.enabled
;
118 o
= s
.taboption('advanced', form
.DynamicList
, 'dns', _('Use custom DNS servers'));
119 o
.depends('peerdns', '0');
120 o
.datatype
= 'ipaddr';
122 o
= s
.taboption('advanced', form
.Value
, '_keepalive_failure', _('LCP echo failure threshold'), _('Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures'));
124 o
.datatype
= 'uinteger';
125 o
.write
= write_keepalive
;
126 o
.remove
= write_keepalive
;
127 o
.cfgvalue = function(section_id
) {
128 var v
= uci
.get('network', section_id
, 'keepalive');
129 if (typeof(v
) == 'string' && v
!= '') {
130 var m
= v
.match(/^(\d+)[ ,]\d+$/);
135 o
= s
.taboption('advanced', form
.Value
, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
137 o
.datatype
= 'min(1)';
138 o
.write
= write_keepalive
;
139 o
.remove
= write_keepalive
;
140 o
.cfgvalue = function(section_id
) {
141 var v
= uci
.get('network', section_id
, 'keepalive');
142 if (typeof(v
) == 'string' && v
!= '') {
143 var m
= v
.match(/^\d+[ ,](\d+)$/);
148 o
= s
.taboption('advanced', form
.Value
, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
150 o
.datatype
= 'uinteger';