friedrith / node-wifi

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

Error when scanning on raspberry or ASUS Tinker Board #40

Closed cedricATBQ closed 5 years ago

cedricATBQ commented 6 years ago

Implementation code: ` wifi.init({ iface: 'wlan0' });

wifi.scan((error, networks) => { if (error) { console.log(error); } else { console.log(networks); } } ` It raises an exception : Cannot read property 'replace' of undefined at .../node_modules/node-wifi/src/linux-scan.js:23:29. Line which caused the error: ssid: fields[1].replace(/\&\&/g, ':')

On some device like raspberry (raspbian) or ASUS Tinker Board (TinkerOS based on debian) we experienced issues because the 'list wifi' command with nmcli return the interface with the result of the scan like: $ nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list ifname wlan0 wlan0 yes:NETWORK_1:D4\:6E\:0E\:8E\:66\:EC:Infra:3:2422 MHz:78:WPA2:(none):pair_ccmp group_ccmp psk no:NETWORK_2:DA\:0F\:99\:70\:C4\:C2:Infra:6:2437 MHz:77:WPA2:(none):pair_ccmp group_ccmp psk no:NETWORK_3:40\:C7\:29\:D1\:BC\:A0:Infra:11:2462 MHz:50:WPA1 WPA2:pair_tkip pair_ccmp group_tkip psk:pair_tkip pair_ccmp group_tkip psk no:NETWORK_4\:C7\:29\:D5\:03\:08:Infra:1:2412 MHz:47:WPA1 WPA2:pair_tkip pair_ccmp group_tkip psk:pair_tkip pair_ccmp group_tkip psk

Testing fields length will do the job.

friedrith commented 5 years ago

I plan to improve the robustness of this library and in order to achieve this challenge, could you upload a stdout of nmcli ?

My goal is to have a example of stdout of each kind of hardware to add unit tests to be sure parser are more robusts.

cedricATBQ commented 5 years ago

Of course. I'll do it when I can and post it here.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.