connectivity-netsocket-tests-tests-network-wifi update

Use default NSAPI configuration
pull/15031/head
Jerome Coutant 2021-09-02 10:10:36 +02:00
parent f89655f2da
commit 787605cec4
5 changed files with 43 additions and 15 deletions

View File

@ -15,6 +15,8 @@
* limitations under the License.
*/
#include "wifi_tests.h"
#define WIFI 2
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE != WIFI
@ -25,7 +27,6 @@
#else
#include "mbed.h"
#include "WiFiInterface.h"
WiFiInterface *get_interface()
{

View File

@ -47,6 +47,8 @@ nsapi_security get_security()
if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA3_WPA2) == 0) {
return NSAPI_SECURITY_WPA3_WPA2;
}
#elif defined MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY
return MBED_CONCAT(NSAPI_SECURITY_, MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY);
#endif
return NSAPI_SECURITY_NONE;
}

View File

@ -27,22 +27,21 @@
#include "utest.h"
#include "wifi_tests.h"
#if !defined(MBED_CONF_APP_WIFI_SECURE_SSID)
#error [NOT_SUPPORTED] Requires secure AP
#endif
// Test for parameters
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && \
(!defined(MBED_CONF_APP_AP_MAC_SECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_SECURE) || \
(!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_PASSWORD) || \
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
!defined(MBED_CONF_APP_WIFI_SECURE_PROTOCOL))
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
#else
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) && \
(!defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
!defined(MBED_CONF_APP_WIFI_UNSECURE_SSID))
(!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE))
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections)
#else

View File

@ -1,27 +1,31 @@
{
"config": {
"wifi-secure-ssid": {
"help": "WiFi SSID for WPA2 secured network",
"help": "WiFi SSID for secure network",
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_SSID is used",
"value": "\"SSID-SECURE\""
},
"wifi-unsecure-ssid": {
"help": "WiFi SSID for unsecure netwrok",
"help": "WiFi SSID for unsecure network",
"optional_parameter": "if value is null, non-secure tests are skipped",
"value": "\"SSID-UNSECURE\""
},
"wifi-password": {
"help": "WiFi Password",
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_PASSWORD is used",
"value": "\"PASSWORD\""
},
"wifi-secure-protocol": {
"help": "WiFi security protocol, valid values are WEP, WPA, WPA2, WPA/WPA2",
"value": "\"WPA/WPA2\""
"optional_parameter": "if value is null, MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY is used",
"value": "\"WPA2\""
},
"wifi-ch-secure": {
"help": "Channel number of secure SSID",
"help": "Channel number of secure SSID (if set_channel() is supported)",
"value": 1
},
"wifi-ch-unsecure": {
"help": "Channel number of unsecure SSID",
"help": "Channel number of unsecure SSID (if set_channel() is supported)",
"value": 2
},
"ap-mac-secure": {
@ -33,7 +37,7 @@
"value": "\"BB:BB:BB:BB:BB:BB\""
},
"max-scan-size": {
"help": "How many networks may appear in Wifi scan result",
"help": "How many networks may appear in Wifi scan result (default is 10)",
"value": 10
}
},

View File

@ -17,8 +17,29 @@
#ifndef WIFI_TESTS_H
#define WIFI_TESTS_H
#ifdef MBED_CONF_NSAPI_PRESENT
#include "WiFiInterface.h"
#if !defined(MBED_CONF_APP_WIFI_SECURE_SSID)
#define MBED_CONF_APP_WIFI_SECURE_SSID MBED_CONF_NSAPI_DEFAULT_WIFI_SSID
#endif
#if !defined(MBED_CONF_APP_WIFI_PASSWORD)
#define MBED_CONF_APP_WIFI_PASSWORD MBED_CONF_NSAPI_DEFAULT_WIFI_PASSWORD
#endif
#if !defined(MBED_CONF_APP_WIFI_SECURE_PROTOCOL)
#define MBED_CONF_APP_WIFI_SECURE_PROTOCOL MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY
#endif
#if !defined(MBED_CONF_APP_WIFI_CH_SECURE)
#define MBED_CONF_APP_WIFI_CH_SECURE 1
#endif
#if !defined(MBED_CONF_APP_MAX_SCAN_SIZE)
#define MBED_CONF_APP_MAX_SCAN_SIZE 10
#endif
/** Get WiFiInterface based on provided
* app_json. */
WiFiInterface *get_interface(void);
@ -82,3 +103,4 @@ void wifi_scan_null(void);
void wifi_scan(void);
#endif //WIFI_TESTS_H
#endif // MBED_CONF_NSAPI_PRESENT