7141 questions

8568 answers


10608 members

+1 vote
1,305 views 5 comments
Hello, I need to connect my RUT240 to a Wi-Fi network by using the JSON-RPC monitoring. In order to do that, my Rasberry get the list of available wifi networks and post a JSON to set the SSID, key(entered by the user through the rasberry's screen) and encyption. It works pretty well but I'm not able to know if the wifi is really connected. I need to know it in case of a wrong key is entered...Thank you in advance for you help!

1 Answer

0 votes


You can use the iwinfo command for information on WiFi Stations/Access Points. Execute iwinfo --help for usage syntax and available options.

Best answer

Thanks you for your answer! I've tried to connect to a wifi network with a wrong password and when I send "iwinfo wlan0 info" I don't always get the same informations... Sometimes it replies with the Access Points data, sometimes with "Unknown" and sometimes with the network's informations to which I try to connect... It's difficult to know the real status... frown


The reason this happens is because when you specify the incorrect password, the Station (STA) keeps trying to connect to the Access Point (AP). The WiFi interface name is called wlan0 and by default it is used by the router's AP. When the router is also in STA mode, the AP's interface name changes to wlan0-1.

So when nothing is happening (sleep between connections) and you use "iwinfo wlan0 info" it will show the router's AP info; when the router is connecting to another AP, it will show "Unknown"; when the router is connected to the AP but not authenticated, it will show the other AP's info.

So yeah, it is difficult this way.

What commands are you using to connect to an AP from the router? Are you using wpa_supplicant or some custom script? If you're using wpa_supplicant, you should get the relevant output if the password is wrong:

wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="some_ap" auth_failures=1 duration=10 reason=WRONG_KEY

Ok yes that's what I thought too...  I working under a Windows Iot core...Not sure I can use wpa_supplicant... To connect the router I just set the Ssid, the key and the Encryption methode through a uci set command then I commit and execute a "luci-reload".
Maybe you could do other checks, like, for example, checking whether the WiFi interface gets an IP address or checking if ping requests are sent successfully?

Not quite as specific as getting a "good/bad password" indication, but you will at least know whether the connection was successful or not.
Yes check the IP address sounds like a good idea! Otherwise I was thinking about checking the password by using the Raspberry Wi-Fi.

Thank you for your help and have a good day!