node-wifi
node-wifi copied to clipboard
Is there a `.isConnected()` method to check if the target wifi is connected or not?
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
You can use .getCurrentConnections() and compare the results to check if you're on the right network.