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

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.