mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			100 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| '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(/^mbim-.+$/);
 | |
| 
 | |
| return network.registerProtocol('mbim', {
 | |
| 	getI18n: function() {
 | |
| 		return _('MBIM Cellular');
 | |
| 	},
 | |
| 
 | |
| 	getIfname: function() {
 | |
| 		return this._ubus('l3_device') || 'mbim-%s'.format(this.sid);
 | |
| 	},
 | |
| 
 | |
| 	getOpkgPackage: function() {
 | |
| 		return 'umbim';
 | |
| 	},
 | |
| 
 | |
| 	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.Value, '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');
 | |
| 		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;
 | |
| 
 | |
| 		if (L.hasSystemFeature('ipv6')) {
 | |
| 			o = s.taboption('advanced', form.Flag, 'ipv6', _('Enable IPv6 negotiation'));
 | |
| 			o.default = o.disabled;
 | |
| 		}
 | |
| 
 | |
| 		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)';
 | |
| 
 | |
| 		o = s.taboption('general', form.ListValue, 'pdptype', _('PDP Type'));
 | |
| 		o.value('ipv4v6', 'IPv4/IPv6');
 | |
| 		o.value('ipv4', 'IPv4');
 | |
| 		o.value('ipv6', 'IPv6');
 | |
| 		o.default = 'ipv4v6';
 | |
| 	}
 | |
| });
 |