5

Environment

  • Linux Ubuntu
  • node.js v0.6.12

Goal

I'd like to be able to get the list of APs available / network names (SSIDs)

I may want to select a specific SSID.

My ultimate goal is to be able to check on wifi signal strength and quality in order to force re-association to another AP before it loses completely connectivity.

How do create a loop that retrieves and updates the list of surrounding APs using node.js?

Would node.js a good choice to accomplish this?

How do I get information from an AP i.e. signal strength and quality?

zabumba
  • 12,172
  • 16
  • 72
  • 129
  • Node does not have APIs for this type of information directly. You will need to execute linux native tools as child processes and parse their output and/or get information from the `/sys` filesystem. You will probably have better luck just researching that directly. You are not quite ready to start coding or ask for node help at this point. – Peter Lyons Oct 02 '14 at 15:11
  • Yes I suppose I should modify my question to ask how to use the "native" linux tools from `node.js` and what are the best tools. I am guessing I could use `wpa_supplicant` but how do I call `wpa_cli` from `node.js` and keep it in a loop to keep an updated list? – zabumba Oct 03 '14 at 13:27
  • Use the `child_process` module to run native commands. You can use `setInterval` to run code periodically. Repost after you have some code. SO frowns upon this type of question with no attempt at any code posted. – Peter Lyons Oct 03 '14 at 19:41
  • 2
    Peter don't be annoyed. Helping with a patronizing note is quite lame actually. I am just trying to get started with `node.js`. We can't all be good at everything, sometimes trying the right piece of doc to educate yourself can be a difficult. How many times have I read 30 pages of doc to no avail? So please spare the community of such patronizing notes. – zabumba Oct 03 '14 at 22:13

1 Answers1

4

You can use the wireless-tools package.

Usage:

var iwlist = require('wireless-tools/iwlist');

iwlist.scan('wlan0', function(err, networks) {
  console.log(networks);
});

// => 
[
  {
    address: '00:0b:81:ab:14:22',
    ssid: 'BlueberryPi',
    mode: 'master',
    frequency: 2.437,
    channel: 6,
    security: 'wpa',
    quality: 48,
    signal: 87
  },
  // ...
Ricardo Stuven
  • 4,704
  • 2
  • 34
  • 36