I want to connect to a Wi-Fi network using Python on OS X (10.11). Based on CWInterface reference I figured out there is a iface.associateToNetwork_password_error_()
method available, however when called it does not connect to the network nor it does cause any exception.
At the same time iface.disassociate()
works correctly and disconnects WiFi.
This is the code I tried:
import objc
objc.loadBundle('CoreWLAN',
bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
module_globals=globals())
iface = CWInterface.interface()
iface.associateToNetwork_password_error_(SSID, PASSWORD, None)
How can I connect to a specified network from Python on OS X and make sure the connection has been established?
SSID
? It looks to me like that method takes aCWNetwork
as its first parameter, but as far as I can tell you don't have an instance of one to give to it. – Rachealrachel