Skip to content

Commit 72e7c32

Browse files
author
Seppo Takalo
committed
Fix builds for targets without wifi or without mbed_app.json
1 parent 5b40280 commit 72e7c32

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

TESTS/network/wifi/get_interface.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
#include "mbed.h"
22

3+
// Pick the correct driver based on mbed_app.json
4+
#define INTERNAL 1
5+
#define WIFI_ESP8266 2
6+
#define X_NUCLEO_IDW01M1 3
7+
8+
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL
9+
310
#if TARGET_UBLOX_EVK_ODIN_W2
411
#include "OdinWiFiInterface.h"
12+
#define DRIVER OdinWiFiInterface
13+
514
#elif TARGET_REALTEK_RTL8195AM
615
#include "RTWInterface.h"
16+
#define DRIVER RTWInterface
717
#else
18+
#error [NOT_SUPPORTED] Unsupported Wifi driver
19+
#endif
20+
21+
#elif MBED_CONF_APP_WIFI_DRIVER == WIFI_ESP8266
822
#include "ESP8266Interface.h"
23+
#define DRIVER ESP8266Interface
24+
25+
#elif MBED_CONF_APP_WIFI_DRIVER == X_NUCLEO_IDW01M1
26+
#include "SpwfSAInterface.h"
27+
#define DRIVER SpwfSAInterface
28+
#else
29+
#error [NOT_SUPPORTED] Unsupported Wifi driver
930
#endif
1031

1132
WiFiInterface *get_interface()
@@ -15,12 +36,10 @@ WiFiInterface *get_interface()
1536
if (interface)
1637
delete interface;
1738

18-
#if TARGET_UBLOX_EVK_ODIN_W2
19-
interface = new OdinWiFiInterface();
20-
#elif TARGET_REALTEK_RTL8195AM
21-
interface = new RTWInterface();
39+
#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL
40+
interface = new DRIVER();
2241
#else
23-
interface = new ESP8266Interface(D1, D0);
42+
interface = new DRIVER(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
2443
#endif
2544
return interface;
2645
}

TESTS/network/wifi/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
#include "utest.h"
55
#include "wifi_tests.h"
66

7+
// Test for parameters
8+
#if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \
9+
!defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
10+
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
11+
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
12+
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
13+
!defined(MBED_CONF_APP_WIFI_DRIVER) || \
14+
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \
15+
!defined(MBED_CONF_APP_WIFI_RX) || \
16+
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
17+
!defined(MBED_CONF_APP_WIFI_TX) || \
18+
!defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
19+
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json
20+
#endif
21+
722
using namespace utest::v1;
823

924
utest::v1::status_t test_setup(const size_t number_of_cases) {

TESTS/network/wifi/template_mbed_app.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
"help": "Channel number of unsecure SSID",
2121
"value": 2
2222
},
23+
"wifi-driver": {
24+
"help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW01M1",
25+
"value": "INTERNAL"
26+
},
27+
"wifi-tx": {
28+
"help": "TX pin for serial connection to external device",
29+
"value": "D1"
30+
},
31+
"wifi-rx": {
32+
"help": "RX pin for serial connection to external device",
33+
"value": "D0"
34+
},
2335
"ap-mac-secure": {
2436
"help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF",
2537
"value": "\"AA:AA:AA:AA:AA:AA\""

0 commit comments

Comments
 (0)