Find out if wlan0 device is busy

1.3k views Asked by At

I'm working on a Java project for the raspberry pi that requires some networking functionality. For this I use nmcli through a Process. However, I noticed that when trying to create a new connection (with a wrong password) sometimes the error message would be:

Error: No  network with SSID <nameofSSID> found.

I tracked this down to the fact that if you call:

sudo iwlist wlan0 scanning 

Shortly after trying to create a connection it will return:

wlan0     Interface doesn't support scanning : Device or resource busy

To solve this I figured I could just check if the device was busy before creating a new connection, however I have not been able to find the appropriate command.

1

There are 1 answers

0
Tigris On

The closest I could come was:

nmcli -t -g GENERAL.STATE dev show wlan0

Sadly this is a mix of a number and text, but still requires minimal processing.