Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_IKS01A1 mbed FP MQTTPacket DnsQuery ATParser
NetworkSocketAPI/WiFiInterface.h@0:4cdaf9b1e7d0, 2017-09-27 (annotated)
- Committer:
- PavelSavyhin
- Date:
- Wed Sep 27 14:40:52 2017 +0300
- Revision:
- 0:4cdaf9b1e7d0
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| PavelSavyhin | 0:4cdaf9b1e7d0 | 1 | /* WiFiInterface |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 2 | * Copyright (c) 2015 ARM Limited |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 3 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 5 | * you may not use this file except in compliance with the License. |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 6 | * You may obtain a copy of the License at |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 7 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 9 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 10 | * Unless required by applicable law or agreed to in writing, software |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 13 | * See the License for the specific language governing permissions and |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 14 | * limitations under the License. |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 15 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 16 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 17 | #ifndef WIFI_INTERFACE_H |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 18 | #define WIFI_INTERFACE_H |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 19 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 20 | #include "NetworkStack.h" |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 21 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 22 | /** Enum of WiFi encryption types |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 23 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 24 | * The security type specifies a particular security to use when |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 25 | * connected to a WiFi network |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 26 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 27 | * @enum nsapi_protocol_t |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 28 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 29 | enum nsapi_security_t { |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 30 | NSAPI_SECURITY_NONE = 0, /*!< open access point */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 31 | NSAPI_SECURITY_WEP, /*!< phrase conforms to WEP */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 32 | NSAPI_SECURITY_WPA, /*!< phrase conforms to WPA */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 33 | NSAPI_SECURITY_WPA2, /*!< phrase conforms to WPA2 */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 34 | }; |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 35 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 36 | /** WiFiInterface class |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 37 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 38 | * Common interface that is shared between WiFi devices |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 39 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 40 | class WiFiInterface |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 41 | { |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 42 | public: |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 43 | /** Start the interface |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 44 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 45 | * Attempts to connect to a WiFi network. If passphrase is invalid, |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 46 | * NSAPI_ERROR_AUTH_ERROR is returned. |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 47 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 48 | * @param ssid Name of the network to connect to |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 49 | * @param pass Security passphrase to connect to the network |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 50 | * @param security Type of encryption for connection |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 51 | * @return 0 on success, negative error code on failure |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 52 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 53 | virtual int connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE) = 0; |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 54 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 55 | /** Stop the interface |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 56 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 57 | * @return 0 on success, negative error code on failure |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 58 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 59 | virtual int disconnect() = 0; |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 60 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 61 | /** Get the local MAC address |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 62 | * |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 63 | * @return Null-terminated representation of the local MAC address |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 64 | */ |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 65 | virtual const char *get_mac_address() = 0; |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 66 | }; |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 67 | |
| PavelSavyhin | 0:4cdaf9b1e7d0 | 68 | #endif |