Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
wifi_set_channel.cpp
00001 /* 00002 * Copyright (c) 2017, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "greentea-client/test_env.h" 00020 #include "unity.h" 00021 #include "utest.h" 00022 #include "wifi_tests.h" 00023 #include <stdbool.h> 00024 00025 using namespace utest::v1; 00026 00027 void wifi_set_channel(void) 00028 { 00029 bool is_2Ghz = false; 00030 bool is_5Ghz = false; 00031 00032 WiFiInterface *wifi = get_interface(); 00033 00034 if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED ) { 00035 TEST_IGNORE_MESSAGE("set_channel() not supported"); 00036 return; 00037 } 00038 00039 nsapi_error_t error; 00040 error = wifi->set_channel(1); 00041 if (error == NSAPI_ERROR_OK ) { 00042 is_2Ghz = true; 00043 } 00044 00045 error = wifi->set_channel(30); 00046 if (error == NSAPI_ERROR_OK ) { 00047 is_5Ghz = true; 00048 } 00049 00050 TEST_ASSERT(is_2Ghz || is_5Ghz); 00051 00052 if (is_2Ghz) { 00053 error = wifi->set_channel(0); 00054 TEST_ASSERT(error == NSAPI_ERROR_PARAMETER ); 00055 error = wifi->set_channel(1); 00056 TEST_ASSERT(error == NSAPI_ERROR_OK ); 00057 error = wifi->set_channel(13); 00058 TEST_ASSERT(error == NSAPI_ERROR_OK || error == NSAPI_ERROR_PARAMETER ); 00059 error = wifi->set_channel(15); 00060 TEST_ASSERT(error == NSAPI_ERROR_PARAMETER ); 00061 } 00062 00063 if (is_5Ghz) { 00064 error = wifi->set_channel(30); 00065 TEST_ASSERT(error == NSAPI_ERROR_PARAMETER ); 00066 error = wifi->set_channel(36); 00067 TEST_ASSERT(error == NSAPI_ERROR_OK ); 00068 error = wifi->set_channel(169); 00069 TEST_ASSERT(error == NSAPI_ERROR_PARAMETER ); 00070 } 00071 00072 } 00073
Generated on Fri Jul 22 2022 04:54:05 by
1.7.2
