20
20
21
21
#include " mbed.h"
22
22
23
+ #if TARGET_UBLOX_EVK_ODIN_W2
24
+ #include " OdinWiFiInterface.h"
25
+ #else
26
+ #error [NOT_SUPPORTED] Only built in WiFi modules are supported at this time.
27
+ #endif
28
+
23
29
using namespace utest ::v1;
24
30
25
31
/* *
@@ -32,30 +38,25 @@ using namespace utest::v1;
32
38
#error WIFI_TEST_NETWORKS, WIFI_TEST_PASS and WIFI_TEST_NETWORKS have to be defined for this test.
33
39
#endif
34
40
41
+
35
42
const char *networks[] = {WIFI_TEST_NETWORKS, NULL };
36
43
37
- /* We use singletons as some of the WiFi modules don't like to be initialized multiple times and using global objects
38
- causes greentea serial to timeout.
39
- */
40
- #if TARGET_UBLOX_EVK_ODIN_W2
41
- #include " OdinWiFiInterface.h"
42
- SingletonPtr<OdinWiFiInterface> wifi;
43
- #else
44
- #if !TARGET_FF_ARDUINO
45
- #error [NOT_SUPPORTED] Only Arduino form factor devices supported
46
- #endif
47
- #include " ESP8266Interface.h"
48
- ESP8266Interface wifi (D1, D0);
49
- #endif
44
+ WiFiInterface *wifi;
50
45
51
- /* That's a hack to accommodate Odin requiring a singleton */
46
+ /* In normal circumstances the WiFi object could be global, but the delay introduced by WiFi initialization is an issue
47
+ for the tests. It causes Greentea to timeout on syncing with the board. To solve it we defer the actual object
48
+ creation till we actually need it.
49
+ */
52
50
WiFiInterface *get_wifi ()
53
51
{
52
+ if (wifi == NULL ) {
53
+ /* We don't really care about freeing this, as its lifetime is through the full test suit run. */
54
54
#if TARGET_UBLOX_EVK_ODIN_W2
55
- return wifi.get ();
56
- #else
57
- return &wifi;
55
+ wifi = new OdinWiFiInterface;
58
56
#endif
57
+ }
58
+
59
+ return wifi;
59
60
}
60
61
61
62
void check_wifi (const char *ssid, bool *net_stat)
0 commit comments