6 var callTTYDevices = rpc.declare({
8 method: 'getTTYDevices',
9 params: [ 'with_cdc', 'with_tts' ],
10 expect: { result: [] }
13 network.registerPatternVirtual(/^qmi-.+$/);
14 network.registerErrorCode('CALL_FAILED', _('Call failed'));
15 network.registerErrorCode('NO_CID', _('Unable to obtain client ID'));
16 network.registerErrorCode('PLMN_FAILED', _('Setting PLMN failed'));
18 return network.registerProtocol('qmi', {
20 return _('QMI Cellular');
23 getIfname: function() {
24 return this._ubus('l3_device') || 'qmi-%s'.format(this.sid);
27 getOpkgPackage: function() {
31 isFloating: function() {
35 isVirtual: function() {
39 getDevices: function() {
43 containsDevice: function(ifname) {
44 return (network.getIfnameOf(ifname) == this.getIfname());
47 renderFormOptions: function(s) {
48 var dev = this.getL3Device() || this.getDevice(), o;
50 o = s.taboption('general', form.Value, 'device', _('Modem device'));
52 o.load = function(section_id) {
53 return callTTYDevices(true, false).then(L.bind(function(devices) {
54 if (Array.isArray(devices))
55 for (var i = 0; i < devices.length; i++)
56 if (/cdc-wdm/.test(devices[i]))
57 this.value(devices[i]);
59 return form.Value.prototype.load.apply(this, [section_id]);
63 s.taboption('general', form.Value, 'apn', _('APN'));
64 s.taboption('general', form.Value, 'pincode', _('PIN'));
66 o = s.taboption('general', form.ListValue, 'auth', _('Authentication Type'));
67 o.value('both', 'PAP/CHAP (both)');
68 o.value('pap', 'PAP');
69 o.value('chap', 'CHAP');
70 o.value('none', 'NONE');
73 o = s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
74 o.depends('auth', 'pap');
75 o.depends('auth', 'chap');
76 o.depends('auth', 'both');
78 o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
79 o.depends('auth', 'pap');
80 o.depends('auth', 'chap');
81 o.depends('auth', 'both');
84 if (L.hasSystemFeature('ipv6')) {
85 o = s.taboption('advanced', form.Flag, 'ipv6', _('Enable IPv6 negotiation'));
86 o.default = o.disabled;
89 o = s.taboption('advanced', form.Value, 'delay', _('Modem init timeout'), _('Maximum amount of seconds to wait for the modem to become ready'));
91 o.datatype = 'min(1)';
93 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
94 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
95 o.datatype = 'max(9200)';