I am having problems with the wifi-scan.py example found on this page:
The output of wlan.scan() appears to be different from the way it is parsed in the code that follows.
I need help parsing the new output of wlan.scan().
# Scan Example
# This example shows how to scan for Wi-Fi networks.
import time, network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
print("Scanning...")
while (True):
scan_result = wlan.scan()
for ap in scan_result:
print (ap)
print()
#print("Channel:%s RSSI:%s Auth:%s BSSID:%s SSID:%s"%(ap))
print("SSID:%s %s Channel:%d RSSI:%d Auth:%d BSSID:%d "%(ap))
print()
time.sleep_ms(2000)
# Scan Example
# This example shows how to scan for Wi-Fi networks.
import time, network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
print("Scanning...")
while (True):
scan_result = wlan.scan()
for ap in scan_result:
print(ap)
print()
#print("Channel:%s RSSI:%s Auth:%s BSSID:%s SSID:%s"%(ap))
# Add parentheses and commas around ap
print("SSID:%s %s Channel:%d RSSI:%d Auth:%d BSSID:%d "%(ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]))
print()
time.sleep_ms(2000)
The output shows one access point that was detected by the scan. The SSID is TELUS1837, which is the name of the network. The BSSID is fc:2b:b2:e1:38:42, which is the MAC address of the router. The channel is 11, which is the frequency band used by the network. The RSSI is -54, which is the signal strength in decibels. The Auth is 4, which is the authentication mode used by the network. The last number 1 is not part of the output, but a reference to the first result in the scan list.