diff options
Diffstat (limited to 'protocols/luci-proto-ncm/htdocs')
-rw-r--r-- | protocols/luci-proto-ncm/htdocs/luci-static/resources/protocol/ncm.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/protocols/luci-proto-ncm/htdocs/luci-static/resources/protocol/ncm.js b/protocols/luci-proto-ncm/htdocs/luci-static/resources/protocol/ncm.js index ba673b4a0..3ab6c01d6 100644 --- a/protocols/luci-proto-ncm/htdocs/luci-static/resources/protocol/ncm.js +++ b/protocols/luci-proto-ncm/htdocs/luci-static/resources/protocol/ncm.js @@ -3,11 +3,18 @@ 'require form'; 'require network'; -var callTTYDevices = rpc.declare({ - object: 'luci', - method: 'getTTYDevices', - params: [ 'with_cdc', 'with_tts' ], - expect: { result: [] } +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(/^ttyUSB/) || list[i].name.match(/^cdc-wdm/)) + rv.push(params.path + list[i].name); + return rv.sort(); + } }); network.registerPatternVirtual(/^ncm-.+$/); @@ -54,12 +61,9 @@ return network.registerProtocol('ncm', { o = s.taboption('general', form.Value, 'device', _('Modem device')); o.rmempty = false; o.load = function(section_id) { - return callTTYDevices(true, false).then(L.bind(function(devices) { - if (Array.isArray(devices)) - for (var i = 0; i < devices.length; i++) - if (/(ttyUSB|cdc-wdm)/.test(devices[i])) - this.value(devices[i]); - + 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)); }; |