Skip to content

Commit

Permalink
fix: attempt to try fix #93
Browse files Browse the repository at this point in the history
  • Loading branch information
elraro committed Jan 4, 2024
1 parent 53056ad commit c0c4211
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ class LinuxWifiConfigurationCapability extends WifiConfigurationCapability {
:-)
*/
const iwOutput = spawnSync("iw", ["dev", this.networkInterface, "link"]).stdout.toString();
const wifiStatus = this.parseIwStdout(iwOutput);
const iwOutput = spawnSync("iw", ["dev", this.networkInterface, "link"]).stdout;
let wifiStatus;
if (iwOutput !== null) {
wifiStatus = this.parseIwStdout(iwOutput.toString());
} else {
wifiStatus = this.parseIwStdout("");
}

//IPs are not part of the iw output
if (wifiStatus.state === ValetudoWifiStatus.STATE.CONNECTED) {
Expand All @@ -46,14 +51,17 @@ class LinuxWifiConfigurationCapability extends WifiConfigurationCapability {
});
}

// @ts-ignore
return wifiStatus;

}

/**
* @param {import("../../../entities/core/ValetudoWifiConfiguration")} wifiConfig
* @returns {Promise<void>}
* @abstract
*/
// @ts-ignore
async setWifiConfiguration(wifiConfig) {
throw new NotImplementedError();
}
Expand All @@ -71,6 +79,7 @@ class LinuxWifiConfigurationCapability extends WifiConfigurationCapability {

const connectedMatch = stdout.match(WIFI_CONNECTED_IW_REGEX);
if (connectedMatch) {
// @ts-ignore
output.state = ValetudoWifiStatus.STATE.CONNECTED;
output.details.bssid = connectedMatch.groups.bssid.trim();

Expand Down Expand Up @@ -108,6 +117,7 @@ class LinuxWifiConfigurationCapability extends WifiConfigurationCapability {

output.details.frequency = ValetudoWifiStatus.FREQUENCY_TYPE.W2_4Ghz;
} else if (stdout.trim().match(WIFI_NOT_CONNECTED_IW_REGEX)) {
// @ts-ignore
output.state = ValetudoWifiStatus.STATE.NOT_CONNECTED;
}

Expand Down

0 comments on commit c0c4211

Please sign in to comment.