Skip to content

Commit 787605c

Browse files
committed
connectivity-netsocket-tests-tests-network-wifi update
Use default NSAPI configuration
1 parent f89655f commit 787605c

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

connectivity/netsocket/tests/TESTS/network/wifi/get_interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include "wifi_tests.h"
19+
1820
#define WIFI 2
1921
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
2022
MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE != WIFI
@@ -25,7 +27,6 @@
2527
#else
2628

2729
#include "mbed.h"
28-
#include "WiFiInterface.h"
2930

3031
WiFiInterface *get_interface()
3132
{

connectivity/netsocket/tests/TESTS/network/wifi/get_security.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ nsapi_security get_security()
4747
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA3_WPA2) == 0) {
4848
return NSAPI_SECURITY_WPA3_WPA2;
4949
}
50+
#elif defined MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY
51+
return MBED_CONCAT(NSAPI_SECURITY_, MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY);
5052
#endif
5153
return NSAPI_SECURITY_NONE;
5254
}

connectivity/netsocket/tests/TESTS/network/wifi/main.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,21 @@
2727
#include "utest.h"
2828
#include "wifi_tests.h"
2929

30+
#if !defined(MBED_CONF_APP_WIFI_SECURE_SSID)
31+
#error [NOT_SUPPORTED] Requires secure AP
32+
#endif
33+
3034
// Test for parameters
3135
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && \
32-
(!defined(MBED_CONF_APP_AP_MAC_SECURE) || \
33-
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
34-
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
36+
(!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
3537
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \
36-
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
3738
!defined(MBED_CONF_APP_WIFI_SECURE_PROTOCOL))
3839
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
3940
#else
4041

4142
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) && \
42-
(!defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
43-
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
44-
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
45-
!defined(MBED_CONF_APP_WIFI_UNSECURE_SSID))
43+
(!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
44+
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE))
4645
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections)
4746
#else
4847

connectivity/netsocket/tests/TESTS/network/wifi/template_mbed_app.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
{
22
"config": {
33
"wifi-secure-ssid": {
4-
"help": "WiFi SSID for WPA2 secured network",
4+
"help": "WiFi SSID for secure network",
5+
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_SSID is used",
56
"value": "\"SSID-SECURE\""
67
},
78
"wifi-unsecure-ssid": {
8-
"help": "WiFi SSID for unsecure netwrok",
9+
"help": "WiFi SSID for unsecure network",
10+
"optional_parameter": "if value is null, non-secure tests are skipped",
911
"value": "\"SSID-UNSECURE\""
1012
},
1113
"wifi-password": {
1214
"help": "WiFi Password",
15+
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_PASSWORD is used",
1316
"value": "\"PASSWORD\""
1417
},
1518
"wifi-secure-protocol": {
1619
"help": "WiFi security protocol, valid values are WEP, WPA, WPA2, WPA/WPA2",
17-
"value": "\"WPA/WPA2\""
20+
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY is used",
21+
"value": "\"WPA2\""
1822
},
1923
"wifi-ch-secure": {
20-
"help": "Channel number of secure SSID",
24+
"help": "Channel number of secure SSID (if set_channel() is supported)",
2125
"value": 1
2226
},
2327
"wifi-ch-unsecure": {
24-
"help": "Channel number of unsecure SSID",
28+
"help": "Channel number of unsecure SSID (if set_channel() is supported)",
2529
"value": 2
2630
},
2731
"ap-mac-secure": {
@@ -33,7 +37,7 @@
3337
"value": "\"BB:BB:BB:BB:BB:BB\""
3438
},
3539
"max-scan-size": {
36-
"help": "How many networks may appear in Wifi scan result",
40+
"help": "How many networks may appear in Wifi scan result (default is 10)",
3741
"value": 10
3842
}
3943
},

connectivity/netsocket/tests/TESTS/network/wifi/wifi_tests.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,29 @@
1717
#ifndef WIFI_TESTS_H
1818
#define WIFI_TESTS_H
1919

20+
#ifdef MBED_CONF_NSAPI_PRESENT
2021
#include "WiFiInterface.h"
2122

23+
#if !defined(MBED_CONF_APP_WIFI_SECURE_SSID)
24+
#define MBED_CONF_APP_WIFI_SECURE_SSID MBED_CONF_NSAPI_DEFAULT_WIFI_SSID
25+
#endif
26+
27+
#if !defined(MBED_CONF_APP_WIFI_PASSWORD)
28+
#define MBED_CONF_APP_WIFI_PASSWORD MBED_CONF_NSAPI_DEFAULT_WIFI_PASSWORD
29+
#endif
30+
31+
#if !defined(MBED_CONF_APP_WIFI_SECURE_PROTOCOL)
32+
#define MBED_CONF_APP_WIFI_SECURE_PROTOCOL MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY
33+
#endif
34+
35+
#if !defined(MBED_CONF_APP_WIFI_CH_SECURE)
36+
#define MBED_CONF_APP_WIFI_CH_SECURE 1
37+
#endif
38+
39+
#if !defined(MBED_CONF_APP_MAX_SCAN_SIZE)
40+
#define MBED_CONF_APP_MAX_SCAN_SIZE 10
41+
#endif
42+
2243
/** Get WiFiInterface based on provided
2344
* app_json. */
2445
WiFiInterface *get_interface(void);
@@ -82,3 +103,4 @@ void wifi_scan_null(void);
82103
void wifi_scan(void);
83104

84105
#endif //WIFI_TESTS_H
106+
#endif // MBED_CONF_NSAPI_PRESENT

0 commit comments

Comments
 (0)