Skip to content

Commit

Permalink
wifiConnections() added signal quality attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Feb 18, 2024
1 parent f913530 commit f9e9c6c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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) |
Expand Down
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Expand Up @@ -57,6 +57,11 @@ <h3>Full version history</h3>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.22.0</th>
<td>2024-02-18</td>
<td><span class="code">wifiConnections()</span> added quality attribute</td>
</tr>
<tr>
<th scope="row">5.21.25</th>
<td>2024-02-17</td>
Expand Down
20 changes: 10 additions & 10 deletions docs/wifi.html
Expand Up @@ -358,16 +358,6 @@ <h2>Wifi Connections</h2>
<td></td>
<td>interface</td>
</tr>
<tr>
<td></td>
<td>[0].name</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>name</td>
</tr>
<tr>
<td></td>
<td>[0].model</td>
Expand Down Expand Up @@ -448,6 +438,16 @@ <h2>Wifi Connections</h2>
<td></td>
<td>signal level in dB</td>
</tr>
<tr>
<td></td>
<td>[0].quality</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>signal level quality in %</td>
</tr>
<tr>
<td></td>
<td>[0].txRate</td>
Expand Down
3 changes: 2 additions & 1 deletion lib/index.d.ts
Expand Up @@ -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;
}

Expand Down
18 changes: 12 additions & 6 deletions lib/wifi.js
Expand Up @@ -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(' ') : []
Expand Down Expand Up @@ -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,
Expand All @@ -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
});
}
Expand Down Expand Up @@ -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',
Expand All @@ -628,6 +631,7 @@ function wifiConnections(callback) {
type,
security,
signalLevel,
quality: wifiQualityFromDB(signalLevel),
txRate
});
}
Expand Down Expand Up @@ -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;
Expand All @@ -678,6 +683,7 @@ function wifiConnections(callback) {
type,
security,
signalLevel,
quality: quality ? parseInt(quality, 10) : null,
txRate: util.toInt(txRate) || null
});
}
Expand Down

0 comments on commit f9e9c6c

Please sign in to comment.