Wi-Fi Operations

Wi-Fi operation features are experimental. We will only introduce some of the available implemented features. You can use the relevant interfaces to get the device's Wi-Fi status, retrieve Wi-Fi scan results, get signal strength, and blacklist BSSIDs.

Get Wi-Fi Instance

First, you need to get a Wi-Fi feature instance. You can do this as follows.

wifi = d.stub("Wifi")

Get Wi-Fi Status

Get Wi-Fi information such as BSSID, SSID, and IP address.

wifi.status()
>>> wifi.status()
id: "0"
address: "c1:c2:c3:c4:c5:c6"
bssid: "00:12:34:56:78:90"
freq: "2447"
group_cipher: "TKIP"
ip_address: "192.168.1.158"
key_mgmt: "WPA2-PSK"
mode: "station"
pairwise_cipher: "CCMP"
ssid: "TPLINK_AE86"
wifi_generation: "4"
wpa_state: "COMPLETED"
>>> result = wifi.status()
>>> print (result.ssid)
TPLINK_AE86

Add to Wi-Fi Blacklist

Add a BSSID to the Wi-Fi blacklist. (After this, the corresponding Wi-Fi network will no longer appear in the Wi-Fi list).

wifi.blacklist_add("3c:06:aa:8a:55:66")

Get Wi-Fi Blacklist

Get all BSSIDs in the Wi-Fi blacklist.

wifi.blacklist_get_all()
>>> wifi.blacklist_get_all()
['3c:06:aa:8a:55:66']

Clear Wi-Fi Blacklist

Clear all blacklisted BSSIDs from the Wi-Fi blacklist.

wifi.blacklist_clear()

Perform Wi-Fi Scan

Perform a Wi-Fi scan. This will initiate a scan for nearby Wi-Fi networks.

wifi.scan()

Get Wi-Fi Scan Results

Calling this interface will return the scan results for nearby Wi-Fi networks.

wifi.scan_results()
>>> wifi.scan_results()
[id: "0"
bssid: "00:12:34:56:78:90"
ssid: "TPLINK_AE86"
freq: "2447"
noise: "-89"
level: "-62"
tsf: "0000001234567890"
flags: "[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]"
, id: "6"
bssid: "00:12:34:56:78:90"
ssid: "MIFI-97A5"
freq: "2437"
noise: "-89"
level: "-59"
tsf: "0000001234567890"
flags: "[WPA2-PSK-CCMP][WPS][ESS]"
...
>>> result = wifi.scan_results()
>>> print (result[0].bssid)
00:12:34:56:78:90

Get Wi-Fi Signal Strength

Call the following interface to get information such as Wi-Fi signal strength, link speed, and frequency.

wifi.signal_poll()
>>> wifi.signal_poll()
RSSI: "-59"
LINKSPEED: "39"
NOISE: "9999"
FREQUENCY: "2447"
>>> result = wifi.signal_poll()
>>> print (result.LINKSPEED)
39

Get Wi-Fi MAC Address

Call this interface to get the current Wi-Fi MAC address.

wifi.get_mac_addr()
>>> wifi.get_mac_addr()
'c1:c2:c3:c4:c5:c6'