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.
Dependents: blinky_max32630fthr
WiFiInterface.h
00001 00002 /** \addtogroup netsocket */ 00003 /** @{*/ 00004 /* WiFiInterface 00005 * Copyright (c) 2015 - 2016 ARM Limited 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); 00008 * you may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 */ 00019 00020 #ifndef WIFI_INTERFACE_H 00021 #define WIFI_INTERFACE_H 00022 00023 #include <string.h> 00024 #include "Callback.h" 00025 #include "netsocket/NetworkInterface.h" 00026 #include "netsocket/WiFiAccessPoint.h" 00027 00028 /** WiFiInterface class 00029 * 00030 * Common interface that is shared between WiFi devices 00031 */ 00032 class WiFiInterface: public NetworkInterface 00033 { 00034 public: 00035 /** WiFiInterface lifetime 00036 */ 00037 virtual ~WiFiInterface() {}; 00038 00039 /** Set the WiFi network credentials 00040 * 00041 * @param ssid Name of the network to connect to 00042 * @param pass Security passphrase to connect to the network 00043 * @param security Type of encryption for connection 00044 * (defaults to NSAPI_SECURITY_NONE) 00045 * @return 0 on success, or error code on failure 00046 */ 00047 virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, 00048 nsapi_security_t security = NSAPI_SECURITY_NONE ) = 0; 00049 00050 /** Set the WiFi network channel 00051 * 00052 * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) 00053 * @return 0 on success, or error code on failure 00054 */ 00055 virtual nsapi_error_t set_channel(uint8_t channel) = 0; 00056 00057 /** Gets the current radio signal strength for active connection 00058 * 00059 * @return Connection strength in dBm (negative value), 00060 * or 0 if measurement impossible 00061 */ 00062 virtual int8_t get_rssi() = 0; 00063 00064 /** Start the interface 00065 * 00066 * Attempts to connect to a WiFi network. 00067 * 00068 * @param ssid Name of the network to connect to 00069 * @param pass Security passphrase to connect to the network 00070 * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) 00071 * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) 00072 * @return 0 on success, or error code on failure 00073 */ 00074 virtual nsapi_error_t connect(const char *ssid, const char *pass, 00075 nsapi_security_t security = NSAPI_SECURITY_NONE , uint8_t channel = 0) = 0; 00076 00077 /** Start the interface 00078 * 00079 * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. 00080 * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. 00081 * 00082 * @return 0 on success, negative error code on failure 00083 */ 00084 virtual nsapi_error_t connect() = 0; 00085 00086 /** Stop the interface 00087 * 00088 * @return 0 on success, or error code on failure 00089 */ 00090 virtual nsapi_error_t disconnect() = 0; 00091 00092 /** Scan for available networks 00093 * 00094 * The scan will 00095 * If the network interface is set to non-blocking mode, scan will attempt to scan 00096 * for WiFi networks asynchronously and return NSAPI_ERROR_WOULD_BLOCK. If a callback 00097 * is attached, the callback will be called when the operation has completed. 00098 * 00099 * @param ap Pointer to allocated array to store discovered AP 00100 * @param count Size of allocated @a res array, or 0 to only count available AP 00101 * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) 00102 * @return Number of entries in @a, or if @a count was 0 number of available networks, 00103 * negative on error 00104 * see @a nsapi_error 00105 */ 00106 virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0; 00107 }; 00108 00109 #endif 00110 00111 /** @}*/
Generated on Tue Jul 12 2022 14:21:25 by
