Programming problem with WiFiscan.py

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)

Here is the output:

Scanning...
(b'TELUS1837', b'\xfc+\xb2\xe18B', 11, -56, 4, 1)

SSID:b'TELUS1837' b'\xfc+\xb2\xe18B' Channel:11 RSSI:-56 Auth:4 BSSID:1

# 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)

Maybe this helps.

Thanks. I'll give it a try and post the results.

Here is the result of your code:

Scanning...
(b'TELUS1837', b'\xfc+\xb2\xe18B', 11, -54, 4, 1)

SSID:b'TELUS1837' b'\xfc+\xb2\xe18B' Channel:11 RSSI:-54 Auth:4 BSSID:1

Everything is correct.

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.

1 Like

Thank you so much for all your help !

I would be happy about a like! You can also mark it as "Solved"!
If you have any further questions, you can write to me!

1 Like

Solved

Then it's good!

I don't want to force you, but it's best to mark the solution as "solution" so that it shows that the problem has been solved!

image

Thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.