API Documentation

WpaSupplicantDriver

class wpa_supplicant.core.WpaSupplicantDriver(reactor)

Driver object for starting, stopping and connecting to wpa_supplicant

connect(*args, **kwargs)

Connect to wpa_supplicant over D-Bus

Returns:Remote D-Bus proxy object of the root wpa_supplicant interface
Return type:WpaSupplicant

WpaSupplicant

class wpa_supplicant.core.WpaSupplicant(*args, **kwargs)

Interface implemented by the main wpa_supplicant D-Bus object

Registered in the bus as “fi.w1.wpa_supplicant1”

create_interface(interface_name)

Registers a wireless interface in wpa_supplicant

Returns:

Interface object that implements the wpa_supplicant Interface API

Raises:
  • InterfaceExists – The interface_name specified is already registered
  • UnknownError – An unknown error occurred
get_debug_level()

Global wpa_supplicant debugging level

Returns:Possible values: “msgdump” (verbose debugging) “debug” (debugging) “info” (informative) “warning” (warnings) “error” (errors)
Return type:str
get_debug_showkeys()

Determines if secrets are shown in debug logs

get_debug_timestamp()

Determines if timestamps are shown in debug logs

get_eap_methods()

An array with supported EAP methods names

get_interface(interface_name)

Get D-Bus object related to an interface which wpa_supplicant already controls

Returns:

Interface object that implements the wpa_supplicant Interface API.

Return type:

Interface

Raises:
  • InterfaceUnknown – wpa_supplicant doesn’t know anything about interface_name
  • UnknownError – An unknown error occurred
get_interfaces()

An array with paths to D-Bus objects representing controlled interfaces

remove_interface(interface_path)

Deregisters a wireless interface from wpa_supplicant

Parameters:

interface_path – D-Bus object path to the interface to be removed

Returns:

None

Raises:
  • InterfaceUnknown – wpa_supplicant doesn’t know anything about interface_name
  • UnknownError – An unknown error occurred

Interface

class wpa_supplicant.core.Interface(obj_path, conn, reactor)

Interface implemented by objects related to network interface added to wpa_supplicant

add_network(network_cfg)

Adds a new network to the interface

Parameters:

network_cfg – Dictionary of config, see wpa_supplicant.conf for k/v pairs

Returns:

Network object that was registered w/ wpa_supplicant

Raises:
  • InvalidArgs – Invalid argument format
  • UnknownError – An unknown error occurred
disconnect_network()

Disassociates the interface from current network

Returns:None
Raises NotConnected:
 The interface is not currently connected to a network
get_all_bss()

List of D-Bus objects paths representing BSSs known to the interface

get_ap_scan()

Identical to ap_scan entry in wpa_supplicant configuration file.

Possible values are 0, 1 or 2.

get_bridge_ifname()

Name of bridge network interface controlled by the interface, e.g., br0

get_bss_expire_age()

Identical to bss_expiration_age entry in wpa_supplicant.conf file

get_bss_expire_count()

Identical to bss_expiration_scan_count entry in wpa_supplicant.conf file

get_country()

Identical to country entry in wpa_supplicant.conf

get_current_bss()

BSS object path which wpa_supplicant is associated with

Returns “/” if is not associated at all

get_current_network()

The Network object which wpa_supplicant is associated with

Returns None if is not associated at all

get_driver()

Name of driver used by the interface, e.g., nl80211

get_fast_reauth()

Identical to fast_reauth entry in wpa_supplicant.conf

get_ifname()

Name of network interface controlled by the interface, e.g., wlan0

get_networks()

List of Network objects representing configured networks

get_scan_interval()

Time (in seconds) between scans for a suitable AP. Must be >= 0

get_scanning()

Determines if the interface is already scanning or not

get_state()

A state of the interface.

Possible values are: “disconnected”
“inactive” “scanning” “authenticating” “associating” “associated” “4way_handshake” “group_handshake” “completed” “unknown”
remove_network(network_path)

Removes a configured network from the interface

Parameters:

network_path – D-Bus object path to the desired network

Returns:

None

Raises:
  • NetworkUnknown – The specified network_path is invalid
  • InvalidArgs – Invalid argument format
  • UnknownError – An unknown error occurred
scan(type='active', ssids=None, ies=None, channels=None, block=False)

Triggers a scan

Returns:

List of BSS objects if block=True else None

Raises:
  • InvalidArgs – Invalid argument format
  • MethodTimeout – Scan has timed out (only if block=True)
  • UnknownError – An unknown error occurred
select_network(network_path)

Attempt association with a configured network

Parameters:

network_path – D-Bus object path to the desired network

Returns:

None

Raises:
  • NetworkUnknown – The specified network_path has not been added
  • InvalidArgs – Invalid argument format

Network

class wpa_supplicant.core.Network(obj_path, conn, reactor)

Interface implemented by objects representing configured networks

get_enabled()

Determines if the configured network is enabled or not

get_properties()

Properties of the configured network

Dictionary contains entries from “network” block of wpa_supplicant.conf. All values are string type, e.g., frequency is “2437”, not 2437.

BSS

class wpa_supplicant.core.BSS(obj_path, conn, reactor)

Interface implemented by objects representing a scanned BSSs (scan results)

get_bssid()

BSSID of the BSS as hex bytes delimited by a colon

get_channel()

Wi-Fi channel number (1-14)

get_frequency()

Frequency of the BSS in MHz

get_ies()

All IEs of the BSS as a chain of TLVs

get_mode()

Describes mode of the BSS

Possible values are: “ad-hoc”
“infrastructure”
get_network_type()

Return the network type as a string

Possible values are:
‘WPA’ ‘WPA2’ ‘WEP’ ‘OPEN’
get_privacy()

Indicates if BSS supports privacy

get_rates()

Descending ordered array of rates supported by the BSS in bits per second

get_rsn()

RSN/WPA2 information of the BSS, empty dictionary indicates no RSN support

Dictionaries are:

{
    "KeyMgmt": <Possible array elements: "wpa-psk", "wpa-eap", "wpa-ft-psk", "wpa-ft-eap", "wpa-psk-sha256", "wpa-eap-sha256">,
    "Pairwise": <Possible array elements: "ccmp", "tkip">,
    "Group": <Possible values are: "ccmp", "tkip", "wep104", "wep40">,
    "MgmtGroup": <Possible values are: "aes128cmac">,
}
get_signal_dbm()

Signal strength of the BSS in dBm

get_signal_quality()

Signal strength of the BSS as a percentage (0-100)

get_ssid()

SSID of the BSS in ASCII

get_wpa()

WPA information of the BSS, empty dictionary indicates no WPA support

Dictionaries are:

{
    "KeyMgmt": <Possible array elements: "wpa-psk", "wpa-eap", "wpa-none">,
    "Pairwise": <Possible array elements: "ccmp", "tkip">,
    "Group": <Possible values are: "ccmp", "tkip", "wep104", "wep40">,
    "MgmtGroup": <Possible values are: "aes128cmac">
}
to_dict()

Dict representation of a BSS object