7
7
#include < Wire.h>
8
8
#include < vector>
9
9
#include < algorithm>
10
+ #include < WiFi.h>
11
+
12
+ #include " sdkconfig.h"
10
13
11
14
/* DS1307 functions */
12
15
@@ -26,6 +29,9 @@ static uint8_t read_month = 0;
26
29
static uint16_t read_year = 0 ;
27
30
static int peek_data = -1 ;
28
31
32
+ const char *ssid = " Wokwi-GUEST" ;
33
+ const char *password = " " ;
34
+
29
35
const auto BCD2DEC = [](uint8_t num) -> uint8_t {
30
36
return ((num / 16 * 10 ) + (num % 16 ));
31
37
};
@@ -247,7 +253,7 @@ void test_api() {
247
253
Wire.flush ();
248
254
}
249
255
250
- void scan_bus () {
256
+ bool device_found () {
251
257
std::vector<uint8_t > found_addresses;
252
258
uint8_t err;
253
259
@@ -259,14 +265,33 @@ void scan_bus() {
259
265
log_i (" Found device at address: 0x%02X" , address);
260
266
found_addresses.push_back (address);
261
267
} else if (address == DS1307_ADDR) {
262
- TEST_FAIL_MESSAGE (" Failed to find DS1307" );
268
+ log_e (" Failed to find DS1307" );
269
+ return false ;
263
270
}
264
271
}
265
272
266
273
// Find DS1307_ADDR in found_addresses
267
274
auto it = std::find (found_addresses.begin (), found_addresses.end (), DS1307_ADDR);
268
- TEST_ASSERT_TRUE (it != found_addresses.end ());
275
+ return it != found_addresses.end ();
276
+ }
277
+
278
+ void scan_bus () {
279
+ TEST_ASSERT_TRUE (device_found ());
280
+ }
281
+
282
+ #if SOC_WIFI_SUPPORTED
283
+ void scan_bus_with_wifi () {
284
+ // delete old config
285
+ WiFi.disconnect (true , true , 1000 );
286
+ delay (1000 );
287
+ WiFi.begin (ssid, password);
288
+ delay (5000 );
289
+ bool found = device_found ();
290
+ WiFi.disconnect (true , true , 1000 );
291
+
292
+ TEST_ASSERT_TRUE (found);
269
293
}
294
+ #endif
270
295
271
296
/* Main */
272
297
@@ -282,6 +307,9 @@ void setup() {
282
307
log_d (" Starting tests" );
283
308
UNITY_BEGIN ();
284
309
RUN_TEST (scan_bus);
310
+ #if SOC_WIFI_SUPPORTED
311
+ RUN_TEST (scan_bus_with_wifi);
312
+ #endif
285
313
RUN_TEST (rtc_set_time);
286
314
RUN_TEST (rtc_run_clock);
287
315
RUN_TEST (change_clock);
0 commit comments