2 listDeviceNames: L.rpc.declare({
5 expect: { 'devices': [ ] },
6 filter: function(data) {
12 getPhyName: L.rpc.declare({
15 params: [ 'section' ],
16 expect: { 'phyname': '' }
19 getDeviceStatus: L.rpc.declare({
24 filter: function(data, params) {
25 if (!$.isEmptyObject(data))
27 data['device'] = params['device'];
34 getAssocList: L.rpc.declare({
38 expect: { results: [ ] },
39 filter: function(data, params) {
40 for (var i = 0; i < data.length; i++)
41 data[i]['device'] = params['device'];
43 data.sort(function(a, b) {
44 if (a.bssid < b.bssid)
46 else if (a.bssid > b.bssid)
56 getWirelessStatus: function() {
57 return this.listDeviceNames().then(function(names) {
60 for (var i = 0; i < names.length; i++)
61 L.wireless.getDeviceStatus(names[i]);
64 }).then(function(networks) {
68 'country', 'channel', 'frequency', 'frequency_offset',
69 'txpower', 'txpower_offset', 'hwmodes', 'hardware', 'phy'
73 'ssid', 'bssid', 'mode', 'quality', 'quality_max',
74 'signal', 'noise', 'bitrate', 'encryption'
77 for (var i = 0; i < networks.length; i++)
79 var phy = rv[networks[i].phy] || (
80 rv[networks[i].phy] = { networks: [ ] }
84 device: networks[i].device
87 for (var j = 0; j < phy_attrs.length; j++)
88 phy[phy_attrs[j]] = networks[i][phy_attrs[j]];
90 for (var j = 0; j < net_attrs.length; j++)
91 net[net_attrs[j]] = networks[i][net_attrs[j]];
93 phy.networks.push(net);
100 getAssocLists: function()
102 return this.listDeviceNames().then(function(names) {
105 for (var i = 0; i < names.length; i++)
106 L.wireless.getAssocList(names[i]);
108 return L.rpc.flush();
109 }).then(function(assoclists) {
112 for (var i = 0; i < assoclists.length; i++)
113 for (var j = 0; j < assoclists[i].length; j++)
114 rv.push(assoclists[i][j]);
120 formatEncryption: function(enc)
122 var format_list = function(l, s)
125 for (var i = 0; i < l.length; i++)
126 rv.push(l[i].toUpperCase());
127 return rv.join(s ? s : ', ');
130 if (!enc || !enc.enabled)
135 if (enc.wep.length == 2)
136 return L.tr('WEP Open/Shared') + ' (%s)'.format(format_list(enc.ciphers, ', '));
137 else if (enc.wep[0] == 'shared')
138 return L.tr('WEP Shared Auth') + ' (%s)'.format(format_list(enc.ciphers, ', '));
140 return L.tr('WEP Open System') + ' (%s)'.format(format_list(enc.ciphers, ', '));
144 if (enc.wpa.length == 2)
145 return L.tr('mixed WPA/WPA2') + ' %s (%s)'.format(
146 format_list(enc.authentication, '/'),
147 format_list(enc.ciphers, ', ')
149 else if (enc.wpa[0] == 2)
150 return 'WPA2 %s (%s)'.format(
151 format_list(enc.authentication, '/'),
152 format_list(enc.ciphers, ', ')
155 return 'WPA %s (%s)'.format(
156 format_list(enc.authentication, '/'),
157 format_list(enc.ciphers, ', ')
161 return L.tr('Unknown');