fixes wifi
This commit is contained in:
parent
14b4892feb
commit
c39f52c54f
25
lib/wifi.js
25
lib/wifi.js
@ -33,8 +33,7 @@ function wifiQualityFromDB(db) {
|
||||
return result <= 100 ? result : 100;
|
||||
}
|
||||
|
||||
function wifiFrequencyFromChannel(channel) {
|
||||
const frequencies = {
|
||||
const _wifi_frequencies = {
|
||||
1: 2412,
|
||||
2: 2417,
|
||||
3: 2422,
|
||||
@ -108,8 +107,20 @@ function wifiFrequencyFromChannel(channel) {
|
||||
189: 4945,
|
||||
192: 4960,
|
||||
196: 4980
|
||||
};
|
||||
return {}.hasOwnProperty.call(frequencies, channel) ? frequencies[channel] : null;
|
||||
};
|
||||
|
||||
function wifiFrequencyFromChannel(channel) {
|
||||
return {}.hasOwnProperty.call(_wifi_frequencies, channel) ? _wifi_frequencies[channel] : null;
|
||||
}
|
||||
|
||||
function wifiChannelFromFrequencs(frequency) {
|
||||
let channel = 0;
|
||||
for (let key in _wifi_frequencies) {
|
||||
if ({}.hasOwnProperty.call(_wifi_frequencies, key)) {
|
||||
if (_wifi_frequencies[key] === frequency) { channel = key; }
|
||||
}
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
function ifaceListLinux() {
|
||||
@ -178,11 +189,13 @@ function wpaConnectionLinux(iface) {
|
||||
const cmd = `wpa_cli -i ${iface} status 2>&1`;
|
||||
try {
|
||||
const lines = execSync(cmd).toString().split('\n');
|
||||
const freq = util.toInt(util.getValue(lines, 'freq', '='));
|
||||
return {
|
||||
ssid: util.getValue(lines, 'ssid', '='),
|
||||
uuid: util.getValue(lines, 'uuid', '='),
|
||||
security: util.getValue(lines, 'key_mgmt', '='),
|
||||
freq: util.getValue(lines, 'freq', '='),
|
||||
freq,
|
||||
channel: wifiChannelFromFrequencs(freq),
|
||||
bssid: util.getValue(lines, 'bssid', '=').toLowerCase()
|
||||
};
|
||||
} catch (e) {
|
||||
@ -481,7 +494,7 @@ function wifiConnections(callback) {
|
||||
const ssid = nmiDetails.ssid || wpaDetails.ssid;
|
||||
const network = networkList.filter(nw => nw.ssid === ssid);
|
||||
const nmiConnection = nmiConnectionLinux(ssid);
|
||||
const channel = network && network.length && network[0].channel ? network[0].channel : null;
|
||||
const channel = network && network.length && network[0].channel ? network[0].channel : (wpaDetails && wpaDetails.channel ? wpaDetails.channel : null);
|
||||
const bssid = network && network.length && network[0].bssid ? network[0].bssid : (wpaDetails && wpaDetails.bssid ? wpaDetails.bssid : null);
|
||||
if (ssid && bssid) {
|
||||
result.push({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user