6 function getModemList() {
7 return fs
.exec_direct('/usr/bin/mmcli', [ '-L' ]).then(function(res
) {
8 var lines
= (res
|| '').split(/\n/),
11 for (var i
= 0; i
< lines
.length
; i
++) {
12 var m
= lines
[i
].match(/\/Modem\/(\d+)/);
14 tasks
.push(fs
.exec_direct('/usr/bin/mmcli', [ '-m', m
[1] ]));
17 return Promise
.all(tasks
).then(function(res
) {
20 for (var i
= 0; i
< res
.length
; i
++) {
21 var man
= res
[i
].match(/manufacturer: ([^\n]+)/),
22 mod
= res
[i
].match(/model: ([^\n]+)/),
23 dev
= res
[i
].match(/device: ([^\n]+)/);
27 device
: dev
[1].trim(),
28 manufacturer
: (man
? man
[1].trim() : '') || '?',
29 model
: (mod
? mod
[1].trim() : '') || dev
[1].trim()
39 network
.registerPatternVirtual(/^mobiledata-.+$/);
40 network
.registerErrorCode('CALL_FAILED', _('Call failed'));
41 network
.registerErrorCode('NO_CID', _('Unable to obtain client ID'));
42 network
.registerErrorCode('PLMN_FAILED', _('Setting PLMN failed'));
44 return network
.registerProtocol('modemmanager', {
46 return _('ModemManager');
49 getIfname: function() {
50 return this._ubus('l3_device') || 'modemmanager-%s'.format(this.sid
);
53 getOpkgPackage: function() {
54 return 'modemmanager';
57 isFloating: function() {
61 isVirtual: function() {
65 getDevices: function() {
69 containsDevice: function(ifname
) {
70 return (network
.getIfnameOf(ifname
) == this.getIfname());
73 renderFormOptions: function(s
) {
74 var dev
= this.getL3Device() || this.getDevice(), o
;
76 o
= s
.taboption('general', form
.ListValue
, 'device', _('Modem device'));
78 o
.load = function(section_id
) {
79 return getModemList().then(L
.bind(function(devices
) {
80 for (var i
= 0; i
< devices
.length
; i
++)
81 this.value(devices
[i
].device
,
82 '%s - %s'.format(devices
[i
].manufacturer
, devices
[i
].model
));
83 return form
.Value
.prototype.load
.apply(this, [section_id
]);
87 s
.taboption('general', form
.Value
, 'apn', _('APN'));
88 s
.taboption('general', form
.Value
, 'pincode', _('PIN'));
90 o
= s
.taboption('general', form
.ListValue
, 'auth', _('Authentication Type'));
91 o
.value('both', _('PAP/CHAP (both)'));
92 o
.value('pap', 'PAP');
93 o
.value('chap', 'CHAP');
94 o
.value('none', _('None'));
97 o
= s
.taboption('general', form
.Value
, 'username', _('PAP/CHAP username'));
98 o
.depends('auth', 'pap');
99 o
.depends('auth', 'chap');
100 o
.depends('auth', 'both');
102 o
= s
.taboption('general', form
.Value
, 'password', _('PAP/CHAP password'));
103 o
.depends('auth', 'pap');
104 o
.depends('auth', 'chap');
105 o
.depends('auth', 'both');
108 o
= s
.taboption('general', form
.ListValue
, 'iptype', _('IP Type'));
109 o
.value('ipv4v6', _('IPv4/IPv6 (both - defaults to IPv4)'))
110 o
.value('ipv4', _('IPv4 only'));
111 o
.value('ipv6', _('IPv6 only'));
112 o
.default = 'ipv4v6';
114 o
= s
.taboption('advanced', form
.Value
, 'mtu', _('Override MTU'));
115 o
.placeholder
= dev
? (dev
.getMTU() || '1500') : '1500';
116 o
.datatype
= 'max(9200)';
118 s
.taboption('general', form
.Value
, 'metric', _('Gateway metric'));