File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1
1
def test_wifi (dut ):
2
+ dut .expect_exact ("Scan start" )
3
+ dut .expect_exact ("Scan done" )
4
+ dut .expect_exact ("Wokwi-GUEST" )
2
5
dut .expect_exact ("WiFi connected" )
3
6
dut .expect_exact ("IP address:" )
Original file line number Diff line number Diff line change @@ -112,6 +112,28 @@ void setup() {
112
112
Serial.println (eventID);
113
113
// WiFi.removeEvent(eventID);
114
114
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
+
115
137
WiFi.begin (ssid, password);
116
138
117
139
Serial.println ();
You can’t perform that action at this time.
0 commit comments