node-wifi icon indicating copy to clipboard operation
node-wifi copied to clipboard

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

Open mrdulin opened this issue 5 years ago • 1 comments

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

  • [x] node API
  • [ ] cli

Context

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

Your Environment

  • OS: macOS 10.15.7 (19H524)
  • node-wifi version: "node-wifi": "^2.0.14",
  • wifi card: Don't know

mrdulin avatar Mar 30 '21 10:03 mrdulin

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

juanmartin avatar Dec 29 '21 23:12 juanmartin