How to use the node-wifi.init function in node-wifi

To help you get started, we’ve selected a few node-wifi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alvinwan / riot / test / index.js View on Github external
async function demo() {

// Initialize wifi module
// Absolutely necessary even to set interface to null
wifi.init({
    iface : null // network interface, choose a random wifi interface if set to null
});

data = {samples: []}

if (process.argv.length <= 2) {
  n = 1
} else {
  n = process.argv[2]
}

for (var i=0; i < n; i++){
// Scan networks
wifi.scan(function(err, networks) {
    if (err) {
        console.log(err);
github alvinwan / riot / scripts / observe.js View on Github external
async function record(n=1, completion=function(data) {}, hook=function(i, sample) {}) {
  console.log(" * [INFO] Starting to listen")
  wifi.init({
      iface : null // network interface, choose a random wifi interface if set to null
  });

  samples = []
  function startScan(i) {
    var date1 = new Date();
    wifi.scan(function(err, networks) {
        if (err || networks.length == 0) {
          console.log(" * [ERR] Failed to collect " + i + ". Waiting for a second before retrying... (" + err + ")")
          utils.sleep(1000)
          startScan(i);
          return
        }
        console.log(" * [INFO] Collected sample " + i + " with " + networks.length + " networks in " + ( (new Date() - date1) / 1000 ) + "s")
        samples.push(networks)
        hook(i, networks);
github alvinwan / riot / tutorial / observe-step2.js View on Github external
function record(n, completion, hook) {
  wifi.init({
      iface : null // network interface, choose a random wifi interface if set to null
  });

  samples = []
  function startScan(i) {
    wifi.scan(function(err, networks) {
        if (err || networks.length == 0) {
          startScan(i);
          return
        }
        if (i <= 0) {
          return completion({samples: samples});
        }
        hook(i, networks)
        samples.push(networks)
        startScan(i-1);
github blahsd / snwe / app / js / require / modules / wifi.js View on Github external
constructor(filePath, document) {
    super(filePath, document);
    this.container = 'right';

    this.isOn = false;
    this.isConnected = false;
    this.isConnecting = true;
    this.network = false;

    wifi.init({
      iface: null // network interface, choose a random wifi interface if set to null
    });

  }