RTC auf true
features/netsocket/WiFiInterface.h@0:38ceb79fef03, 2018-11-28 (annotated)
- Committer:
- kevman
- Date:
- Wed Nov 28 15:10:15 2018 +0000
- Revision:
- 0:38ceb79fef03
RTC modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | |
kevman | 0:38ceb79fef03 | 2 | /* WiFiInterface |
kevman | 0:38ceb79fef03 | 3 | * Copyright (c) 2015 - 2016 ARM Limited |
kevman | 0:38ceb79fef03 | 4 | * |
kevman | 0:38ceb79fef03 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kevman | 0:38ceb79fef03 | 6 | * you may not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 7 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 8 | * |
kevman | 0:38ceb79fef03 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 10 | * |
kevman | 0:38ceb79fef03 | 11 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
kevman | 0:38ceb79fef03 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 14 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 15 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 16 | */ |
kevman | 0:38ceb79fef03 | 17 | |
kevman | 0:38ceb79fef03 | 18 | #ifndef WIFI_INTERFACE_H |
kevman | 0:38ceb79fef03 | 19 | #define WIFI_INTERFACE_H |
kevman | 0:38ceb79fef03 | 20 | |
kevman | 0:38ceb79fef03 | 21 | #include <string.h> |
kevman | 0:38ceb79fef03 | 22 | #include "netsocket/NetworkInterface.h" |
kevman | 0:38ceb79fef03 | 23 | #include "netsocket/WiFiAccessPoint.h" |
kevman | 0:38ceb79fef03 | 24 | |
kevman | 0:38ceb79fef03 | 25 | /** Common interface that is shared between Wi-Fi devices. |
kevman | 0:38ceb79fef03 | 26 | * |
kevman | 0:38ceb79fef03 | 27 | * @addtogroup netsocket |
kevman | 0:38ceb79fef03 | 28 | */ |
kevman | 0:38ceb79fef03 | 29 | class WiFiInterface: public virtual NetworkInterface { |
kevman | 0:38ceb79fef03 | 30 | public: |
kevman | 0:38ceb79fef03 | 31 | /** Get the default Wi-Fi interface. |
kevman | 0:38ceb79fef03 | 32 | * |
kevman | 0:38ceb79fef03 | 33 | * This is provided as a weak method so applications can override. |
kevman | 0:38ceb79fef03 | 34 | * Default behaviour is to get the target's default interface, if |
kevman | 0:38ceb79fef03 | 35 | * any. |
kevman | 0:38ceb79fef03 | 36 | * |
kevman | 0:38ceb79fef03 | 37 | * @return pointer to interface, if any. |
kevman | 0:38ceb79fef03 | 38 | */ |
kevman | 0:38ceb79fef03 | 39 | static WiFiInterface *get_default_instance(); |
kevman | 0:38ceb79fef03 | 40 | |
kevman | 0:38ceb79fef03 | 41 | /** Set the Wi-Fi network credentials. |
kevman | 0:38ceb79fef03 | 42 | * |
kevman | 0:38ceb79fef03 | 43 | * @param ssid Name of the network to connect to. |
kevman | 0:38ceb79fef03 | 44 | * @param pass Security passphrase to connect to the network. |
kevman | 0:38ceb79fef03 | 45 | * @param security Type of encryption for connection |
kevman | 0:38ceb79fef03 | 46 | * (defaults to NSAPI_SECURITY_NONE). |
kevman | 0:38ceb79fef03 | 47 | * @return NSAPI_ERROR_OK on success, or error code on failure. |
kevman | 0:38ceb79fef03 | 48 | */ |
kevman | 0:38ceb79fef03 | 49 | virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, |
kevman | 0:38ceb79fef03 | 50 | nsapi_security_t security = NSAPI_SECURITY_NONE) = 0; |
kevman | 0:38ceb79fef03 | 51 | |
kevman | 0:38ceb79fef03 | 52 | /** Set the Wi-Fi network channel. |
kevman | 0:38ceb79fef03 | 53 | * |
kevman | 0:38ceb79fef03 | 54 | * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0). |
kevman | 0:38ceb79fef03 | 55 | * @return NSAPI_ERROR_OK on success, or error code on failure. |
kevman | 0:38ceb79fef03 | 56 | */ |
kevman | 0:38ceb79fef03 | 57 | virtual nsapi_error_t set_channel(uint8_t channel) = 0; |
kevman | 0:38ceb79fef03 | 58 | |
kevman | 0:38ceb79fef03 | 59 | /** Get the current radio signal strength for active connection. |
kevman | 0:38ceb79fef03 | 60 | * |
kevman | 0:38ceb79fef03 | 61 | * @return Connection strength in dBm (negative value), |
kevman | 0:38ceb79fef03 | 62 | * or 0 if measurement impossible. |
kevman | 0:38ceb79fef03 | 63 | */ |
kevman | 0:38ceb79fef03 | 64 | virtual int8_t get_rssi() = 0; |
kevman | 0:38ceb79fef03 | 65 | |
kevman | 0:38ceb79fef03 | 66 | /** Attempt to connect to a Wi-Fi network. |
kevman | 0:38ceb79fef03 | 67 | * |
kevman | 0:38ceb79fef03 | 68 | * @param ssid Name of the network to connect to. |
kevman | 0:38ceb79fef03 | 69 | * @param pass Security passphrase to connect to the network. |
kevman | 0:38ceb79fef03 | 70 | * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE). |
kevman | 0:38ceb79fef03 | 71 | * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0). |
kevman | 0:38ceb79fef03 | 72 | * @return NSAPI_ERROR_OK on success, or error code on failure. |
kevman | 0:38ceb79fef03 | 73 | */ |
kevman | 0:38ceb79fef03 | 74 | virtual nsapi_error_t connect(const char *ssid, const char *pass, |
kevman | 0:38ceb79fef03 | 75 | nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0) = 0; |
kevman | 0:38ceb79fef03 | 76 | |
kevman | 0:38ceb79fef03 | 77 | /** Attempt to connect to a Wi-Fi network. Requires ssid and passphrase to be set. |
kevman | 0:38ceb79fef03 | 78 | * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. |
kevman | 0:38ceb79fef03 | 79 | * |
kevman | 0:38ceb79fef03 | 80 | * @return NSAPI_ERROR_OK on success, negative error code on failure. |
kevman | 0:38ceb79fef03 | 81 | */ |
kevman | 0:38ceb79fef03 | 82 | virtual nsapi_error_t connect() = 0; |
kevman | 0:38ceb79fef03 | 83 | |
kevman | 0:38ceb79fef03 | 84 | /** Stop the interface. |
kevman | 0:38ceb79fef03 | 85 | * |
kevman | 0:38ceb79fef03 | 86 | * @return NSAPI_ERROR_OK on success, or error code on failure. |
kevman | 0:38ceb79fef03 | 87 | */ |
kevman | 0:38ceb79fef03 | 88 | virtual nsapi_error_t disconnect() = 0; |
kevman | 0:38ceb79fef03 | 89 | |
kevman | 0:38ceb79fef03 | 90 | /** Scan for available networks. |
kevman | 0:38ceb79fef03 | 91 | * |
kevman | 0:38ceb79fef03 | 92 | * This function will block. If the count is 0, function will only return count of available networks, so that |
kevman | 0:38ceb79fef03 | 93 | * user can allocated necessary memory. If the count is grater than 0 and the a \p res is not NULL it'll be populated |
kevman | 0:38ceb79fef03 | 94 | * with discovered networks up to value of count. |
kevman | 0:38ceb79fef03 | 95 | * |
kevman | 0:38ceb79fef03 | 96 | * @param res Pointer to allocated array to store discovered APs. |
kevman | 0:38ceb79fef03 | 97 | * @param count Size of allocated res array, or 0 to only count available APs. |
kevman | 0:38ceb79fef03 | 98 | * @return Number of entries in res, or if count was 0 number of available networks. |
kevman | 0:38ceb79fef03 | 99 | * Negative on error (@see nsapi_types.h for nsapi_error). |
kevman | 0:38ceb79fef03 | 100 | */ |
kevman | 0:38ceb79fef03 | 101 | virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0; |
kevman | 0:38ceb79fef03 | 102 | |
kevman | 0:38ceb79fef03 | 103 | /** @copydoc NetworkInterface::wifiInterface |
kevman | 0:38ceb79fef03 | 104 | */ |
kevman | 0:38ceb79fef03 | 105 | virtual WiFiInterface *wifiInterface() |
kevman | 0:38ceb79fef03 | 106 | { |
kevman | 0:38ceb79fef03 | 107 | return this; |
kevman | 0:38ceb79fef03 | 108 | } |
kevman | 0:38ceb79fef03 | 109 | |
kevman | 0:38ceb79fef03 | 110 | #if !defined(DOXYGEN_ONLY) |
kevman | 0:38ceb79fef03 | 111 | protected: |
kevman | 0:38ceb79fef03 | 112 | |
kevman | 0:38ceb79fef03 | 113 | /** Get the target's default Wi-Fi interface. |
kevman | 0:38ceb79fef03 | 114 | * |
kevman | 0:38ceb79fef03 | 115 | * This is provided as a weak method so targets can override. The |
kevman | 0:38ceb79fef03 | 116 | * default implementation returns NULL. |
kevman | 0:38ceb79fef03 | 117 | * |
kevman | 0:38ceb79fef03 | 118 | * @return pointer to interface, if any. |
kevman | 0:38ceb79fef03 | 119 | */ |
kevman | 0:38ceb79fef03 | 120 | static WiFiInterface *get_target_default_instance(); |
kevman | 0:38ceb79fef03 | 121 | #endif //!defined(DOXYGEN_ONLY) |
kevman | 0:38ceb79fef03 | 122 | }; |
kevman | 0:38ceb79fef03 | 123 | |
kevman | 0:38ceb79fef03 | 124 | #endif |
kevman | 0:38ceb79fef03 | 125 | |
kevman | 0:38ceb79fef03 | 126 | /** @}*/ |