2017-10-04 14:45:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017, ARM Limited, All Rights Reserved
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-08-16 07:08:50 +00:00
|
|
|
#define WIFI 2
|
|
|
|
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
|
|
|
|
MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE != WIFI
|
|
|
|
#error [NOT_SUPPORTED] No network configuration found for this target.
|
2018-05-04 09:23:55 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-26 16:21:08 +00:00
|
|
|
#include "mbed.h"
|
2017-09-19 17:16:36 +00:00
|
|
|
#include "greentea-client/test_env.h"
|
|
|
|
#include "unity.h"
|
|
|
|
#include "utest.h"
|
|
|
|
#include "wifi_tests.h"
|
2016-10-28 12:57:49 +00:00
|
|
|
|
2017-10-03 09:50:03 +00:00
|
|
|
// Test for parameters
|
2017-11-21 12:42:51 +00:00
|
|
|
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
2017-10-03 09:50:03 +00:00
|
|
|
#if !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_WIFI_PASSWORD) || \
|
|
|
|
!defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \
|
2017-12-22 10:54:22 +00:00
|
|
|
!defined MBED_CONF_APP_WIFI_SECURE_PROTOCOL
|
2017-11-21 12:42:51 +00:00
|
|
|
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for secure connections)
|
|
|
|
#endif
|
|
|
|
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
|
|
|
|
|
|
|
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
|
|
|
#if !defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \
|
|
|
|
!defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \
|
|
|
|
!defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \
|
2017-10-03 09:50:03 +00:00
|
|
|
!defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
2017-11-21 12:42:51 +00:00
|
|
|
#error [NOT_SUPPORTED] Requires parameters from mbed_app.json (for unsecure connections)
|
2017-10-03 09:50:03 +00:00
|
|
|
#endif
|
2017-11-21 12:42:51 +00:00
|
|
|
#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
2017-10-03 09:50:03 +00:00
|
|
|
|
2016-10-26 16:21:08 +00:00
|
|
|
using namespace utest::v1;
|
|
|
|
|
2018-07-27 09:17:07 +00:00
|
|
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
|
|
|
{
|
2019-02-14 12:07:55 +00:00
|
|
|
#ifdef MBED_GREENTEA_TEST_WIFI_TIMEOUT_S
|
|
|
|
GREENTEA_SETUP(MBED_GREENTEA_TEST_WIFI_TIMEOUT_S, "default_auto");
|
|
|
|
#else
|
2019-02-07 16:10:02 +00:00
|
|
|
GREENTEA_SETUP(360, "default_auto");
|
2019-02-14 12:07:55 +00:00
|
|
|
#endif
|
2017-09-19 17:16:36 +00:00
|
|
|
return verbose_test_setup_handler(number_of_cases);
|
2016-10-26 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 17:16:36 +00:00
|
|
|
// Test cases
|
2016-10-26 16:21:08 +00:00
|
|
|
Case cases[] = {
|
2017-09-19 17:16:36 +00:00
|
|
|
Case("WIFI-CONSTRUCTOR", wifi_constructor),
|
2017-12-18 13:11:59 +00:00
|
|
|
Case("WIFI-CONNECT-NOCREDENTIALS", wifi_connect_nocredentials),
|
2017-09-19 17:16:36 +00:00
|
|
|
Case("WIFI-SET-CREDENTIAL", wifi_set_credential),
|
|
|
|
Case("WIFI-SET-CHANNEL", wifi_set_channel),
|
|
|
|
Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null),
|
2018-11-24 10:28:14 +00:00
|
|
|
Case("WIFI-SCAN-NULL", wifi_scan_null),
|
|
|
|
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) || defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
|
|
|
Case("WIFI-SCAN", wifi_scan),
|
|
|
|
#endif
|
2017-11-21 12:42:51 +00:00
|
|
|
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
2018-11-24 10:28:14 +00:00
|
|
|
Case("WIFI-GET-RSSI", wifi_get_rssi),
|
2017-09-19 17:16:36 +00:00
|
|
|
Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure),
|
2018-11-24 10:28:14 +00:00
|
|
|
Case("WIFI-CONNECT", wifi_connect),
|
|
|
|
Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
|
2017-11-21 12:42:51 +00:00
|
|
|
#endif
|
|
|
|
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
2017-09-19 17:16:36 +00:00
|
|
|
Case("WIFI-CONNECT-PARAMS-VALID-SECURE", wifi_connect_params_valid_secure),
|
|
|
|
Case("WIFI-CONNECT-PARAMS-CHANNEL", wifi_connect_params_channel),
|
|
|
|
Case("WIFI-CONNECT-PARAMS-CHANNEL-FAIL", wifi_connect_params_channel_fail),
|
|
|
|
Case("WIFI-CONNECT-SECURE", wifi_connect_secure),
|
|
|
|
Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail),
|
2017-11-21 12:42:51 +00:00
|
|
|
#endif
|
2016-10-26 16:21:08 +00:00
|
|
|
};
|
|
|
|
|
2018-10-23 10:58:21 +00:00
|
|
|
Specification specification(test_setup, cases, greentea_continue_handlers);
|
2016-10-26 16:21:08 +00:00
|
|
|
|
2017-09-19 17:16:36 +00:00
|
|
|
// Entry point into the tests
|
2018-07-27 09:17:07 +00:00
|
|
|
int main()
|
|
|
|
{
|
2017-09-19 17:16:36 +00:00
|
|
|
return !Harness::run(specification);
|
2016-10-26 16:21:08 +00:00
|
|
|
}
|