Mistake on this page?
Report an issue in GitHub or email us
RdaWiFiInterface.h
1 /* LWIP implementation of NetworkInterfaceAPI
2  * Copyright (c) 2019 Unisoc Communications Inc.
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 RDA_WIFI_INTERFACE_H
19 #define RDA_WIFI_INTERFACE_H
20 
21 #include "nsapi.h"
22 #include "rtos.h"
23 #include "EMACInterface.h"
24 #include "WiFiInterface.h"
25 
26 
27 /** RDAWiFiInterface class
28  * Implementation of the NetworkStack for an EMAC-based Ethernet driver
29  */
31 {
32  public:
33  /** Create an EMAC-based ethernet interface.
34  *
35  * The default arguments obtain the default EMAC, which will be target-
36  * dependent (and the target may have some JSON option to choose which
37  * is the default, if there are multiple). The default stack is configured
38  * by JSON option nsapi.default-stack.
39  *
40  * Due to inability to return errors from the constructor, no real
41  * work is done until the first call to connect().
42  *
43  * @param emac Reference to EMAC to use
44  * @param stack Reference to onboard-network stack to use
45  */
49  _ssid[0] = '\0';
50  _pass[0] = '\0';
51  _channel = 0;
52  _security = NSAPI_SECURITY_NONE;
53  }
54 
55  //static RDAWiFiInterface *get_target_default_instance();
56 
57  /** Set the WiFi network credentials
58  *
59  * @param ssid Name of the network to connect to
60  * @param pass Security passphrase to connect to the network
61  * @param security Type of encryption for connection
62  * (defaults to NSAPI_SECURITY_NONE)
63  * @return 0 on success, or error code on failure
64  */
65  virtual nsapi_error_t set_credentials(const char *ssid, const char *pass,
67 
68  /** Set the WiFi network channel
69  *
70  * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
71  * @return 0 on success, or error code on failure
72  */
73  virtual nsapi_error_t set_channel(uint8_t channel);
74 
75  /** Gets the current radio signal strength for active connection
76  *
77  * @return Connection strength in dBm (negative value),
78  * or 0 if measurement impossible
79  */
80  virtual int8_t get_rssi();
81 
82  /** Start the interface
83  *
84  * Attempts to connect to a WiFi network.
85  *
86  * @param ssid Name of the network to connect to
87  * @param pass Security passphrase to connect to the network
88  * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
89  * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
90  * @return 0 on success, or error code on failure
91  */
92  virtual nsapi_error_t connect(const char *ssid, const char *pass,
93  nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
94 
95  /** Start the interface
96  *
97  * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
98  * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
99  *
100  * @return 0 on success, negative error code on failure
101  */
102  virtual nsapi_error_t connect();
103 
104  /** Stop the interface
105  *
106  * @return 0 on success, or error code on failure
107  */
108  virtual nsapi_error_t disconnect();
109 
110  /** Scan for available networks
111  *
112  * This function will block. If the @a count is 0, function will only return count of available networks, so that
113  * 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
114  * with discovered networks up to value of \p count.
115  *
116  * @param res Pointer to allocated array to store discovered AP
117  * @param count Size of allocated @a res array, or 0 to only count available AP
118  * @return Number of entries in \p count, or if \p count was 0 number of available networks,
119  * negative on error see @a nsapi_error
120  */
122 
123  virtual nsapi_size_or_error_t init();
124  private:
125  char _ssid[33];
126  char _pass[65];
127  uint8_t _channel;
128  nsapi_security_t _security;
129 
130 
131 };
132 
133 #endif
134 
135 
136 
137 
Common interface between Wi-Fi devices.
Definition: WiFiInterface.h:31
virtual nsapi_error_t connect()
Start the interface.
virtual nsapi_error_t set_channel(uint8_t channel)
Set the WiFi network channel.
EMACInterface class Implementation of the NetworkInterface for an EMAC-based driver.
Definition: EMACInterface.h:38
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:106
mbed OS API for onboard IP stack abstraction
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count)
Scan for available networks.
virtual int8_t get_rssi()
Gets the current radio signal strength for active connection.
static EMAC & get_default_instance()
Return the default on-board EMAC.
virtual nsapi_error_t disconnect()
Stop the interface.
virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE)
Set the WiFi network credentials.
RDAWiFiInterface(EMAC &emac=EMAC::get_default_instance(), OnboardNetworkStack &stack=OnboardNetworkStack::get_default_instance())
Create an EMAC-based ethernet interface.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:99
This interface should be used to abstract low level access to networking hardware All operations rece...
Definition: EMAC.h:32
enum nsapi_security nsapi_security_t
Enum of encryption types.
static OnboardNetworkStack & get_default_instance()
Return the default on-board network stack.
RDAWiFiInterface class Implementation of the NetworkStack for an EMAC-based Ethernet driver...
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.