awkman / pywifi

A cross-platform module for manipulating WiFi devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I use this module in Rasspberry Pi

JintaoSun opened this issue · comments

I can use this module to establish a wifi connection in Windows, my code is as follows:
wifi=PyWiFi()
ifaces=wifi.interfaces()[0]
print(ifaces.name())
print(const.IFACE_CONNECTED)
print(const.IFACE_INACTIVE)

profile = pywifi.Profile()
profile.ssid = ""
profile.auth = const.AUTH_ALG_OPEN
profile.akm.append(const.AKM_TYPE_WPA2PSK)
profile.cipher = const.CIPHER_TYPE_CCMP
profile.key = "
**"

tmp_profile = ifaces.add_network_profile(profile)
ifaces.connect(tmp_profile)
time.sleep(5)

if ifaces.status() == const.IFACE_CONNECTED:
print("OK")
else:
print("ERROR")`
Now I wann make a wifi connection on Raspberry pi,using this code not succeed.
The "Prerequisites" : "On Linux, you will need to run wpa_supplicant to manipulate the wifi devices, and then pywifi can communicate with wpa_supplicant through socket." I think I should start here, but I don't know how to do it in particular. could you give me some advice? Thanks

I use this module on Raspberry pi and it do not succeed either. However it works on Windows.

Having the same issue. The iface.status() is always 0, but I am sure it already connected to the Network.

Having the same issue~ Anyone can fix it?