|
| 1 | +/* |
| 2 | + * Copyright (c) 2017, ARM Limited, All Rights Reserved |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | + * not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#include "mbed.h" |
| 19 | +#include "greentea-client/test_env.h" |
| 20 | +#include "unity.h" |
| 21 | +#include "utest.h" |
| 22 | +#include "wifi_tests.h" |
| 23 | + |
| 24 | +using namespace utest::v1; |
| 25 | + |
| 26 | +#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) |
| 27 | + |
| 28 | +void wifi_get_time(void) |
| 29 | +{ |
| 30 | + WiFiInterface *wifi = get_interface(); |
| 31 | + |
| 32 | + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security())); |
| 33 | + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect()); |
| 34 | + |
| 35 | + std::tm t = {}; |
| 36 | + nsapi_error_t ret = wifi->get_time(&t); |
| 37 | + if (ret == NSAPI_ERROR_UNSUPPORTED) { |
| 38 | + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect()); |
| 39 | + TEST_SKIP_MESSAGE("This device does not support get_time or it is not enabled"); |
| 40 | + } |
| 41 | + |
| 42 | + TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, ret); |
| 43 | + |
| 44 | + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect()); |
| 45 | +} |
| 46 | + |
| 47 | +#endif // defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) |
0 commit comments