mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 07:23:56 +08:00
🎄 Sync 2026-04-23 03:14:31
This commit is contained in:
1 parent
67b877b3d6
commit
7439c23f17
97 files changed
+4710
-1
No files matched your search
@@ -0,0 +1,119 @@
|
||||
'use strict';
|
||||
'require rpc';
|
||||
'require uci';
|
||||
'require form';
|
||||
'require network';
|
||||
|
||||
var callFileList = rpc.declare({
|
||||
object: 'file',
|
||||
method: 'list',
|
||||
params: [ 'path' ],
|
||||
expect: { entries: [] },
|
||||
filter: function(list, params) {
|
||||
var rv = [];
|
||||
for (var i = 0; i < list.length; i++)
|
||||
if (list[i].name.match(/^tty[A-Z]/) || list[i].name.match(/^[0-9]+$/))
|
||||
rv.push(params.path + list[i].name);
|
||||
return rv.sort();
|
||||
}
|
||||
});
|
||||
|
||||
network.registerPatternVirtual(/^nbiot-.+$/);
|
||||
|
||||
return network.registerProtocol('nbiot', {
|
||||
getI18n: function() {
|
||||
return _('NB-IoT (SIM7020E)');
|
||||
},
|
||||
|
||||
getIfname: function() {
|
||||
return this._ubus('l3_device') || 'nbiot-%s'.format(this.sid);
|
||||
},
|
||||
|
||||
getOpkgPackage: function() {
|
||||
return 'comgt';
|
||||
},
|
||||
|
||||
isFloating: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
isVirtual: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
getDevices: function() {
|
||||
return null;
|
||||
},
|
||||
|
||||
containsDevice: function(ifname) {
|
||||
return (network.getIfnameOf(ifname) == this.getIfname());
|
||||
},
|
||||
|
||||
renderFormOptions: function(s) {
|
||||
var o;
|
||||
|
||||
o = s.taboption('general', form.Value, '_modem_device', _('Modem device'));
|
||||
o.ucioption = 'device';
|
||||
o.rmempty = false;
|
||||
o.load = function(section_id) {
|
||||
return callFileList('/dev/').then(L.bind(function(devices) {
|
||||
for (var i = 0; i < devices.length; i++)
|
||||
this.value(devices[i]);
|
||||
return callFileList('/dev/tts/');
|
||||
}, this)).then(L.bind(function(devices) {
|
||||
for (var i = 0; i < devices.length; i++)
|
||||
this.value(devices[i]);
|
||||
return form.Value.prototype.load.apply(this, [section_id]);
|
||||
}, this));
|
||||
};
|
||||
|
||||
o = s.taboption('general', form.DummyValue, 'imei', _('IMEI'));
|
||||
o = s.taboption('general', form.DummyValue, 'ccid', _('SIM CCID'));
|
||||
|
||||
o = s.taboption('general', form.Value, 'apn', _('APN'));
|
||||
o.validate = function(section_id, value) {
|
||||
if (value == null || value == '')
|
||||
return true;
|
||||
|
||||
if (!/^[a-zA-Z0-9\-.]*[a-zA-Z0-9]$/.test(value))
|
||||
return _('Invalid APN provided');
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
o = s.taboption('general', form.Value, 'pincode', _('PIN'));
|
||||
o.datatype = 'and(uinteger,minlength(4),maxlength(8))';
|
||||
|
||||
o = s.taboption('general', form.ListValue, 'auth', _('Authentication Type'));
|
||||
o.value('pap', 'PAP');
|
||||
o.value('chap', 'CHAP');
|
||||
o.value('none', 'NONE');
|
||||
o.default = 'none';
|
||||
|
||||
o = s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
|
||||
o.depends('auth', 'pap');
|
||||
o.depends('auth', 'chap');
|
||||
o.depends('auth', 'both');
|
||||
|
||||
o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
|
||||
o.depends('auth', 'pap');
|
||||
o.depends('auth', 'chap');
|
||||
o.depends('auth', 'both');
|
||||
o.password = true;
|
||||
|
||||
o = s.taboption('general', form.Value, 'dialnumber', _('Dial number'));
|
||||
o.placeholder = '*99***1#';
|
||||
|
||||
o = s.taboption('general', form.MultiValue, 'band', _('NB-IoT band'));
|
||||
o.value(1);
|
||||
o.value(3);
|
||||
o.value(5);
|
||||
o.value(8);
|
||||
o.value(20);
|
||||
o.value(28);
|
||||
|
||||
o = s.taboption('advanced', form.Value, 'delay', _('Modem init timeout'), _('Maximum amount of seconds to wait for the modem to become ready'));
|
||||
o.placeholder = '10';
|
||||
o.datatype = 'min(1)';
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user