WiFi

WiFi-related operation functions are experimental features. We only introduce some of the available functionalities that have been implemented. You can obtain the device's WiFi status, WiFi scan results, signal strength, and add BSSID to the blacklist through relevant interfaces.

Get WiFi Instance

First, you need to obtain a WiFi function instance, which can be achieved as follows.

wifi = d.stub("Wifi")

Get WiFi Status

Get information such as WiFi's BSSID, SSID, IP, etc.

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 WiFi Blacklist

Add a BSSID to the WiFi blacklist (after that, this WiFi will not appear in the WiFi list).

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

Get WiFi Blacklist

Get all BSSIDs in the WiFi blacklist.

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

Clear WiFi Blacklist

Clear all BSSIDs from the WiFi blacklist.

wifi.blacklist_clear()

Perform WiFi Scan

Perform a WiFi scan; calling this will attempt to scan nearby WiFi networks.

wifi.scan()

Get WiFi Scan Results

Calling this interface will return the scan results of surrounding WiFi 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 WiFi Signal Strength

Call the following interface to get information such as WiFi 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 WiFi MAC

Get the MAC address of the current WiFi.

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