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