awkman / pywifi

A cross-platform module for manipulating WiFi devices.
MIT License
447 stars 154 forks source link

iface.connect(profile) always return const.IFACE_DISCONNECTED win10 python3 #22

Closed WuQio closed 5 years ago

WuQio commented 6 years ago

iface.connect(profile) always return const.IFACE_DISCONNECTED. I use Python3, win10. It cannot connect to my AP even if the key is write.

` from pywifi import * import time

def main(): wifi = PyWiFi() iface = wifi.interfaces()[0] iface.scan() time.sleep(1) scanres = iface.scan_results()

profile = Profile()

for s in scanres:
    if s.ssid == 'meilan':
        profile.ssid = s.ssid
        profile.auth = s.auth
        profile.akm.append(s.akm[0])
        profile.cipher = s.cipher
        break
key = 'abcdefgg'
profile.key = key
profile = iface.add_network_profile(profile)
iface.remove_all_network_profiles()
iface.connect(profile)
time.sleep(30)
print(iface.status())

main() `

awkman commented 6 years ago

@WuQio Remove the line "iface.remove_all_network_profiles()" to try whether your code could work properly