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