friedrith / node-wifi

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

Not working on Raspberry pi linux OS #3

Closed DaniyalGeek closed 5 years ago

DaniyalGeek commented 7 years ago

only showing empty array

friedrith commented 7 years ago

Yes, after trying to resolve issue #2, I have noticed this bug. It seems to come from nmcli on raspbian. I don't know if it is a misconfiguration of wifi on rapsbian or a bug of nmcli on raspbian. I am investigating. If you have any idea how to use nmcli for scan on raspbian, do not hesitate to give your solution here.

paul-em commented 7 years ago

why was this issue closed? was a solution found? i still have the issue... :/

friedrith commented 7 years ago

@DaniyalGeek closed this issus himself. Don't know why too. This issue still remains. I don't know how to use nmcli on raspbian on raspberry pi. I already lost more than one day to try to understand why, without results. Unfortunately, Raspberry pi is not a priority (this project is managed by my company). But if you find a solution, do not hesitate to pull request, I will be happy to integrate it.

Which version of the raspberry pi do you use ? version 3 or an other one with dongle ?

michael-palmes commented 7 years ago

Just got node-wifi up and running on a Raspberry Pi 3 (Raspbian Jessie) and an Odroid XU4 (DietPi) . Below are the steps I followed if it helps:

Your node app using node-wifi should now work correctly.

friedrith commented 7 years ago

I have just tried on raspbian and it's working very well. Thx. So node-wifi works officially on raspbian. Except that I have to use the last command with as root. However I don't want that node-wifi users run their scripts as root because it is too dangereous. Do you know how to setup nmcli to make it working as standard user ?

openedhardware commented 7 years ago

@michael-palmes If I comment out any wlan interfaces, the PIXEL wifi interface on the top-right corner does not work. Any idea?

(That needs wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf in /etc/network/interface file)

friedrith commented 7 years ago

Commenting the interfaces in the config file make them not managed anymore by network manager so it is normal (even if it is really confusing). Since most of raspberry pi uses are without user interfaces, it is not really a problem. Moreover when I install a user interface on my linux (gnome, etc...) the setup proposed by @michael-palmes seems to be not necessary.

mmeendez8 commented 6 years ago

Have you found any solution to avoid the root use ?

friedrith commented 6 years ago

Unfortunately no, I think it is related to a a sudo configuration. node-wifi seems not to be the problem. Some users have experienced the same bug on standard linux distributions.

jarrodbell commented 6 years ago

Any solution for this issue requiring root?

jarrodbell commented 6 years ago

sudo chmod u+s,a-w /usr/bin/nmcli This is working for my needs.

Taken from here: https://unix.stackexchange.com/questions/364250/run-select-shell-commands-as-root-without-giving-the-user-sudo-permisions

friedrith commented 6 years ago

Ok thanks I will put this in the readme because it is very easy to apply. However, I think it would be safer to user sudoer file maybe.

zimbora commented 5 years ago

After doing something similar to what was discussed here, I noticed that when using "config.iface" parameter the first line returned from the exec command was the own parameter and it was leading to a crash in 'for' loop because fields var will only have one position and the next code, consequently fails:

  ssid: fields[1].replace(/\&\&/g, ':'),
  bssid: fields[2].replace(/\&\&/g, ':'),
  mac: fields[2].replace(/\&\&/g, ':'), // for retrocompatibility with version 1.x
  mode: fields[3].replace(/\&\&/g, ':'),
  channel: parseInt(fields[4].replace(/\&\&/g, ':')),
  frequency: parseInt(fields[5].replace(/\&\&/g, ':')),
  //signal_level: networkUtils.dBFromQuality(fields[6].replace(/\&\&/g, ':')),
  security: fields[7].replace(/\&\&/g, ':') != '(none)' ? fields[7].replace(/\&\&/g, ':') : 'none',
  security_flags: {
    wpa:  fields[8].replace(/\&\&/g, ':'),
    rsn: fields[9].replace(/\&\&/g, ':'),
  }

This is very simple to solve. I solve that by changing the line: if (lines[i] != '') { to if (lines[i] != '' && lines[i].includes(":")) {

I am using this lib in several platforms with success but raspbian took me 2 hours to set up nmcli and figure out this issue. If you could commit it I would appreciate :)

My comment refers to file: linux-scan.js line: 25 and intends to fix a bug for raspbian os

filipppp commented 5 years ago

@zimbora changed the src/linux_scan.js file with your if, still doesn't work

zimbora commented 5 years ago

@filipppp what isn't working? I have some devices connected to my server for a few days or weeks without loosing connection.

filipppp commented 5 years ago

@zimbora I don't use the script to connect to a WIFI Network, i use it for getting the network signal strength. I use the .getCurrentConnections() method, but it always returns an empty array. This error only appears at our raspberry pi, my linux machine and windows machine work fine with it.

I'm using iwget command to get the strength

zimbora commented 5 years ago

I will implement a function with this method for raspy and see what happens. Then I give you a feedback. My previous post only fix scanWifi function

zimbora commented 5 years ago

@filipppp I allready implemented a function calling getCurrentConnections method and it is working well. I am reading rssi through it. If you explain your error maybe I could hep you

filipppp commented 5 years ago

@filipppp What do you mean you implemented a function? i use the .getCurrentConnections() function from the Project itself.

Btw there is no error the currenConnections Parameter is just empty.

drewcovi commented 5 years ago

@filipppp @zimbora @friedrith the struggle is real. got this up and running on balena, and if you provide the iface option, you do indeed get that name concatenated to the list of results (broken by \n)

I've added a pull request to put this behind us.

drewcovi commented 5 years ago

@friedrith can we get this pulled?

https://github.com/friedrith/node-wifi/pull/66

tiznull commented 4 years ago

@michael-palmes - Thank you for your notes! This helped me a lot. I had to do a few more things to get it to work properly on RASPBIAN version "STRETCH". I just had to disable DHCP and also install network-manager-gnome. It is important to note that the device will lose internet connection after you make this change. This will be fixed once you add a new connection using node-wifi or the built-in "wifi" cli or nmcli. If you scripted your app properly then this is not an issue and you should be able to add the first connection under the design.

#> sudo apt-get install network-manager network-manager-gnome
#> sudo nano /etc/dhcpcd.conf
    # This disables DHCP on the WLAN interface
    denyinterfaces wlan0
#> sudo nano /etc/NetworkManager/NetworkManager.conf
    # Change "managed=false" to "managed=true"
#> reboot
friedrith commented 3 years ago

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