34 lines
766 B
Python
34 lines
766 B
Python
import time
|
|
import pywifi
|
|
from pywifi import const
|
|
|
|
wifi = pywifi.PyWiFi()
|
|
|
|
print(wifi.interfaces)
|
|
|
|
# iface = wifi.interfaces()[0]
|
|
|
|
# iface.disconnect()
|
|
# time.sleep(1)
|
|
# assert iface.status() in\
|
|
# [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
|
|
|
|
# profile = pywifi.Profile()
|
|
# profile.ssid = 'testap'
|
|
# profile.auth = const.AUTH_ALG_OPEN
|
|
# profile.akm.append(const.AKM_TYPE_WPA2PSK)
|
|
# profile.cipher = const.CIPHER_TYPE_CCMP
|
|
# profile.key = '12345678'
|
|
|
|
# iface.remove_all_network_profiles()
|
|
# tmp_profile = iface.add_network_profile(profile)
|
|
|
|
# iface.connect(tmp_profile)
|
|
# time.sleep(30)
|
|
# assert iface.status() == const.IFACE_CONNECTED
|
|
|
|
# iface.disconnect()
|
|
# time.sleep(1)
|
|
# assert iface.status() in\
|
|
# [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
|