Mistake on this page?
Report an issue in GitHub or email us
ESP8266Interface.h
1 /* ESP8266 implementation of NetworkInterfaceAPI
2  * Copyright (c) 2015 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 ESP8266_INTERFACE_H
19 #define ESP8266_INTERFACE_H
20 
21 #if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_API_PRESENT)
22 #include "drivers/DigitalOut.h"
23 #include "drivers/Timer.h"
24 #include "ESP8266/ESP8266.h"
25 #include "events/EventQueue.h"
26 #include "events/mbed_shared_queues.h"
28 #include "netsocket/NetworkStack.h"
29 #include "netsocket/nsapi_types.h"
31 #include "netsocket/WiFiAccessPoint.h"
32 #include "netsocket/WiFiInterface.h"
33 #include "platform/Callback.h"
34 #include "platform/mbed_chrono.h"
35 #if MBED_CONF_RTOS_PRESENT
36 #include "rtos/ConditionVariable.h"
37 #endif
38 #include "rtos/Mutex.h"
39 
40 #define ESP8266_SOCKET_COUNT 5
41 
42 #define ESP8266_INTERFACE_CONNECT_INTERVAL 5s
43 #define ESP8266_INTERFACE_CONNECT_TIMEOUT (2 * ESP8266_CONNECT_TIMEOUT + ESP8266_INTERFACE_CONNECT_INTERVAL)
44 
45 #ifdef TARGET_FF_ARDUINO
46 #ifndef MBED_CONF_ESP8266_TX
47 #define MBED_CONF_ESP8266_TX D1
48 #endif
49 
50 #ifndef MBED_CONF_ESP8266_RX
51 #define MBED_CONF_ESP8266_RX D0
52 #endif
53 #endif /* TARGET_FF_ARDUINO */
54 
55 #ifndef MBED_CONF_ESP8266_COUNTRY_CODE
56 #define MBED_CONF_ESP8266_COUNTRY_CODE "CN"
57 #endif
58 
59 #ifndef MBED_CONF_ESP8266_CHANNEL_START
60 #define MBED_CONF_ESP8266_CHANNEL_START 1
61 #endif
62 
63 #ifndef MBED_CONF_ESP8266_CHANNELS
64 #define MBED_CONF_ESP8266_CHANNELS 13
65 #endif
66 
67 /** ESP8266Interface class
68  * Implementation of the NetworkStack for the ESP8266
69  */
70 class ESP8266Interface : public NetworkStack, public WiFiInterface {
71 public:
72 #if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
73  /**
74  * @brief ESP8266Interface default constructor
75  * Will use values defined in mbed_lib.json
76  */
77  ESP8266Interface();
78 #endif
79 
80  /** ESP8266Interface lifetime
81  * @param tx TX pin
82  * @param rx RX pin
83  * @param debug Enable debugging
84  */
85  ESP8266Interface(PinName tx, PinName rx, bool debug = false, PinName rts = NC, PinName cts = NC, PinName rst = NC, PinName pwr = NC);
86 
87  /**
88  * @brief ESP8266Interface default destructor
89  */
90  virtual ~ESP8266Interface();
91 
92  /** Start the interface
93  *
94  * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
95  * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
96  *
97  * @return 0 on success, negative error code on failure
98  */
99  virtual int connect();
100 
101  /** Start the interface
102  *
103  * Attempts to connect to a WiFi network.
104  *
105  * If interface is configured blocking it will timeout after up to
106  * ESP8266_INTERFACE_CONNECT_TIMEOUT_MS + ESP8266_CONNECT_TIMEOUT ms.
107  *
108  * @param ssid Name of the network to connect to
109  * @param pass Security passphrase to connect to the network
110  * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
111  * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED
112  * @return 0 on success, or error code on failure
113  */
114  virtual int connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE,
115  uint8_t channel = 0);
116 
117  /** Set the WiFi network credentials
118  *
119  * @param ssid Name of the network to connect to
120  * @param pass Security passphrase to connect to the network
121  * @param security Type of encryption for connection
122  * (defaults to NSAPI_SECURITY_NONE)
123  * @return 0 on success, or error code on failure
124  */
125  virtual int set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE);
126 
127  /** Set the WiFi network channel - NOT SUPPORTED
128  *
129  * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED
130  *
131  * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
132  * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED
133  */
134  virtual int set_channel(uint8_t channel);
135 
136  /** @copydoc NetworkInterface::set_network */
137  virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway);
138 
139  /** @copydoc NetworkInterface::dhcp */
140  virtual nsapi_error_t set_dhcp(bool dhcp);
141 
142  /** Stop the interface
143  * @return 0 on success, negative on failure
144  */
145  virtual int disconnect();
146 
147  /** Get the internally stored IP address
148  * @return IP address of the interface or null if not yet connected
149  */
150  virtual nsapi_error_t get_ip_address(SocketAddress *address);
151 
152  /** Get the internally stored MAC address
153  * @return MAC address of the interface
154  */
155  virtual const char *get_mac_address();
156 
157  /** Get the local gateway
158  *
159  * @return Null-terminated representation of the local gateway
160  * or null if no network mask has been recieved
161  */
162  virtual nsapi_error_t get_gateway(SocketAddress *address);
163 
164  MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
165  virtual const char *get_gateway();
166 
167  /** Get the local network mask
168  *
169  * @return Null-terminated representation of the local network mask
170  * or null if no network mask has been recieved
171  */
172  virtual nsapi_error_t get_netmask(SocketAddress *address);
173 
174  MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
175  virtual const char *get_netmask();
176 
177  /** Get the current time.
178  *
179  * @retval NSAPI_ERROR_UNSUPPORTED if the function is not supported
180  * @retval NSAPI_ERROR_OK on success
181  *
182  * @note esp8266.sntp-enable must be set to true in mbed_app.json.
183  */
184  nsapi_error_t get_time(std::tm *t);
185 
186  /** Get the network interface name
187  *
188  * @return Null-terminated representation of the network interface name
189  * or null if interface not exists
190  */
191  virtual char *get_interface_name(char *interface_name);
192 
193  /** Gets the current radio signal strength for active connection
194  *
195  * @return Connection strength in dBm (negative value)
196  */
197  virtual int8_t get_rssi();
198 
199  /** Scan mode
200  */
201  enum scan_mode {
202  SCANMODE_ACTIVE, /*!< active mode */
203  SCANMODE_PASSIVE /*!< passive mode */
204  };
205 
206  /** Scan for available networks
207  *
208  * This function will block.
209  *
210  * @param ap Pointer to allocated array to store discovered AP
211  * @param count Size of allocated @a res array, or 0 to only count available AP
212  * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
213  * see @a nsapi_error
214  */
215  virtual int scan(WiFiAccessPoint *res, unsigned count);
216 
217  /** Scan for available networks
218  *
219  * This function will block.
220  *
221  * @param ap Pointer to allocated array to store discovered AP
222  * @param count Size of allocated @a res array, or 0 to only count available AP
223  * @param t_max Scan time for each channel - 0-1500ms. If 0 - uses default value
224  * @param t_min Minimum for each channel in active mode - 0-1500ms. If 0 - uses default value. Omit in passive mode
225  * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
226  * see @a nsapi_error
227  */
228  virtual int scan(WiFiAccessPoint *res, unsigned count, scan_mode mode = SCANMODE_PASSIVE,
229  mbed::chrono::milliseconds_u32 t_max = mbed::chrono::milliseconds_u32(0),
230  mbed::chrono::milliseconds_u32 t_min = mbed::chrono::milliseconds_u32(0));
231 
232  /** Translates a hostname to an IP address with specific version
233  *
234  * The hostname may be either a domain name or an IP address. If the
235  * hostname is an IP address, no network transactions will be performed.
236  *
237  * If no stack-specific DNS resolution is provided, the hostname
238  * will be resolve using a UDP socket on the stack.
239  *
240  * @param address Destination for the host SocketAddress
241  * @param host Hostname to resolve
242  * @param version IP version of address to resolve, NSAPI_UNSPEC indicates
243  * version is chosen by the stack (defaults to NSAPI_UNSPEC)
244  * @return 0 on success, negative error code on failure
245  */
246 #if MBED_CONF_ESP8266_BUILT_IN_DNS
247  nsapi_error_t gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name);
248 #else
250 #endif
251 
254 
255  /** Add a domain name server to list of servers to query
256  *
257  * @param addr Destination for the host address
258  * @return 0 on success, negative error code on failure
259  */
260 #if MBED_CONF_ESP8266_BUILT_IN_DNS
261  nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name);
262 #else
264 #endif
265 
266  /** @copydoc NetworkStack::setsockopt
267  */
268  virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level,
269  int optname, const void *optval, unsigned optlen);
270 
271  /** @copydoc NetworkStack::getsockopt
272  */
273  virtual nsapi_error_t getsockopt(nsapi_socket_t handle, int level, int optname,
274  void *optval, unsigned *optlen);
275 
276  /** Register callback for status reporting
277  *
278  * The specified status callback function will be called on status changes
279  * on the network. The parameters on the callback are the event type and
280  * event-type dependent reason parameter.
281  *
282  * In ESP8266 the callback will be called when processing OOB-messages via
283  * AT-parser. Do NOT call any ESP8266Interface -functions or do extensive
284  * processing in the callback.
285  *
286  * @param status_cb The callback for status changes
287  */
288  virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
289 
290  /** Get the connection status
291  *
292  * @return The connection status according to ConnectionStatusType
293  */
294  virtual nsapi_connection_status_t get_connection_status() const;
295 
296 protected:
297  /** Open a socket
298  * @param handle Handle in which to store new socket
299  * @param proto Type of socket to open, NSAPI_TCP or NSAPI_UDP
300  * @return 0 on success, negative on failure
301  */
302  virtual int socket_open(void **handle, nsapi_protocol_t proto);
303 
304  /** Close the socket
305  * @param handle Socket handle
306  * @return 0 on success, negative on failure
307  * @note On failure, any memory associated with the socket must still
308  * be cleaned up
309  */
310  virtual int socket_close(void *handle);
311 
312  /** Bind a server socket to a specific port
313  * @param handle Socket handle
314  * @param address Local address to listen for incoming connections on
315  * @return 0 on success, negative on failure.
316  */
317  virtual int socket_bind(void *handle, const SocketAddress &address);
318 
319  /** Start listening for incoming connections
320  * @param handle Socket handle
321  * @param backlog Number of pending connections that can be queued up at any
322  * one time [Default: 1]
323  * @return 0 on success, negative on failure
324  */
325  virtual int socket_listen(void *handle, int backlog);
326 
327  /** Connects this TCP socket to the server
328  * @param handle Socket handle
329  * @param address SocketAddress to connect to
330  * @return 0 on success, negative on failure
331  */
332  virtual int socket_connect(void *handle, const SocketAddress &address);
333 
334  /** Accept a new connection.
335  * @param handle Handle in which to store new socket
336  * @param server Socket handle to server to accept from
337  * @return 0 on success, negative on failure
338  * @note This call is not-blocking, if this call would block, must
339  * immediately return NSAPI_ERROR_WOULD_WAIT
340  */
341  virtual int socket_accept(void *handle, void **socket, SocketAddress *address);
342 
343  /** Send data to the remote host
344  * @param handle Socket handle
345  * @param data The buffer to send to the host
346  * @param size The length of the buffer to send
347  * @return Number of written bytes on success, negative on failure
348  * @note This call is not-blocking, if this call would block, must
349  * immediately return NSAPI_ERROR_WOULD_WAIT
350  */
351  virtual int socket_send(void *handle, const void *data, unsigned size);
352 
353  /** Receive data from the remote host
354  * @param handle Socket handle
355  * @param data The buffer in which to store the data received from the host
356  * @param size The maximum length of the buffer
357  * @return Number of received bytes on success, negative on failure
358  * @note This call is not-blocking, if this call would block, must
359  * immediately return NSAPI_ERROR_WOULD_WAIT
360  */
361  virtual int socket_recv(void *handle, void *data, unsigned size);
362 
363  /** Send a packet to a remote endpoint
364  * @param handle Socket handle
365  * @param address The remote SocketAddress
366  * @param data The packet to be sent
367  * @param size The length of the packet to be sent
368  * @return The number of written bytes on success, negative on failure
369  * @note This call is not-blocking, if this call would block, must
370  * immediately return NSAPI_ERROR_WOULD_WAIT
371  */
372  virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size);
373 
374  /** Receive a packet from a remote endpoint
375  * @param handle Socket handle
376  * @param address Destination for the remote SocketAddress or null
377  * @param buffer The buffer for storing the incoming packet data
378  * If a packet is too long to fit in the supplied buffer,
379  * excess bytes are discarded
380  * @param size The length of the buffer
381  * @return The number of received bytes on success, negative on failure
382  * @note This call is not-blocking, if this call would block, must
383  * immediately return NSAPI_ERROR_WOULD_WAIT
384  */
385  virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size);
386 
387  /** Register a callback on state change of the socket
388  * @param handle Socket handle
389  * @param callback Function to call on state change
390  * @param data Argument to pass to callback
391  * @note Callback may be called in an interrupt context.
392  */
393  virtual void socket_attach(void *handle, void (*callback)(void *), void *data);
394 
395  /** Provide access to the NetworkStack object
396  *
397  * @return The underlying NetworkStack object
398  */
399  virtual NetworkStack *get_stack()
400  {
401  return this;
402  }
403 
404  /** Set blocking status of connect() which by default should be blocking.
405  *
406  * @param blocking Use true to make connect() blocking.
407  * @return NSAPI_ERROR_OK on success, negative error code on failure.
408  */
409  virtual nsapi_error_t set_blocking(bool blocking);
410 
411  /** Set country code
412  *
413  * @param track_ap if TRUE, use country code used by the AP ESP is connected to,
414  * otherwise uses country_code always
415  * @param country_code ISO 3166-1 coded, 2 character alphanumeric country code assumed
416  * @param len Length of the country code
417  * @param channel_start The channel number to start at
418  * @param channel Number of channels
419  * @return NSAPI_ERROR_OK on success, negative error code on failure.
420  */
421  nsapi_error_t set_country_code(bool track_ap, const char *country_code, int len, int channel_start, int channels);
422 
423 private:
424  // AT layer
425  ESP8266 _esp;
426  void refresh_conn_state_cb();
427 
428  /** Status of software connection
429  */
430  typedef enum esp_connection_software_status {
431  IFACE_STATUS_DISCONNECTED = 0,
432  IFACE_STATUS_CONNECTING = 1,
433  IFACE_STATUS_CONNECTED = 2,
434  IFACE_STATUS_DISCONNECTING = 3
435  } esp_connection_software_status_t;
436 
437  // HW reset pin
438  class ResetPin {
439  public:
440  ResetPin(PinName rst_pin);
441  void rst_assert();
442  void rst_deassert();
443  bool is_connected();
444  private:
445  mbed::DigitalOut _rst_pin;
446  } _rst_pin;
447 
448  // HW power pin
449  class PowerPin {
450  public:
451  PowerPin(PinName pwr_pin);
452  void power_on();
453  void power_off();
454  bool is_connected();
455  private:
456  mbed::DigitalOut _pwr_pin;
457  } _pwr_pin;
458 
459  /** Assert the reset and power pins
460  * ESP8266 has two pins serving similar purpose and this function asserts them both
461  * if they are configured in mbed_app.json.
462  */
463  void _power_off();
464 
465  // Credentials
466  static const int ESP8266_SSID_MAX_LENGTH = 32; /* 32 is what 802.11 defines as longest possible name */
467  char ap_ssid[ESP8266_SSID_MAX_LENGTH + 1]; /* The longest possible name; +1 for the \0 */
468  static const int ESP8266_PASSPHRASE_MAX_LENGTH = 63; /* The longest allowed passphrase */
469  static const int ESP8266_PASSPHRASE_MIN_LENGTH = 8; /* The shortest allowed passphrase */
470  char ap_pass[ESP8266_PASSPHRASE_MAX_LENGTH + 1]; /* The longest possible passphrase; +1 for the \0 */
471  nsapi_security_t _ap_sec;
472 
473  // Country code
474  struct _channel_info {
475  bool track_ap; // Set country code based on the AP ESP is connected to
476  char country_code[4]; // ISO 3166-1 coded, 2-3 character alphanumeric country code - +1 for the '\0' - assumed. Documentation doesn't tell.
477  int channel_start;
478  int channels;
479  };
480  struct _channel_info _ch_info;
481 
482  bool _if_blocking; // NetworkInterface, blocking or not
483 #if MBED_CONF_RTOS_PRESENT
484  rtos::ConditionVariable _if_connected;
485 #endif
486 
487  // connect status reporting
488  nsapi_error_t _conn_status_to_error();
489  mbed::Timer _conn_timer;
490 
491  // Drivers's socket info
492  struct _sock_info {
493  bool open;
494  uint16_t sport;
495  };
496  struct _sock_info _sock_i[ESP8266_SOCKET_COUNT];
497 
498  // Driver's state
499  int _initialized;
500  nsapi_error_t _connect_retval;
501  nsapi_error_t _disconnect_retval;
502  bool _get_firmware_ok();
503  nsapi_error_t _init(void);
504  nsapi_error_t _reset();
505 
506  //sigio
507  struct {
508  void (*callback)(void *);
509  void *data;
510  uint8_t deferred;
511  } _cbs[ESP8266_SOCKET_COUNT];
512  void event();
513  void event_deferred();
514 
515  // Connection state reporting to application
516  nsapi_connection_status_t _conn_stat;
518 
519  // Background OOB processing
520  // Use global EventQueue
521  events::EventQueue *_global_event_queue;
522  int _oob_event_id;
523  int _connect_event_id;
524  int _disconnect_event_id;
525  void proc_oob_evnt();
526  void _connect_async();
527  void _disconnect_async();
528  rtos::Mutex _cmutex; // Protect asynchronous connection logic
529  esp_connection_software_status_t _software_conn_stat;
530  bool _dhcp;
531 
532 };
533 #endif
534 #endif
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle, const void *data, nsapi_size_t size)=0
Send data over a TCP socket.
Common interface between Wi-Fi devices.
Definition: WiFiInterface.h:32
virtual void attach(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register callback for status reporting.
SocketAddress class.
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)=0
Connects TCP socket to a remote host.
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)=0
Listen for connections on a TCP socket.
NetworkStack class.
Definition: NetworkStack.h:42
EventQueue.
Definition: EventQueue.h:62
Network Interface base class.
void * nsapi_socket_t
Opaque handle for network sockets.
Definition: nsapi_types.h:252
virtual nsapi_error_t set_channel(uint8_t channel)=0
Set the Wi-Fi network channel.
virtual nsapi_error_t gethostbyname_async_cancel(int id)
Cancel asynchronous hostname translation.
virtual nsapi_error_t get_ip_address(SocketAddress *address)
Get the local IP address.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
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.
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle, void *data, nsapi_size_t size)=0
Receive data over a TCP socket.
virtual const char * get_mac_address()
Get the local MAC address.
virtual nsapi_error_t socket_close(nsapi_socket_t handle)=0
Close the socket.
virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address)=0
Bind a specific address to a socket.
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address, void *buffer, nsapi_size_t size)=0
Receive a packet over a UDP socket.
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address, const void *data, nsapi_size_t size)=0
Send a packet over a UDP socket.
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)=0
Opens a socket.
nsapi_error_t disconnect() override=0
Stop the interface.
virtual nsapi_connection_status_t get_connection_status() const
Get the connection status.
virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level, int optname, const void *optval, unsigned optlen)
Set stack-specific socket options.
SocketAddress class.
Definition: SocketAddress.h:37
The Mutex class is used to synchronize the execution of threads.
Definition: Mutex.h:70
virtual nsapi_error_t set_dhcp(bool dhcp)
Enable or disable DHCP on connecting the network.
virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name=NULL)
Add a domain name server to list of servers to query.
virtual void socket_attach(nsapi_socket_t handle, void(*callback)(void *), void *data)=0
Register a callback on state change of the socket.
virtual nsapi_error_t gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translates a hostname to an IP address with specific version.
virtual nsapi_error_t get_gateway(SocketAddress *address)
Get the local gateway.
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count)=0
Scan for available networks.
The ConditionVariable class is a synchronization primitive that allows threads to wait until a partic...
virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name)
Add a domain name server to list of servers to query.
A digital output, used for setting the state of a pin.
Definition: DigitalOut.h:51
virtual nsapi_error_t gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translate a hostname to an IP address with specific version using network interface name...
NetworkStack class.
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translate a hostname to an IP address (asynchronous) using network interface name.
virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway)
Configure this network interface to use a static IP address.
virtual nsapi_error_t set_blocking(bool blocking)
Set asynchronous operation of connect() and disconnect() calls.
enum nsapi_security nsapi_security_t
Enum of encryption types.
static void debug(const char *format,...) MBED_PRINTF(1
Output a debug message.
Definition: mbed_debug.h:44
virtual nsapi_error_t getsockopt(nsapi_socket_t handle, int level, int optname, void *optval, unsigned *optlen)
Get stack-specific socket options.
virtual nsapi_error_t socket_accept(nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0)=0
Accepts a connection on a TCP socket.
Callback class based on template specialization.
Definition: Callback.h:53
Definition: ATHandler.h:46
nsapi_error_t connect() override=0
Attempt to connect to a Wi-Fi network.
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
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.