awkman / pywifi

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

iface.connect(profile) = no effect -_- #45

Open RealSniperKing opened 5 years ago

RealSniperKing commented 5 years ago

Why 'iface.status()' return always a null value ? I try simply establish a connection with created profile

My OS : Windows 10 My python : 3.6.2

What is there a solution for this bug ?

My code :

from pywifi import *
import time

wifi = PyWiFi()
iface = wifi.interfaces()[0]

iface.scan()
scan_results = []

iface.disconnect()

if len(scan_results) == 0:
    print("Wait 3 secondes")
    time.sleep(3)
    scan_results = iface.scan_results()

if len(scan_results) != 0:
    print(scan_results)

    for r_wifi in scan_results:
        #print(r_wifi.ssid)

        if r_wifi.ssid == 'toto':
            print("> toto : " + str(r_wifi.ssid))
            profile = Profile()
            profile.ssid = r_wifi.ssid
            profile.auth = r_wifi.auth
            profile.akm.append(r_wifi.akm[0])
            profile.cipher = r_wifi.cipher

            key = 'mpkihy947'
            profile.key = key

            tmp_profile = iface.add_network_profile(profile)
            iface.connect(tmp_profile)
            time.sleep(10)
            print("STATUT")
            print(iface.status())
AhmedHeshams commented 5 years ago

i have the same problem iface.connect(profile) isn't the issue , the issue in save profile it never save , try to connect to a saved profile network, it'll connect normally without any problems