friedrith / node-wifi

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

Support hidden wifi on windows #183

Open maxhellwig opened 1 year ago

maxhellwig commented 1 year ago

Description

This PR add support for hidden wifis, wifis which do not broadcast there SSID, without breaking existing API usages.

Motivation and Context

Windows does not simply connect to wifis which do not broadcast their SSID (hidden wifis). The additional flag <nonBroadcast>true</nonBroadcast> in the profile xml file is required.

If the flag is set, this PR adds the nonBroadcast param to the profile xml config file and connects to the wifi. It also skips the scan for the given wifi because it will not appear in the wifi list, obviously.

This PR is related and should close #22 on Windows.

The missing configuration has been posted on Stackoverflow in this thread: https://stackoverflow.com/questions/69470100/connect-to-hidden-wifi-using-netsh-commands

Usage examples

Users can now provide an additional parameter to the connect() method:

nodeWifi.connect({ssid: 'foo', password: 'bar', isHidden?: true})

the default of isHidden is false so that existing code should not break.

How Has This Been Tested?

The code has been tested on Windows 10 with a Wifi without SSID.

Types of changes