From f9e9c6c199cc2d448b8fb9f65b0581bf64ac805a Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 18 Feb 2024 08:21:33 +0100 Subject: [PATCH] wifiConnections() added signal quality attribute --- CHANGELOG.md | 1 + README.md | 9 +++++---- docs/history.html | 5 +++++ docs/wifi.html | 20 ++++++++++---------- lib/index.d.ts | 3 ++- lib/wifi.js | 18 ++++++++++++------ 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fd171eb..e645893b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.22.0 | 2024-02-18 | `wifiConnections()` added signal quality attribute | | 5.21.25 | 2024-02-17 | `wifiConnections()` fixed signal strength (windows) | | 5.21.24 | 2024-01-21 | `osInfo()` improved release version parsing (linux) | | 5.21.23 | 2024-01-20 | `cpu()` improved CPU speed parsing (linux) | diff --git a/README.md b/README.md index 372565c6..54b48fe2 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 5.22.0: `wifiConnections()` added signal quality - Version 5.21.0: `graphics()` added subVendor (linux) - Version 5.20.0: `mem()` added writeback and dirty (linux) - Version 5.19.0: `currentLoad()` added steal and guest time (linux) @@ -658,15 +659,15 @@ Full function reference with examples can be found at [https://systeminformation | si.wifiConnections(cb) | [{...}] | X | | X | X | | array of active wifi connections | | | [0].id | X | | X | X | | ID | | | [0].iface | X | | X | X | | interface | -| | [0].name | X | | X | X | | name | -| | [0].mode | X | | X | X | | model | +| | [0].model | X | | X | X | | model | +| | [0].ssid | X | | X | X | | SSID | | | [0].bssid | X | | (X) | X | | BSSID (mac) - macOS only on older os versions | -| | [0].mode | X | | | | | mode | | | [0].channel | X | | X | X | | channel | | | [0].frequency | X | | X | X | | frequency in MHz | +| | [0].type | X | | X | X | | e.g. 802.11 | +| | [0].security | X | | X | X | | array e.g. WPA, WPA-2 | | | [0].signalLevel | X | | X | X | | signal level in dB | | | [0].quality | X | | X | X | | quality in % | -| | [0].security | X | | X | X | | array e.g. WPA, WPA-2 | | | [0].txRate | X | | X | X | | transfer rate MBit/s | #### 15. Bluetooth diff --git a/docs/history.html b/docs/history.html index c951b463..77129c83 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@

Full version history

+ + 5.22.0 + 2024-02-18 + wifiConnections() added quality attribute + 5.21.25 2024-02-17 diff --git a/docs/wifi.html b/docs/wifi.html index 9fc8607e..3c3d8077 100644 --- a/docs/wifi.html +++ b/docs/wifi.html @@ -358,16 +358,6 @@

Wifi Connections

interface - - - [0].name - X - - X - X - - name - [0].model @@ -448,6 +438,16 @@

Wifi Connections

signal level in dB + + + [0].quality + X + + X + X + + signal level quality in % + [0].txRate diff --git a/lib/index.d.ts b/lib/index.d.ts index 2caa6531..72a21c08 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -576,10 +576,11 @@ export namespace Systeminformation { ssid: string; bssid: string; channel: number; + frequency: number; type: string; security: string; - frequency: number; signalLevel: number; + quality: number; txRate: number; } diff --git a/lib/wifi.js b/lib/wifi.js index 5fae47c3..d8c0ca15 100644 --- a/lib/wifi.js +++ b/lib/wifi.js @@ -247,14 +247,15 @@ function getWifiNetworkListNmi() { const security = util.getValue(lines, 'SECURITY').replace('(', '').replace(')', ''); const wpaFlags = util.getValue(lines, 'WPA-FLAGS').replace('(', '').replace(')', ''); const rsnFlags = util.getValue(lines, 'RSN-FLAGS').replace('(', '').replace(')', ''); + const quality = util.getValue(lines, 'SIGNAL'); result.push({ ssid: util.getValue(lines, 'SSID'), bssid: util.getValue(lines, 'BSSID').toLowerCase(), mode: util.getValue(lines, 'MODE'), channel: channel ? parseInt(channel, 10) : null, frequency: frequency ? parseInt(frequency, 10) : null, - signalLevel: wifiDBFromQuality(util.getValue(lines, 'SIGNAL')), - quality: parseFloat(util.getValue(lines, 'SIGNAL')), + signalLevel: wifiDBFromQuality(quality), + quality: quality ? parseInt(quality, 10) : null, security: security && security !== 'none' ? security.split(' ') : [], wpaFlags: wpaFlags && wpaFlags !== 'none' ? wpaFlags.split(' ') : [], rsnFlags: rsnFlags && rsnFlags !== 'none' ? rsnFlags.split(' ') : [] @@ -575,6 +576,7 @@ function wifiConnections(callback) { const nmiConnection = nmiConnectionLinux(ssidSanitized); const channel = network && network.length && network[0].channel ? network[0].channel : (wpaDetails.channel ? wpaDetails.channel : null); const bssid = network && network.length && network[0].bssid ? network[0].bssid : (wpaDetails.bssid ? wpaDetails.bssid : null); + const signalLevel = network && network.length && network[0].signalLevel ? network[0].signalLevel : null; if (ssid && bssid) { result.push({ id: ifaceDetail.id, @@ -586,7 +588,8 @@ function wifiConnections(callback) { frequency: channel ? wifiFrequencyFromChannel(channel) : null, type: nmiConnection.type ? nmiConnection.type : '802.11', security: nmiConnection.security ? nmiConnection.security : (wpaDetails.security ? wpaDetails.security : null), - signalLevel: network && network.length && network[0].signalLevel ? network[0].signalLevel : null, + signalLevel, + quality: wifiQualityFromDB(signalLevel), txRate: null }); } @@ -614,8 +617,8 @@ function wifiConnections(callback) { const channel = util.getValue(lines2, 'channel', ':', true).split(',')[0]; const type = '802.11'; const rssi = util.toInt(util.getValue(lines2, 'agrCtlRSSI', ':', true)); - const noise = util.toInt(util.getValue(lines2, 'agrCtlNoise', ':', true)); - const signalLevel = rssi - noise; + /// const noise = util.toInt(util.getValue(lines2, 'agrCtlNoise', ':', true)); + const signalLevel = rssi; if (ssid || bssid) { result.push({ id: 'Wi-Fi', @@ -628,6 +631,7 @@ function wifiConnections(callback) { type, security, signalLevel, + quality: wifiQualityFromDB(signalLevel), txRate }); } @@ -661,7 +665,8 @@ function wifiConnections(callback) { const id = lines[2].indexOf(':') >= 0 ? lines[2].split(':')[1].trim() : ''; const ssid = util.getValue(lines, 'SSID', ':', true); const bssid = util.getValue(lines, 'BSSID', ':', true); - const signalLevel = wifiDBFromQuality(util.getValue(lines, 'Signal', ':', true)); + const quality = util.getValue(lines, 'Signal', ':', true); + const signalLevel = wifiDBFromQuality(quality); const type = util.getValue(lines, 'Radio type', ':', true) || util.getValue(lines, 'Type de radio', ':', true) || util.getValue(lines, 'Funktyp', ':', true) || null; const security = util.getValue(lines, 'authentication', ':', true) || util.getValue(lines, 'Authentification', ':', true) || util.getValue(lines, 'Authentifizierung', ':', true) || null; const channel = util.getValue(lines, 'Channel', ':', true) || util.getValue(lines, 'Canal', ':', true) || util.getValue(lines, 'Kanal', ':', true) || null; @@ -678,6 +683,7 @@ function wifiConnections(callback) { type, security, signalLevel, + quality: quality ? parseInt(quality, 10) : null, txRate: util.toInt(txRate) || null }); }