Skip to content
This repository has been archived by the owner on Aug 11, 2019. It is now read-only.

Commit

Permalink
check wifi signal
Browse files Browse the repository at this point in the history
Made this in response to treehouses/control#6
  • Loading branch information
TerrenceEJ committed May 16, 2018
1 parent 58b6085 commit 5a5153d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ var commands = [{
command: 'wificountry <country>',
description: 'changes the wifi country',
action: './lib/wificountry.js'
},
{
command: 'checksignal',
description:"checks the RSSI of the RPi's wifi connection",
action: './lib/checksignal.js'
}
]

Expand Down
26 changes: 26 additions & 0 deletions lib/checksignal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

var exec = require('child_process').exec;

module.exports = () => {
var command = "iwconfig wlan0";

exec(command, (error, stdout, stderr) => {
if (error) {
console.log('There has been an error running this command: ' + error);
}
if (stderr) {
process.stdout.write(stderr)
process.exit(1)
}
var change = stdout.split("\n");
var SSID = change[0];
var index = SSID.indexOf("ESSID");
SSID = SSID.slice(index);

var signal = change[6];
index = signal.indexOf("Signal");
signal = signal.slice(index);
console.log(SSID + signal);
})
}

0 comments on commit 5a5153d

Please sign in to comment.