Daniel Vizcaya
/
04_RTOS_Embebidos
Entrega 3er corte - sistemas embebidos
mbed-os/features/netsocket/WiFiInterface.h@0:6ad07c9019fd, 2018-05-30 (annotated)
- Committer:
- Bethory
- Date:
- Wed May 30 00:01:50 2018 +0000
- Revision:
- 0:6ad07c9019fd
Codigo de tales para todos los pasculaes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bethory | 0:6ad07c9019fd | 1 | |
Bethory | 0:6ad07c9019fd | 2 | /* WiFiInterface |
Bethory | 0:6ad07c9019fd | 3 | * Copyright (c) 2015 - 2016 ARM Limited |
Bethory | 0:6ad07c9019fd | 4 | * |
Bethory | 0:6ad07c9019fd | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Bethory | 0:6ad07c9019fd | 6 | * you may not use this file except in compliance with the License. |
Bethory | 0:6ad07c9019fd | 7 | * You may obtain a copy of the License at |
Bethory | 0:6ad07c9019fd | 8 | * |
Bethory | 0:6ad07c9019fd | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Bethory | 0:6ad07c9019fd | 10 | * |
Bethory | 0:6ad07c9019fd | 11 | * Unless required by applicable law or agreed to in writing, software |
Bethory | 0:6ad07c9019fd | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
Bethory | 0:6ad07c9019fd | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Bethory | 0:6ad07c9019fd | 14 | * See the License for the specific language governing permissions and |
Bethory | 0:6ad07c9019fd | 15 | * limitations under the License. |
Bethory | 0:6ad07c9019fd | 16 | */ |
Bethory | 0:6ad07c9019fd | 17 | |
Bethory | 0:6ad07c9019fd | 18 | #ifndef WIFI_INTERFACE_H |
Bethory | 0:6ad07c9019fd | 19 | #define WIFI_INTERFACE_H |
Bethory | 0:6ad07c9019fd | 20 | |
Bethory | 0:6ad07c9019fd | 21 | #include <string.h> |
Bethory | 0:6ad07c9019fd | 22 | #include "netsocket/NetworkInterface.h" |
Bethory | 0:6ad07c9019fd | 23 | #include "netsocket/WiFiAccessPoint.h" |
Bethory | 0:6ad07c9019fd | 24 | |
Bethory | 0:6ad07c9019fd | 25 | /** WiFiInterface class |
Bethory | 0:6ad07c9019fd | 26 | * |
Bethory | 0:6ad07c9019fd | 27 | * Common interface that is shared between WiFi devices |
Bethory | 0:6ad07c9019fd | 28 | * @addtogroup netsocket |
Bethory | 0:6ad07c9019fd | 29 | */ |
Bethory | 0:6ad07c9019fd | 30 | class WiFiInterface: public NetworkInterface |
Bethory | 0:6ad07c9019fd | 31 | { |
Bethory | 0:6ad07c9019fd | 32 | public: |
Bethory | 0:6ad07c9019fd | 33 | /** WiFiInterface lifetime |
Bethory | 0:6ad07c9019fd | 34 | */ |
Bethory | 0:6ad07c9019fd | 35 | virtual ~WiFiInterface() {}; |
Bethory | 0:6ad07c9019fd | 36 | |
Bethory | 0:6ad07c9019fd | 37 | /** Set the WiFi network credentials |
Bethory | 0:6ad07c9019fd | 38 | * |
Bethory | 0:6ad07c9019fd | 39 | * @param ssid Name of the network to connect to |
Bethory | 0:6ad07c9019fd | 40 | * @param pass Security passphrase to connect to the network |
Bethory | 0:6ad07c9019fd | 41 | * @param security Type of encryption for connection |
Bethory | 0:6ad07c9019fd | 42 | * (defaults to NSAPI_SECURITY_NONE) |
Bethory | 0:6ad07c9019fd | 43 | * @return 0 on success, or error code on failure |
Bethory | 0:6ad07c9019fd | 44 | */ |
Bethory | 0:6ad07c9019fd | 45 | virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, |
Bethory | 0:6ad07c9019fd | 46 | nsapi_security_t security = NSAPI_SECURITY_NONE) = 0; |
Bethory | 0:6ad07c9019fd | 47 | |
Bethory | 0:6ad07c9019fd | 48 | /** Set the WiFi network channel |
Bethory | 0:6ad07c9019fd | 49 | * |
Bethory | 0:6ad07c9019fd | 50 | * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) |
Bethory | 0:6ad07c9019fd | 51 | * @return 0 on success, or error code on failure |
Bethory | 0:6ad07c9019fd | 52 | */ |
Bethory | 0:6ad07c9019fd | 53 | virtual nsapi_error_t set_channel(uint8_t channel) = 0; |
Bethory | 0:6ad07c9019fd | 54 | |
Bethory | 0:6ad07c9019fd | 55 | /** Gets the current radio signal strength for active connection |
Bethory | 0:6ad07c9019fd | 56 | * |
Bethory | 0:6ad07c9019fd | 57 | * @return Connection strength in dBm (negative value), |
Bethory | 0:6ad07c9019fd | 58 | * or 0 if measurement impossible |
Bethory | 0:6ad07c9019fd | 59 | */ |
Bethory | 0:6ad07c9019fd | 60 | virtual int8_t get_rssi() = 0; |
Bethory | 0:6ad07c9019fd | 61 | |
Bethory | 0:6ad07c9019fd | 62 | /** Start the interface |
Bethory | 0:6ad07c9019fd | 63 | * |
Bethory | 0:6ad07c9019fd | 64 | * Attempts to connect to a WiFi network. |
Bethory | 0:6ad07c9019fd | 65 | * |
Bethory | 0:6ad07c9019fd | 66 | * @param ssid Name of the network to connect to |
Bethory | 0:6ad07c9019fd | 67 | * @param pass Security passphrase to connect to the network |
Bethory | 0:6ad07c9019fd | 68 | * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) |
Bethory | 0:6ad07c9019fd | 69 | * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) |
Bethory | 0:6ad07c9019fd | 70 | * @return 0 on success, or error code on failure |
Bethory | 0:6ad07c9019fd | 71 | */ |
Bethory | 0:6ad07c9019fd | 72 | virtual nsapi_error_t connect(const char *ssid, const char *pass, |
Bethory | 0:6ad07c9019fd | 73 | nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0) = 0; |
Bethory | 0:6ad07c9019fd | 74 | |
Bethory | 0:6ad07c9019fd | 75 | /** Start the interface |
Bethory | 0:6ad07c9019fd | 76 | * |
Bethory | 0:6ad07c9019fd | 77 | * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. |
Bethory | 0:6ad07c9019fd | 78 | * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. |
Bethory | 0:6ad07c9019fd | 79 | * |
Bethory | 0:6ad07c9019fd | 80 | * @return 0 on success, negative error code on failure |
Bethory | 0:6ad07c9019fd | 81 | */ |
Bethory | 0:6ad07c9019fd | 82 | virtual nsapi_error_t connect() = 0; |
Bethory | 0:6ad07c9019fd | 83 | |
Bethory | 0:6ad07c9019fd | 84 | /** Stop the interface |
Bethory | 0:6ad07c9019fd | 85 | * |
Bethory | 0:6ad07c9019fd | 86 | * @return 0 on success, or error code on failure |
Bethory | 0:6ad07c9019fd | 87 | */ |
Bethory | 0:6ad07c9019fd | 88 | virtual nsapi_error_t disconnect() = 0; |
Bethory | 0:6ad07c9019fd | 89 | |
Bethory | 0:6ad07c9019fd | 90 | /** Scan for available networks |
Bethory | 0:6ad07c9019fd | 91 | * |
Bethory | 0:6ad07c9019fd | 92 | * This function will block. If the @a count is 0, function will only return count of available networks, so that |
Bethory | 0:6ad07c9019fd | 93 | * user can allocated necessary memory. If the \p count is grater than 0 and the a \p res is not NULL it'll be populated |
Bethory | 0:6ad07c9019fd | 94 | * with discovered networks up to value of \p count. |
Bethory | 0:6ad07c9019fd | 95 | * |
Bethory | 0:6ad07c9019fd | 96 | * @param res Pointer to allocated array to store discovered AP |
Bethory | 0:6ad07c9019fd | 97 | * @param count Size of allocated @a res array, or 0 to only count available AP |
Bethory | 0:6ad07c9019fd | 98 | * @return Number of entries in \p count, or if \p count was 0 number of available networks, |
Bethory | 0:6ad07c9019fd | 99 | * negative on error see @a nsapi_error |
Bethory | 0:6ad07c9019fd | 100 | */ |
Bethory | 0:6ad07c9019fd | 101 | virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0; |
Bethory | 0:6ad07c9019fd | 102 | }; |
Bethory | 0:6ad07c9019fd | 103 | |
Bethory | 0:6ad07c9019fd | 104 | #endif |
Bethory | 0:6ad07c9019fd | 105 | |
Bethory | 0:6ad07c9019fd | 106 | /** @}*/ |