From 6e758fc12a071571a6b1fb2a855db3696f03ecc6 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 19 Jul 2023 16:11:11 +0200 Subject: [PATCH] tests/psoc6/multi/network: Moving config test to new file. Signed-off-by: enriquezgarc --- tests/psoc6/multi/network.py | 20 ++------ tests/psoc6/multi/network.py.exp | 2 - tests/psoc6/multi/network_config.py | 71 +++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 tests/psoc6/multi/network_config.py diff --git a/tests/psoc6/multi/network.py b/tests/psoc6/multi/network.py index 4697cdd8607c3..e55743906a255 100644 --- a/tests/psoc6/multi/network.py +++ b/tests/psoc6/multi/network.py @@ -2,6 +2,8 @@ channel_default = 9 channel_new = 5 +ssid_default = "mpy-psoc6-wlan" +ssid_new = "mpy-test-conf-wlan" # Access Point @@ -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(): @@ -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() @@ -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() diff --git a/tests/psoc6/multi/network.py.exp b/tests/psoc6/multi/network.py.exp index 78c016b20e9a7..f6393bbcd1778 100644 --- a/tests/psoc6/multi/network.py.exp +++ b/tests/psoc6/multi/network.py.exp @@ -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 @@ -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 diff --git a/tests/psoc6/multi/network_config.py b/tests/psoc6/multi/network_config.py new file mode 100644 index 0000000000000..897837c0d9e72 --- /dev/null +++ b/tests/psoc6/multi/network_config.py @@ -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()