Skip to content

Commit

Permalink
tests/psoc6/multi/network: Moving config test to new file.
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 Jul 19, 2023
1 parent 6677bfc commit 6e758fc
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 18 deletions.
20 changes: 4 additions & 16 deletions tests/psoc6/multi/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

channel_default = 9
channel_new = 5
ssid_default = "mpy-psoc6-wlan"
ssid_new = "mpy-test-conf-wlan"


# Access Point
Expand Down Expand Up @@ -44,12 +46,6 @@ def instance0():
stations = ap_if.status("stations")
print("ap status has stations: ", stations != [])

# ifconfig()

# config()
print("ap channel: ", ap_if.config("channel") == channel_default)
ap_if.config(channel=channel_new)


# Station
def instance1():
Expand Down Expand Up @@ -78,7 +74,7 @@ def instance1():
print("sta is not (yet) connected: ", sta_if.isconnected() == False)

# connect()
sta_if.connect("mpy-psoc6-wlan", "mpy_PSOC6_w3lc0me!")
sta_if.connect(ssid_default, "mpy_PSOC6_w3lc0me!")
print("sta attempt connection to ap")

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

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

print("sta is active: ", sta_if.active() == True)

# ifconfig()

# config()
print("sta assoc ap channel: ", sta_if.config("channel") == channel_new)

# # As teardown
# sta_if.disconnect()
2 changes: 0 additions & 2 deletions tests/psoc6/multi/network.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ap has no client: True
ap has clients: True
ap cannot disconnect: network STA required
ap status has stations: True
ap channel: True
--- instance1 ---
sta instance created
sta is not active: True
Expand All @@ -25,4 +24,3 @@ sta status rssi in range: True
sta is disconnected: True
sta attempt connection to ap (with bssid)
sta is active: True
sta assoc ap channel: True
71 changes: 71 additions & 0 deletions tests/psoc6/multi/network_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import binascii, network, time

channel_new = 5
ssid_new = "mpy-test-conf-wlan"
pass_new = "alicessecret"
sec_new = network.WPA3


# Access Point
def instance0():
ap_if = network.WLAN(network.AP_IF)
print("ap instance created")

# ifconfig()

# get config()
print("ap config get channel: ", ap_if.config("channel") == channel_new)
ap_if.config(channel=channel_new)
print("ap config get ssid: ", ap_if.config("ssid") == ssid_new)
ap_if.config(ssid=ssid_new)
print("ap config get pass: ", ap_if.config("key") == pass_new)
print("ap config get security: ", ap_if.config("security") == sec_new)
ap_if.config(sec=ssid_new, key=pass_new)

# active()
ap_if.active(True)
while ap_if.active() == False:
pass
print("ap is activated")

print(" > yield station")
multitest.next()

while ap_if.isconnected() == False:
pass
print("ap has clients: ", ap_if.isconnected() == True)

# status()
stations = ap_if.status("stations")
print("ap status has stations: ", stations != [])


# Station
def instance1():
sta_if = network.WLAN(network.STA_IF)
print("sta instance created")

# connect()
sta_if.connect(ssid_new, pass_new)
print("sta attempt connection to ap")

# active()
print("sta is (now) active: ", sta_if.active() == True)

# isConnected()
print("sta is (now) connected: ", sta_if.isconnected() == True)

# config()
print("sta assoc ap channel config: ", sta_if.config("channel") == channel_new)
print("sta assoc ap ssid config: ", sta_if.config("ssid") == ssid_new)
print("sta assoc ap security config: ", sta_if.config("security") == sec_new)

try:
sta_if.config("key") # not for STA
except ValueError as err:
print("network config key not for sta: ", err)

# print(" > yield access point")
# multitest.next()

# ifconfig()

0 comments on commit 6e758fc

Please sign in to comment.