Reading and Writing WIFI Information

WIFI operation-related functions are experimental features. We only introduce some of the implemented available functions. You can use the relevant interfaces to get the device’s WIFI status, get WIFI scan results, get signal strength, blacklist BSSIDs, and other functions.

Getting WIFI Instance

First, you still need to get a WIFI function instance, which can be obtained using the following method.

wifi = d.stub("Wifi")

Getting WIFI Status

Get wifi bssid, ssid, ip, and other related information.

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

Adding to WIFI Blacklist

Add bssid to the WIFI blacklist (after this, the WIFI will not be displayed in the WIFI list).

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

Getting WIFI Blacklist

Get all bssids in the WIFI blacklist.

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

Clearing WIFI Blacklist

Clear all blacklisted BSSIDs in the WIFI blacklist.

wifi.blacklist_clear()

Performing WIFI Scan

Perform a WIFI scan. After calling, it will try to scan the surrounding WIFI networks.

wifi.scan()

Getting 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

Getting WIFI Signal Strength

Call the following interface to get WIFI signal strength, link speed, and frequency information.

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

Getting WIFI MAC

Call this interface to get the MAC address of the current WIFI.

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