Open fooness opened 5 years ago
Could you execute this command and show me result
LANG=C nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list
LANG=C nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list
executes, but returns nothing.
I suppose you need to configure the operation system. Try to read here:
https://unix.stackexchange.com/questions/334477/nmcli-shows-nothing https://unix.stackexchange.com/questions/158328/network-manager-not-listing-wifi
I think the problem is that Ubuntu Server 18.04 uses netplan
with nerworkd
for setting up ethernet and wifi interfaces.
For my purposes it would be enough to use nmcli
to only list wifi networks, there’s no need to save the wifi network and passphrase to some file, I only need the bssid of the available networks.
So maybe it’s possible to set up nmcli
to be able to list wifi networks but not to interfere with netplan and networkd?
Or maybe it’s possible to use netplan to scan for wifi networks in php-wifi?
Seems I can relatively easy change netplan
’s renderer from networkd
to NetworkManager
(which uses ncmli
).
Unfortunately though, the nmcli […] list
command in php-wifi does not scan (or rather nmcli […] rescan
the network before creating the array of available wifi networks.
Is it somehow possible to force a rescan before creating the array?
Thank you!
You mean that after renderer was changed from networkd to NetworkManager the nmcli doesn't scan anyway? Why do you need rescan the network in this case?
Scanning works, kind of. But the peridocal scanning of nmcli
is not enough. Imaginge you’d like to get a list of available wifi networks in between of information-of-last-scan-lost and new-scan-didn’t-happen-yet.
In regards of man nmcli
:
wifi list [--rescan | auto | no | yes ] [ifname ifname] [bssid BSSID] ]
List available Wi-Fi access points. The ifname and bssid options can be used to list APs for a particular interface or with a specific BSSID, respectively.
By default, nmcli ensures that the access point list is no older than 30 seconds and triggers a network scan if necessary. The --rescan can be used to either force or disable the scan regardless of how fresh the access point list is.
wifi rescan [ifname ifname] [ssid SSID...]
Request that NetworkManager immediately re-scan for available access points. NetworkManager scans Wi-Fi networks periodically, but in some cases it can be useful to start scanning manually (e.g. after resuming the computer). By using ssid, it is possible to scan for a specific SSID, which is useful for APs with hidden SSIDs. You can provide multiple ssid parameters in order to scan more SSIDs.
So maybe … it would be possible to use nmcli device wifi list --rescan
or nmcli device wifi list --rescan yes
, but unfortunately Ubuntu Server 18.04 does not use this version of nmcli
it seems. The version used is 1.10.6 … here’s the corresponding man page and it’s missing the --rescan
parameter.
Another approach would be executing LANG=C nmcli device wifi rescan && sleep 5 &&
(or something alike) in php-wifi before the LANG=C nmcli […] wifi list
function is executed. But I’m struggling with implementing this.
php-wifi works on my macOS environment (development).
On Ubuntu Server 18.04 LTS (production), though, unfortunately I get an error.
Argument 1 passed to Sanchescom\WiFi\System\AbstractNetworks::explodeAvailableNetworks() must be of the type string, integer given, called in /var/www/html/vendor/sanchescom/php-wifi/src/System/Linux/Networks.php on line 52
In the debugger, the first line (line 65) of the following function from
/var/www/html/vendor/sanchescom/php-wifi/src/System/AbstractNetworks.php
is highligthed:Via SSH, that’s what I get when running
nmcli
:Any ideas what the problem might be?
Thank you very much.