Mbed OS Reference
Loading...
Searching...
No Matches
ESP32InterfaceAP.h
1/* ESP32 implementation of NetworkInterfaceAPI
2 * Copyright (c) 2017 Renesas Electronics Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ESP32_INTERFACE_AP_H
18#define ESP32_INTERFACE_AP_H
19
20#include "ESP32Stack.h"
21
22
23/** ESP32Interface class
24 * Implementation of the NetworkStack for the ESP32
25 */
27public:
28 /** ESP32InterfaceAP lifetime
29 * Configuration defined in mbed_lib.json
30 */
32
33 /** ESP32InterfaceAP lifetime
34 * @param en EN pin (If not used this pin, please set "NC")
35 * @param io0 IO0 pin (If not used this pin, please set "NC")
36 * @param tx TX pin
37 * @param rx RX pin
38 * @param debug Enable debugging
39 * @param rts RTS pin
40 * @param cts CTS pin
41 * @param baudrate The baudrate of the serial port (default = 230400).
42 */
43 ESP32InterfaceAP(PinName en, PinName io0, PinName tx, PinName rx, bool debug = false,
44 PinName rts = NC, PinName cts = NC, int baudrate = 230400);
45
46 /** ESP32InterfaceAP lifetime
47 * @param tx TX pin
48 * @param rx RX pin
49 * @param debug Enable debugging
50 */
51 ESP32InterfaceAP(PinName tx, PinName rx, bool debug = false);
52
54 const SocketAddress &ip_address, const SocketAddress &netmask,
55 const SocketAddress &gateway) override;
56
57 nsapi_error_t set_dhcp(bool dhcp) override;
58
59 int connect() override;
60
61 int connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE,
62 uint8_t channel = 0) override;
63
64 int set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE) override;
65
66 int set_channel(uint8_t channel) override;
67
68 int disconnect() override;
69
71
72 const char *get_mac_address() override;
73
75
77
78 int8_t get_rssi() override;
79
80 int scan(WiFiAccessPoint *res, unsigned count) override;
81
83
85
86 void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb) override;
87
88 nsapi_connection_status_t get_connection_status() const override;
89
90 NetworkStack *get_stack() override
91 {
92 return this;
93 }
94
95private:
96 bool _dhcp;
97 uint8_t _own_ch;
98 char _own_ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
99 char _own_pass[64]; /* The longest allowed passphrase */
100 nsapi_security_t _own_sec;
101 SocketAddress _ip_address;
102 SocketAddress _netmask;
103 SocketAddress _gateway;
104 nsapi_connection_status_t _connection_status;
105 mbed::Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
106};
107
108#endif
ESP32Interface class Implementation of the NetworkStack for the ESP32.
const char * get_mac_address() override
Get the local MAC address.
ESP32InterfaceAP(PinName en, PinName io0, PinName tx, PinName rx, bool debug=false, PinName rts=NC, PinName cts=NC, int baudrate=230400)
ESP32InterfaceAP lifetime.
nsapi_connection_status_t get_connection_status() const override
Get the connection status.
ESP32InterfaceAP(PinName tx, PinName rx, bool debug=false)
ESP32InterfaceAP lifetime.
nsapi_error_t get_gateway(SocketAddress *address) override
Get the local gateway.
int set_credentials(const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE) override
Set the Wi-Fi network credentials.
int connect(const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE, uint8_t channel=0) override
Attempt to connect to a Wi-Fi network.
nsapi_error_t get_ip_address(SocketAddress *address) override
Get the local IP address.
int8_t get_rssi() override
Get the current radio signal strength for active connection.
nsapi_error_t set_dhcp(bool dhcp) override
Enable or disable DHCP on connecting the network.
int connect() override
Attempt to connect to a Wi-Fi network.
void attach(mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb) override
Register callback for status reporting.
nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway) override
Configure this network interface to use a static IP address.
ESP32InterfaceAP()
ESP32InterfaceAP lifetime Configuration defined in mbed_lib.json.
int disconnect() override
Stop the interface.
nsapi_error_t get_netmask(SocketAddress *address) override
Get the local network mask.
int set_channel(uint8_t channel) override
Set the Wi-Fi network channel.
ESP32Stack class Implementation of the NetworkStack for the ESP32.
Definition ESP32Stack.h:31
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.
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.
Representation of an IP (v4 or v6) address and port pair.
WiFiAccessPoint class.
Common interface between Wi-Fi devices.
Callback class based on template specialization.
Definition Callback.h:53
enum nsapi_security nsapi_security_t
Enum of encryption types.
signed int nsapi_error_t
Type used to represent error codes.
@ NSAPI_SECURITY_NONE