Mistake on this page?
Report an issue in GitHub or email us
WhdSoftAPInterface.h
1 /*
2  * Copyright (c) 2018-2019 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 
19 #ifndef WHD_SOFTAP_INTERFACE_H
20 #define WHD_SOFTAP_INTERFACE_H
21 
22 #include "netsocket/EMACInterface.h"
23 #include "netsocket/OnboardNetworkStack.h"
24 #include "whd_emac.h"
25 #include "CyDhcpServer.h"
26 #include "whd_interface.h"
27 #include <memory>
28 
29 /**
30  * Vendor IE details
31  */
32 typedef struct {
33  uint8_t oui[WIFI_IE_OUI_LENGTH]; /**< Unique identifier for the IE */
34  uint8_t subtype; /**< Sub-type of the IE */
35  void *data; /**< Pointer to IE data */
36  uint16_t length; /**< IE data length */
37  uint16_t which_packets; /**< Mask of the packet in which this IE details to be included */
39 
40 
41 
42 /** WhdSoftAPInterface class
43  * Implementation of the SoftAPInterface for the Whd
44  */
46 public:
47  /** Construct SoftAP interface
48  * @return pointer to default WhdSoftAPInterface instance
49  */
50  WhdSoftAPInterface(WHD_EMAC &emac = WHD_EMAC::get_instance(WHD_AP_ROLE),
52  whd_interface_shared_info_t &shared = whd_iface_shared);
53 
54  /** Get the default WhdSoftAPInterface instance.
55  * @return pointer to default WhdSoftAPInterface instance
56  */
58 
59  /** Set static IP address for SoftAP
60  *
61  * Configures the static IP address of SoftAP
62  * Requires that the network is stopped.
63  *
64  * @param ip_address Null-terminated representation of the local IP address
65  * @param netmask Null-terminated representation of the local network mask
66  * @param gateway Null-terminated representation of the local gateway
67  * @return 0 on success, negative error code on failure
68  * int set_network(const char *ip_address, const char *netmask, const char *gateway);
69  */
70 
71  /** Start a SoftAP
72  *
73  * @param ssid Name of the SoftAP to create
74  * @param pass Security passphrase for connection to SoftAP
75  * @param security Type of encryption for connection
76  * @param channel Channel for SoftAP
77  * @param start_dhcp_server Start dhcp server for connection
78  * @param whd_custom_ie Optional Custom IE
79  * @param ap_sta_concur Enable STA+AP concurrency mode
80  *
81  * @return 0 on success, or error code on failure
82  * see @a nsapi_error
83  */
84  int start(const char *ssid, const char *pass, nsapi_security_t security, uint8_t channel,
85  bool start_dhcp_server = true, const whd_custom_ie_info_t *ie_info = NULL, bool ap_sta_concur = false);
86 
87  /**
88  * Remove Wi-Fi custom IE
89  *
90  * @param[in] ie_info : Pointer to the structure which contains custom IE information
91  *
92  * @return 0 on success, or error code on failure
93  * see @a nsapi_error
94  */
95  int remove_custom_ie(const whd_custom_ie_info_t *ie_info);
96 
97  /** Stop the Software Access Point
98  *
99  * @return 0 on success, or error code on failure
100  * see @a nsapi_error
101  */
102  int stop(void);
103 
104  /**
105  * Gets information about associated clients.
106  *
107  * @note Only applicable if softAP interface is up
108  *
109  * @param[out] client_list_buffer : pointer to a buffer that will be populated with a variable length structure defined by @ref whd_maclist_t
110  * @param[in] buffer_length : length of the buffer
111  *
112  * @return 0 on success, or error code on failure
113  * see @a nsapi_error
114  */
115  int get_associated_client_list(void *client_list_buffer, uint16_t buffer_length);
116 
117 
118  /**
119  * Register soft AP event handler
120  *
121  * @param[in] softap_event_handler : A function pointer to the event handler
122  *
123  * @return 0 on success, or error code on failure
124  * see @a nsapi_error
125  */
126  int register_event_handler(whd_event_handler_t softap_event_handler);
127 
128  /**
129  * Unregister soft AP event handler
130  *
131  * @return 0 on success, or error code on failure
132  * see @a nsapi_error
133  */
134  int unregister_event_handler(void);
135 
136  /** Set blocking status of interface.
137  * Nonblocking mode unsupported.
138  *
139  * @param blocking true if connect is blocking
140  * @return 0 on success, negative error code on failure
141  */
143  {
144  if (blocking) {
145  _blocking = blocking;
146  return NSAPI_ERROR_OK;
147  } else {
149  }
150  }
151 
152 protected:
153  WHD_EMAC &_whd_emac;
154  std::unique_ptr<CyDhcpServer> _dhcp_server;
155  whd_interface_shared_info_t &_iface_shared;
156 };
157 
158 #endif
int register_event_handler(whd_event_handler_t softap_event_handler)
Register soft AP event handler.
uint16_t length
IE data length.
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 set_blocking(bool blocking)
Set blocking status of interface.
uint16_t which_packets
Mask of the packet in which this IE details to be included.
int unregister_event_handler(void)
Unregister soft AP event handler.
Vendor IE details.
mbed OS API for onboard IP stack abstraction
int remove_custom_ie(const whd_custom_ie_info_t *ie_info)
Remove Wi-Fi custom IE.
static WhdSoftAPInterface * get_default_instance()
Get the default WhdSoftAPInterface instance.
int stop(void)
Stop the Software Access Point.
void * data
Pointer to IE data.
WhdSoftAPInterface(WHD_EMAC &emac=WHD_EMAC::get_instance(WHD_AP_ROLE), OnboardNetworkStack &stack=OnboardNetworkStack::get_default_instance(), whd_interface_shared_info_t &shared=whd_iface_shared)
Construct SoftAP interface.
int get_associated_client_list(void *client_list_buffer, uint16_t buffer_length)
Gets information about associated clients.
int start(const char *ssid, const char *pass, nsapi_security_t security, uint8_t channel, bool start_dhcp_server=true, const whd_custom_ie_info_t *ie_info=NULL, bool ap_sta_concur=false)
Set static IP address for SoftAP.
enum nsapi_security nsapi_security_t
Enum of encryption types.
WhdSoftAPInterface class Implementation of the SoftAPInterface for the Whd.
static OnboardNetworkStack & get_default_instance()
Return the default on-board network stack.
uint8_t subtype
Sub-type of the IE.
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.