Open jimba81 opened 4 years ago
I had to modify little to so the function can finish nicely:
function parseShowInterfaces(stdout) {
...
for (var j = 0; j < fields.length; j++) {
var line = lines[i + j];
//===== MY CHANGE START
// tmpConnection[fields[j]] = line.match(/.*: (.*)/)[1];
const lineMatch = line.match(/.*: (.*)/);
if (lineMatch == null) {
// bad line, skip current interface and move to next one
i += j + 1;
j = -1;
if (i >= lines.length) {
tmpConnection = {};
break;
}
} else {
tmpConnection[fields[j]] = lineMatch[1];
}
//===== MY CHANGE END
...
}
Hi! In my case I'm getting an empty array on Windows. Happens on multiple systems, both W10 and W11. I also tried disabling all other interfaces, but the problem persists. Any ideas on why this could be happening @friedrith ? Thx
Can you try to type the following command in your terminal and print the result here?
netsh wlan show interfaces
Remember to slightly modify the ssid and bssid please.
❯ netsh wlan show interfaces
There is 1 interface on the system:
Name : Wi-Fi
Description : TP-Link Wireless USB Adapter
GUID : 21b1df15-2701-41a0-a09e-47a825cea287
Physical address : 50:3e:aa:e5:98:3c
Interface type : Primary
State : connected
SSID : XXXX-BXA2
BSSID : xx:18:xx:69:xx:a2
Network type : Infrastructure
Radio type : 802.11n
Authentication : Open
Cipher : None
Connection mode : Profile
Band : 2.4 GHz
Channel : 11
Receive rate (Mbps) : 144.4
Transmit rate (Mbps) : 144.4
Signal : 100%
Profile : XXXX-BXA2
Hosted network status : Not available
Ok I will try to propose a fix
I think I figured the problem.
Turns out the computer needs some time to connect and I was checking the currentConnections immediately, thus getting an empty array.
I put the getCurrentConnections()
call inside of a setTimeout()
in the .connect()
callback and voilà!
I am glad you found a workaround. Unfortunately, windows use async commands so you don't know exactly when the job will be finished.
When there are multiple wifi interfaces exist in Windows environment and if the first one is disconnected, the
getCurrentConnections()
returns null.Expected Behavior
The
getCurrentConnections()
should return connected connections from any interfacesCurrent Behavior
When there are multiple wifi interfaces exist in Windows environment and if the first one is disconnected, the
getCurrentConnections()
returns null.Affected features
Possible Solution
I have confirmed working after modified the
windows-current-connections.js
by following:Steps to Reproduce (for bugs)
Context
Your Environment