friedrith / node-wifi

📶 NodeJS tool to manage wifi (connections, scans)
MIT License
398 stars 161 forks source link

Is there a `.isConnected()` method to check if the target wifi is connected or not? #151

Open mrdulin opened 3 years ago

mrdulin commented 3 years ago

Expected Behavior

Is there a .isConnected() method to check if the target wifi is connected or not?

Current Behavior

I am trying to use wifi.scan() method to get the information of the networks.

// disconnected
{
  mac: 'd4:c8:b0:06:a1:71',
  bssid: 'd4:c8:b0:06:a1:71',
  ssid: 'ZA-Office',
  channel: 36,
  frequency: 5180,
  signal_level: '-69',
  quality: 62,
  security: '',
  security_flags: []
},
// connected
{
  mac: '44:6a:2e:10:44:31',
  bssid: '44:6a:2e:10:44:31',
  ssid: 'ZA-Office',
  channel: 36,
  frequency: 5180,
  signal_level: '-92',
  quality: 16,
  security: '',
  security_flags: []
}

There is no field to indicate whether the network is connected.

Affected features

Context

I want to implement a function that automatically reconnects when wifi is disconnected.

Your Environment

juanmartin commented 2 years ago

You can use .getCurrentConnections() and compare the results to check if you're on the right network.