Mistake on this page?
Report an issue in GitHub or email us
WicedInterface.h
1 /* Wiced implementation of NetworkInterfaceAPI
2  * Copyright (c) 2017 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
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 WICED_INTERFACE_H
19 #define WICED_INTERFACE_H
20 
21 #if defined(MBED_CONF_NSAPI_PRESENT)
22 
23 #include "mbed.h"
24 #include "EthernetInterface.h"
25 #include "netsocket/OnboardNetworkStack.h"
26 #include "wiced_emac.h"
27 
28 
29 /** WicedInterface class
30  * Implementation of the NetworkStack for the Wiced
31  */
32 class WicedInterface : public WiFiInterface, public EMACInterface {
33 public:
34 
35  WicedInterface(
36  EMAC &emac = WICED_EMAC::get_instance(),
38 
39  /** Start the interface
40  *
41  * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
42  * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
43  *
44  * @return 0 on success, negative error code on failure
45  */
47 
48  /** Start the interface
49  *
50  * Attempts to connect to a WiFi network.
51  *
52  * @param ssid Name of the network to connect to
53  * @param pass Security passphrase to connect to the network
54  * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
55  * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED
56  * @return 0 on success, or error code on failure
57  */
58  nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
59 
60  /** Stop the interface
61  * @return 0 on success, negative on failure
62  */
64 
65  /** Set the WiFi network credentials
66  *
67  * @param ssid Name of the network to connect to
68  * @param pass Security passphrase to connect to the network
69  * @param security Type of encryption for connection
70  * (defaults to NSAPI_SECURITY_NONE)
71  * @return 0 on success, or error code on failure
72  */
73  nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE);
74 
75  /** Set the WiFi network channel - NOT SUPPORTED
76  *
77  * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED
78  *
79  * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
80  * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED
81  */
82  nsapi_error_t set_channel(uint8_t channel)
83  {
84  if (channel != 0) {
86  }
87 
88  return 0;
89  }
90 
91  /** Gets the current radio signal strength for active connection
92  *
93  * @return Connection strength in dBm (negative value)
94  */
95  int8_t get_rssi();
96 
97  /** Scan for available networks
98  *
99  * This function will block.
100  *
101  * @param ap Pointer to allocated array to store discovered AP
102  * @param count Size of allocated @a res array, or 0 to only count available AP
103  * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
104  * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
105  * see @a nsapi_error
106  */
107  int scan(WiFiAccessPoint *res, unsigned count);
108 
109 private:
110 
111  char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */
112  char _pass[64]; /* The longest allowed passphrase + 1 */
113  nsapi_security_t _security;
114 };
115 
116 #endif
117 
118 #endif
Common interface between Wi-Fi devices.
Definition: WiFiInterface.h:32
nsapi_error_t disconnect() override
Disconnect from the network.
virtual nsapi_error_t set_channel(uint8_t channel)=0
Set the Wi-Fi network channel.
EMACInterface class Implementation of the NetworkInterface for an EMAC-based driver.
Definition: EMACInterface.h:39
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
nsapi_error_t connect() override
Connect to a network.
virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE)=0
Set the Wi-Fi network credentials.
mbed OS API for onboard IP stack abstraction
virtual int8_t get_rssi()=0
Get the current radio signal strength for active connection.
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count)=0
Scan for available networks.
This interface should be used to abstract low level access to networking hardware All operations rece...
Definition: EMAC.h:33
enum nsapi_security nsapi_security_t
Enum of encryption types.
static OnboardNetworkStack & get_default_instance()
Return the default on-board network stack.
WiFiAccessPoint class.
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.