Skip to content

Commit

Permalink
tests/ports/psoc6/../network: Added randomized ssid to avoid conflicts.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Oct 10, 2024
1 parent e993c5f commit 3fdcf85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions tests/ports/psoc6/board_only_hw/multi/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
raise SystemExit

channel_new = 1
ssid_default = "mpy-psoc6-wlan"


# Access Point
Expand All @@ -17,7 +16,12 @@ def instance0():

ap_if = network.WLAN(network.AP_IF)
print("ap instance created")
ap_if.config(channel=channel_new)

# Generate "random" SSID to avoid test conflicts
time_stamp = time.time()
ssid_new = "mpy-psoc6-" + str(time_stamp)
multitest.globals(ssid_gen=ssid_new)
ap_if.config(channel=channel_new, ssid=ssid_new)

# active()
print("ap initially not active: ", ap_if.active() == False)
Expand Down Expand Up @@ -62,11 +66,13 @@ def instance1():

# scan()
wlan_nets = sta_if.scan()
test_ap_net = [net for net in wlan_nets if net[0] == b"mpy-psoc6-wlan"]
# The returned ssid is a bytes object
bytes_ssid = bytes(ssid_gen, "utf-8")
test_ap_net = [net for net in wlan_nets if net[0] == bytes_ssid]
print("sta scan finds ap wlan: ", test_ap_net != [])

wlan_ssid_filter = sta_if.scan(ssid="mpy-psoc6-wlan")
test_ap_net = [net for net in wlan_ssid_filter if net[0] == b"mpy-psoc6-wlan"]
wlan_ssid_filter = sta_if.scan(ssid=ssid_gen)
test_ap_net = [net for net in wlan_ssid_filter if net[0] == bytes_ssid]
print("sta scan finds ap wlan (ssid filter): ", test_ap_net != [])

# print('ap_mac: ', binascii.hexlify(ap_mac, ':'))
Expand All @@ -79,7 +85,7 @@ def instance1():
print("sta is not (yet) connected: ", sta_if.isconnected() == False)

# connect()
sta_if.connect(ssid_default, "mpy_PSOC6_w3lc0me!")
sta_if.connect(ssid_gen, "mpy_PSOC6_w3lc0me!")
print("sta attempt connection to ap")

# active()
Expand All @@ -100,6 +106,6 @@ def instance1():
print("sta is disconnected: ", sta_if.active() == False)

print("sta attempt connection to ap (with bssid)")
sta_if.connect(ssid_default, "mpy_PSOC6_w3lc0me!", bssid=ap_mac)
sta_if.connect(ssid_gen, "mpy_PSOC6_w3lc0me!", bssid=ap_mac)

print("sta is active: ", sta_if.active() == True)
2 changes: 1 addition & 1 deletion tests/ports/psoc6/board_only_hw/multi/network_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
raise SystemExit

channel_new = 5
ssid_new = "mpy-test-conf-wlan"
ssid_new = "mpy-test-" + str(time.time())
pass_new = "alicessecret"
sec_new = network.WLAN.WPA2

Expand Down

0 comments on commit 3fdcf85

Please sign in to comment.