summaryrefslogtreecommitdiffhomepage
path: root/protocols/luci-proto-modemmanager/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorNicholas Smith <nicholas.smith@telcoantennas.com.au>2019-10-09 09:51:20 +1000
committerNicholas Smith <nicholas.smith@telcoantennas.com.au>2019-10-11 08:27:02 +1000
commit6a79c61221132f170b8cfec7d01010f39bfe8a1e (patch)
tree0a1972d2087a133b622cfedec524f6f0d56c8942 /protocols/luci-proto-modemmanager/htdocs/luci-static/resources
parenta1545331219ed608eb6625ce5d38fa216f5bfdc8 (diff)
luci-proto-modemmanager: add luci-proto-modemmanager
Signed-off-by: Nicholas Smith <nicholas.smith@telcoantennas.com.au>
Diffstat (limited to 'protocols/luci-proto-modemmanager/htdocs/luci-static/resources')
-rw-r--r--protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js b/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js
new file mode 100644
index 0000000000..ae68bfd8f4
--- /dev/null
+++ b/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js
@@ -0,0 +1,101 @@
+'use strict';
+'require rpc';
+'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(/^cdc-wdm/))
+ rv.push(params.path + list[i].name);
+ return rv.sort();
+ }
+});
+
+network.registerPatternVirtual(/^mobiledata-.+$/);
+network.registerErrorCode('CALL_FAILED', _('Call failed'));
+network.registerErrorCode('NO_CID', _('Unable to obtain client ID'));
+network.registerErrorCode('PLMN_FAILED', _('Setting PLMN failed'));
+
+return network.registerProtocol('modemmanager', {
+ getI18n: function() {
+ return _('ModemManager');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'modemmanager-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'modemmanager';
+ },
+
+ 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 dev = this.getL3Device() || this.getDevice(), o;
+
+ o = s.taboption('general', form.ListValue, 'device', _('Modem 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 form.Value.prototype.load.apply(this, [section_id]);
+ }, this));
+ };
+
+ s.taboption('general', form.Value, 'apn', _('APN'));
+ s.taboption('general', form.Value, 'pincode', _('PIN'));
+
+ o = s.taboption('general', form.ListValue, 'auth', _('Authentication Type'));
+ o.value('both', 'PAP/CHAP (both)');
+ 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.ListValue, 'iptype', _('IP Type'));
+ o.value('ipv4v6', 'IPv4 IPv6 (both - defaults to IPv4)')
+ o.value('ipv4', 'IPv4 only');
+ o.value('ipv6', 'IPv6 only');
+ o.default = 'ipv4v6';
+
+ o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
+ o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
+ o.datatype = 'max(9200)';
+
+ s.taboption('general', form.Value, 'metric', _('Gateway metric'));
+
+ }
+});