From 034d568d7cb6c7f9e7f52eefbdf99fe86ef0c6c9 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:30:46 -0300 Subject: [PATCH] ci(wifi): Add scan to wifi test (#9805) --- tests/validation/wifi/test_wifi.py | 3 +++ tests/validation/wifi/wifi.ino | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/validation/wifi/test_wifi.py b/tests/validation/wifi/test_wifi.py index aa074192341..49dd22797d2 100644 --- a/tests/validation/wifi/test_wifi.py +++ b/tests/validation/wifi/test_wifi.py @@ -1,3 +1,6 @@ def test_wifi(dut): + dut.expect_exact("Scan start") + dut.expect_exact("Scan done") + dut.expect_exact("Wokwi-GUEST") dut.expect_exact("WiFi connected") dut.expect_exact("IP address:") diff --git a/tests/validation/wifi/wifi.ino b/tests/validation/wifi/wifi.ino index dd93ac137f9..696234505cc 100644 --- a/tests/validation/wifi/wifi.ino +++ b/tests/validation/wifi/wifi.ino @@ -112,6 +112,28 @@ void setup() { Serial.println(eventID); // WiFi.removeEvent(eventID); + Serial.println("Scan start"); + + // WiFi.scanNetworks will return the number of networks found. + int n = WiFi.scanNetworks(); + Serial.println("Scan done"); + if (n == 0) { + Serial.println("no networks found"); + } else { + Serial.print(n); + Serial.println(" networks found"); + for (int i = 0; i < n; ++i) { + // Print SSID for each network found + Serial.printf("%s\n", WiFi.SSID(i).c_str()); + Serial.println(); + delay(10); + } + } + Serial.println(""); + + // Delete the scan result to free memory for code below. + WiFi.scanDelete(); + WiFi.begin(ssid, password); Serial.println();