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('MM_CONNECT_FAILED', _('Connection attempt failed.'));
41 network
.registerErrorCode('MM_DISCONNECT_IN_PROGRESS', _('Modem disconnection in progress. Please wait.'));
42 network
.registerErrorCode('MM_CONNECT_IN_PROGRESS', _('Modem connection in progress. Please wait. This process will timeout after 2 minutes.'));
43 network
.registerErrorCode('MM_TEARDOWN_IN_PROGRESS', _('Modem bearer teardown in progress.'));
44 network
.registerErrorCode('MM_MODEM_DISABLED', _('Modem is disabled.'));
45 network
.registerErrorCode('DEVICE_NOT_MANAGED', _('Device not managed by ModemManager.'));
46 network
.registerErrorCode('INVALID_BEARER_LIST', _('Invalid bearer list. Possibly too many bearers created. This protocol supports one and only one bearer.'));
47 network
.registerErrorCode('UNKNOWN_METHOD', _('Unknown and unsupported connection method.'));
48 network
.registerErrorCode('DISCONNECT_FAILED', _('Disconnection attempt failed.'));
50 return network
.registerProtocol('modemmanager', {
52 return _('ModemManager');
55 getIfname: function() {
56 return this._ubus('l3_device') || 'modemmanager-%s'.format(this.sid
);
59 getOpkgPackage: function() {
60 return 'modemmanager';
63 isFloating: function() {
67 isVirtual: function() {
71 getDevices: function() {
75 containsDevice: function(ifname
) {
76 return (network
.getIfnameOf(ifname
) == this.getIfname());
79 renderFormOptions: function(s
) {
80 var dev
= this.getL3Device() || this.getDevice(), o
;
82 o
= s
.taboption('general', form
.ListValue
, 'device', _('Modem device'));
84 o
.load = function(section_id
) {
85 return getModemList().then(L
.bind(function(devices
) {
86 for (var i
= 0; i
< devices
.length
; i
++)
87 this.value(devices
[i
].device
,
88 '%s - %s'.format(devices
[i
].manufacturer
, devices
[i
].model
));
89 return form
.Value
.prototype.load
.apply(this, [section_id
]);
93 s
.taboption('general', form
.Value
, 'apn', _('APN'));
94 s
.taboption('general', form
.Value
, 'pincode', _('PIN'));
96 o
= s
.taboption('general', form
.ListValue
, 'auth', _('Authentication Type'));
97 o
.value('both', _('PAP/CHAP (both)'));
98 o
.value('pap', 'PAP');
99 o
.value('chap', 'CHAP');
100 o
.value('none', _('None'));
103 o
= s
.taboption('general', form
.Value
, 'username', _('PAP/CHAP username'));
104 o
.depends('auth', 'pap');
105 o
.depends('auth', 'chap');
106 o
.depends('auth', 'both');
108 o
= s
.taboption('general', form
.Value
, 'password', _('PAP/CHAP password'));
109 o
.depends('auth', 'pap');
110 o
.depends('auth', 'chap');
111 o
.depends('auth', 'both');
114 o
= s
.taboption('general', form
.ListValue
, 'iptype', _('IP Type'));
115 o
.value('ipv4v6', _('IPv4/IPv6 (both - defaults to IPv4)'))
116 o
.value('ipv4', _('IPv4 only'));
117 o
.value('ipv6', _('IPv6 only'));
118 o
.default = 'ipv4v6';
120 o
= s
.taboption('advanced', form
.Value
, 'mtu', _('Override MTU'));
121 o
.placeholder
= dev
? (dev
.getMTU() || '1500') : '1500';
122 o
.datatype
= 'max(9200)';
124 o
= s
.taboption('general', form
.Value
, 'signalrate', _('Signal Refresh Rate'), _("In seconds"));
125 o
.datatype
= 'uinteger';