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