77 raise SystemExit
88
99channel_new = 1
10- ssid_default = "mpy-psoc6-wlan"
1110
1211
1312# Access Point
@@ -17,7 +16,12 @@ def instance0():
1716
1817 ap_if = network .WLAN (network .AP_IF )
1918 print ("ap instance created" )
20- ap_if .config (channel = channel_new )
19+
20+ # Generate "random" SSID to avoid test conflicts
21+ time_stamp = time .time ()
22+ ssid_new = "mpy-psoc6-" + str (time_stamp )
23+ multitest .globals (ssid_gen = ssid_new )
24+ ap_if .config (channel = channel_new , ssid = ssid_new )
2125
2226 # active()
2327 print ("ap initially not active: " , ap_if .active () == False )
@@ -62,11 +66,13 @@ def instance1():
6266
6367 # scan()
6468 wlan_nets = sta_if .scan ()
65- test_ap_net = [net for net in wlan_nets if net [0 ] == b"mpy-psoc6-wlan" ]
69+ # The returned ssid is a bytes object
70+ bytes_ssid = bytes (ssid_gen , "utf-8" )
71+ test_ap_net = [net for net in wlan_nets if net [0 ] == bytes_ssid ]
6672 print ("sta scan finds ap wlan: " , test_ap_net != [])
6773
68- wlan_ssid_filter = sta_if .scan (ssid = "mpy-psoc6-wlan" )
69- test_ap_net = [net for net in wlan_ssid_filter if net [0 ] == b"mpy-psoc6-wlan" ]
74+ wlan_ssid_filter = sta_if .scan (ssid = ssid_gen )
75+ test_ap_net = [net for net in wlan_ssid_filter if net [0 ] == bytes_ssid ]
7076 print ("sta scan finds ap wlan (ssid filter): " , test_ap_net != [])
7177
7278 # print('ap_mac: ', binascii.hexlify(ap_mac, ':'))
@@ -79,7 +85,7 @@ def instance1():
7985 print ("sta is not (yet) connected: " , sta_if .isconnected () == False )
8086
8187 # connect()
82- sta_if .connect (ssid_default , "mpy_PSOC6_w3lc0me!" )
88+ sta_if .connect (ssid_gen , "mpy_PSOC6_w3lc0me!" )
8389 print ("sta attempt connection to ap" )
8490
8591 # active()
@@ -100,6 +106,6 @@ def instance1():
100106 print ("sta is disconnected: " , sta_if .active () == False )
101107
102108 print ("sta attempt connection to ap (with bssid)" )
103- sta_if .connect (ssid_default , "mpy_PSOC6_w3lc0me!" , bssid = ap_mac )
109+ sta_if .connect (ssid_gen , "mpy_PSOC6_w3lc0me!" , bssid = ap_mac )
104110
105111 print ("sta is active: " , sta_if .active () == True )
0 commit comments