File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 11def test_wifi (dut ):
2+ dut .expect_exact ("Scan start" )
3+ dut .expect_exact ("Scan done" )
4+ dut .expect_exact ("Wokwi-GUEST" )
25 dut .expect_exact ("WiFi connected" )
36 dut .expect_exact ("IP address:" )
Original file line number Diff line number Diff line change @@ -112,6 +112,28 @@ void setup() {
112112 Serial.println (eventID);
113113 // WiFi.removeEvent(eventID);
114114
115+ Serial.println (" Scan start" );
116+
117+ // WiFi.scanNetworks will return the number of networks found.
118+ int n = WiFi.scanNetworks ();
119+ Serial.println (" Scan done" );
120+ if (n == 0 ) {
121+ Serial.println (" no networks found" );
122+ } else {
123+ Serial.print (n);
124+ Serial.println (" networks found" );
125+ for (int i = 0 ; i < n; ++i) {
126+ // Print SSID for each network found
127+ Serial.printf (" %s\n " , WiFi.SSID (i).c_str ());
128+ Serial.println ();
129+ delay (10 );
130+ }
131+ }
132+ Serial.println (" " );
133+
134+ // Delete the scan result to free memory for code below.
135+ WiFi.scanDelete ();
136+
115137 WiFi.begin (ssid, password);
116138
117139 Serial.println ();
You can’t perform that action at this time.
0 commit comments