Skip to content

Commit e8b55ca

Browse files
committed
WiFi tests: Only support Odin board
1 parent 34cc61f commit e8b55ca

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

TESTS/network/wifi/main.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
#include "mbed.h"
2222

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+
2329
using namespace utest::v1;
2430

2531
/**
@@ -32,30 +38,25 @@ using namespace utest::v1;
3238
#error WIFI_TEST_NETWORKS, WIFI_TEST_PASS and WIFI_TEST_NETWORKS have to be defined for this test.
3339
#endif
3440

41+
3542
const char *networks[] = {WIFI_TEST_NETWORKS, NULL};
3643

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;
5045

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+
*/
5250
WiFiInterface *get_wifi()
5351
{
52+
if (wifi == NULL) {
53+
/* We don't really care about freeing this, as its lifetime is through the full test suit run. */
5454
#if TARGET_UBLOX_EVK_ODIN_W2
55-
return wifi.get();
56-
#else
57-
return &wifi;
55+
wifi = new OdinWiFiInterface;
5856
#endif
57+
}
58+
59+
return wifi;
5960
}
6061

6162
void check_wifi(const char *ssid, bool *net_stat)

0 commit comments

Comments
 (0)