friedrith / node-wifi

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

Added the missing Mac disconnect functionality #99

Open xavier7179 opened 4 years ago

xavier7179 commented 4 years ago

Description

I added a disconnect function by using CLI functions that do not require to be root. Those functions turn off the wifi first and, after an optional delay, turn it on again. Since disconnecting from a network or a device properly may require a delay, I included a sleep function to do it without generating a Promise, like a setTimeout would do.

Motivation and Context

On Mac the disconnect was a missed functionality.

Usage examples

const WiFiControl = require('node-wifi');

WiFiControl.init({ iface: null, debug: true, delay: 5 // delay in seconds }); //.... WiFiControll.disconnect();

How Has This Been Tested?

I tested it on OSX version 10.14.6.

Types of changes

Fokir commented 4 years ago

These edits do not lead to the desired result, since after turning off and on the wifi module there will be an automatic connection to the priority access point

MacOs Catalina 10.15.5

xavier7179 commented 4 years ago

MacOs Catalina 10.15.5 when I released it, there was no version 10.15.5, and there was no automatic re-connection on my version. Nevertheless, I hope it is a start make it better and fully working, because otherwise on mac without this functionality, in a real application, the lib is almost worthless.