test public
Dependencies: HttpServer_snapshot_mbed-os
ESP32InterfaceAP Class Reference
ESP32Interface class Implementation of the NetworkStack for the ESP32. More...
#include <ESP32InterfaceAP.h>
Inherits ESP32Stack.
Public Member Functions | |
ESP32InterfaceAP () | |
ESP32InterfaceAP lifetime Configuration defined in mbed_lib.json. | |
ESP32InterfaceAP (PinName en, PinName io0, PinName tx, PinName rx, bool debug=false, PinName rts=NC, PinName cts=NC, int baudrate=230400) | |
ESP32InterfaceAP lifetime. | |
ESP32InterfaceAP (PinName tx, PinName rx, bool debug=false) | |
ESP32InterfaceAP lifetime. | |
virtual nsapi_error_t | set_network (const char *ip_address, const char *netmask, const char *gateway) |
Set a static IP address. | |
virtual nsapi_error_t | set_dhcp (bool dhcp) |
Enable or disable DHCP on the network. | |
virtual int | connect () |
Start the interface. | |
virtual int | connect (const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE, uint8_t channel=0) |
Start the interface. | |
virtual int | set_credentials (const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE) |
Set the WiFi network credentials. | |
virtual int | set_channel (uint8_t channel) |
Set the WiFi network channel - NOT SUPPORTED. | |
virtual int | disconnect () |
Stop the interface. | |
virtual const char * | get_ip_address () |
Get the internally stored IP address. | |
virtual const char * | get_mac_address () |
Get the internally stored MAC address. | |
virtual const char * | get_gateway () |
Get the local gateway. | |
virtual const char * | get_netmask () |
Get the local network mask. | |
virtual int8_t | get_rssi () |
Gets the current radio signal strength for active connection. | |
virtual int | scan (WiFiAccessPoint *res, unsigned count) |
Scan for available networks. | |
virtual void | attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb) |
Register callback for status reporting. | |
virtual nsapi_connection_status_t | get_connection_status () const |
Get the connection status. | |
virtual NetworkStack * | get_stack () |
Provide access to the NetworkStack object. | |
Protected Member Functions | |
virtual int | socket_open (void **handle, nsapi_protocol_t proto) |
Open a socket. | |
virtual int | socket_close (void *handle) |
Close the socket. | |
virtual int | socket_bind (void *handle, const SocketAddress &address) |
Bind a server socket to a specific port. | |
virtual int | socket_listen (void *handle, int backlog) |
Start listening for incoming connections. | |
virtual int | socket_connect (void *handle, const SocketAddress &address) |
Connects this TCP socket to the server. | |
virtual int | socket_accept (void *handle, void **socket, SocketAddress *address) |
Accept a new connection. | |
virtual int | socket_send (void *handle, const void *data, unsigned size) |
Send data to the remote host. | |
virtual int | socket_recv (void *handle, void *data, unsigned size) |
Receive data from the remote host. | |
virtual int | socket_sendto (void *handle, const SocketAddress &address, const void *data, unsigned size) |
Send a packet to a remote endpoint. | |
virtual int | socket_recvfrom (void *handle, SocketAddress *address, void *buffer, unsigned size) |
Receive a packet from a remote endpoint. | |
virtual void | socket_attach (void *handle, void(*callback)(void *), void *data) |
Register a callback on state change of the socket. | |
virtual nsapi_error_t | setsockopt (nsapi_socket_t handle, int level, int optname, const void *optval, unsigned optlen) |
Set stack-specific socket options The setsockopt allow an application to pass stack-specific hints to the underlying stack. | |
virtual nsapi_error_t | getsockopt (nsapi_socket_t handle, int level, int optname, void *optval, unsigned *optlen) |
Get stack-specific socket options The getstackopt allow an application to retrieve stack-specific hints from the underlying stack. |
Detailed Description
ESP32Interface class Implementation of the NetworkStack for the ESP32.
Definition at line 27 of file ESP32InterfaceAP.h.
Constructor & Destructor Documentation
ESP32InterfaceAP | ( | ) |
ESP32InterfaceAP lifetime Configuration defined in mbed_lib.json.
Definition at line 21 of file ESP32InterfaceAP.cpp.
ESP32InterfaceAP | ( | PinName | en, |
PinName | io0, | ||
PinName | tx, | ||
PinName | rx, | ||
bool | debug = false , |
||
PinName | rts = NC , |
||
PinName | cts = NC , |
||
int | baudrate = 230400 |
||
) |
ESP32InterfaceAP lifetime.
- Parameters:
-
en EN pin (If not used this pin, please set "NC") io0 IO0 pin (If not used this pin, please set "NC") tx TX pin rx RX pin debug Enable debugging rts RTS pin cts CTS pin baudrate The baudrate of the serial port (default = 230400).
Definition at line 37 of file ESP32InterfaceAP.cpp.
ESP32InterfaceAP | ( | PinName | tx, |
PinName | rx, | ||
bool | debug = false |
||
) |
ESP32InterfaceAP lifetime.
- Parameters:
-
tx TX pin rx RX pin debug Enable debugging
Definition at line 53 of file ESP32InterfaceAP.cpp.
Member Function Documentation
void attach | ( | mbed::Callback< void(nsapi_event_t, intptr_t)> | status_cb ) | [virtual] |
Register callback for status reporting.
The specified status callback function will be called on status changes on the network. The parameters on the callback are the event type and event-type dependent reason parameter.
In ESP32 the callback will be called when processing OOB-messages via AT-parser. Do NOT call any ESP8266Interface -functions or do extensive processing in the callback.
- Parameters:
-
status_cb The callback for status changes
Definition at line 212 of file ESP32InterfaceAP.cpp.
int connect | ( | const char * | ssid, |
const char * | pass, | ||
nsapi_security_t | security = NSAPI_SECURITY_NONE , |
||
uint8_t | channel = 0 |
||
) | [virtual] |
Start the interface.
Attempts to connect to a WiFi network.
- Parameters:
-
ssid Name of the network to connect to pass Security passphrase to connect to the network security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED
- Returns:
- 0 on success, or error code on failure
Definition at line 89 of file ESP32InterfaceAP.cpp.
int connect | ( | ) | [virtual] |
Start the interface.
Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
- Returns:
- 0 on success, negative error code on failure
Definition at line 107 of file ESP32InterfaceAP.cpp.
int disconnect | ( | void | ) | [virtual] |
Stop the interface.
- Returns:
- 0 on success, negative on failure
Definition at line 168 of file ESP32InterfaceAP.cpp.
nsapi_connection_status_t get_connection_status | ( | ) | const [virtual] |
Get the connection status.
- Returns:
- The connection status according to ConnectionStatusType
Definition at line 217 of file ESP32InterfaceAP.cpp.
const char * get_gateway | ( | ) | [virtual] |
Get the local gateway.
- Returns:
- Null-terminated representation of the local gateway or null if no network mask has been recieved
Definition at line 192 of file ESP32InterfaceAP.cpp.
const char * get_ip_address | ( | ) | [virtual] |
Get the internally stored IP address.
- Returns:
- IP address of the interface or null if not yet connected
Definition at line 182 of file ESP32InterfaceAP.cpp.
const char * get_mac_address | ( | ) | [virtual] |
Get the internally stored MAC address.
- Returns:
- MAC address of the interface
Definition at line 187 of file ESP32InterfaceAP.cpp.
const char * get_netmask | ( | ) | [virtual] |
Get the local network mask.
- Returns:
- Null-terminated representation of the local network mask or null if no network mask has been recieved
Definition at line 197 of file ESP32InterfaceAP.cpp.
int8_t get_rssi | ( | ) | [virtual] |
Gets the current radio signal strength for active connection.
- Returns:
- Connection strength in dBm (negative value)
Definition at line 202 of file ESP32InterfaceAP.cpp.
virtual NetworkStack* get_stack | ( | ) | [virtual] |
Provide access to the NetworkStack object.
- Returns:
- The underlying NetworkStack object
Definition at line 216 of file ESP32InterfaceAP.h.
nsapi_error_t getsockopt | ( | nsapi_socket_t | handle, |
int | level, | ||
int | optname, | ||
void * | optval, | ||
unsigned * | optlen | ||
) | [protected, virtual, inherited] |
Get stack-specific socket options The getstackopt allow an application to retrieve stack-specific hints from the underlying stack.
For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
- Parameters:
-
handle Socket handle level Stack-specific protocol level optname Stack-specific option identifier optval Destination for option value optlen Length of the option value
- Returns:
- 0 on success, negative error code on failure
Definition at line 307 of file ESP32Stack.cpp.
int scan | ( | WiFiAccessPoint * | res, |
unsigned | count | ||
) | [virtual] |
Scan for available networks.
This function will block.
- Parameters:
-
ap Pointer to allocated array to store discovered AP count Size of allocated res array, or 0 to only count available AP timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
- Returns:
- Number of entries in , or if count was 0 number of available networks, negative on error see nsapi_error
Definition at line 207 of file ESP32InterfaceAP.cpp.
int set_channel | ( | uint8_t | channel ) | [virtual] |
Set the WiFi network channel - NOT SUPPORTED.
This function is not supported and will return NSAPI_ERROR_UNSUPPORTED
- Parameters:
-
channel Channel on which the connection is to be made, or 0 for any (Default: 0)
- Returns:
- Not supported, returns NSAPI_ERROR_UNSUPPORTED
Definition at line 159 of file ESP32InterfaceAP.cpp.
int set_credentials | ( | const char * | ssid, |
const char * | pass, | ||
nsapi_security_t | security = NSAPI_SECURITY_NONE |
||
) | [virtual] |
Set the WiFi network credentials.
- Parameters:
-
ssid Name of the network to connect to pass Security passphrase to connect to the network security Type of encryption for connection (defaults to NSAPI_SECURITY_NONE)
- Returns:
- 0 on success, or error code on failure
Definition at line 135 of file ESP32InterfaceAP.cpp.
nsapi_error_t set_dhcp | ( | bool | dhcp ) | [virtual] |
Enable or disable DHCP on the network.
Enables DHCP on connecting the network. Defaults to enabled unless a static IP address has been assigned. Requires that the network is disconnected.
- Parameters:
-
dhcp True to enable DHCP
- Returns:
- 0 on success, negative error code on failure
Definition at line 82 of file ESP32InterfaceAP.cpp.
nsapi_error_t set_network | ( | const char * | ip_address, |
const char * | netmask, | ||
const char * | gateway | ||
) | [virtual] |
Set a static IP address.
Configures this network interface to use a static IP address. Implicitly disables DHCP, which can be enabled in set_dhcp. Requires that the network is disconnected.
- Parameters:
-
ip_address Null-terminated representation of the local IP address netmask Null-terminated representation of the local network mask gateway Null-terminated representation of the local gateway
- Returns:
- 0 on success, negative error code on failure
Definition at line 68 of file ESP32InterfaceAP.cpp.
nsapi_error_t setsockopt | ( | nsapi_socket_t | handle, |
int | level, | ||
int | optname, | ||
const void * | optval, | ||
unsigned | optlen | ||
) | [protected, virtual, inherited] |
Set stack-specific socket options The setsockopt allow an application to pass stack-specific hints to the underlying stack.
For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned and the socket is unmodified.
- Parameters:
-
handle Socket handle level Stack-specific protocol level optname Stack-specific option identifier optval Option value optlen Length of the option value
- Returns:
- 0 on success, negative error code on failure
Definition at line 274 of file ESP32Stack.cpp.
int socket_accept | ( | void * | handle, |
void ** | socket, | ||
SocketAddress * | address | ||
) | [protected, virtual, inherited] |
Accept a new connection.
- Parameters:
-
handle Handle in which to store new socket server Socket handle to server to accept from
- Returns:
- 0 on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 166 of file ESP32Stack.cpp.
void socket_attach | ( | void * | handle, |
void(*)(void *) | callback, | ||
void * | data | ||
) | [protected, virtual, inherited] |
Register a callback on state change of the socket.
- Parameters:
-
handle Socket handle callback Function to call on state change data Argument to pass to callback
- Note:
- Callback may be called in an interrupt context.
Definition at line 263 of file ESP32Stack.cpp.
int socket_bind | ( | void * | handle, |
const SocketAddress & | address | ||
) | [protected, virtual, inherited] |
Bind a server socket to a specific port.
- Parameters:
-
handle Socket handle address Local address to listen for incoming connections on
- Returns:
- 0 on success, negative on failure.
Definition at line 86 of file ESP32Stack.cpp.
int socket_close | ( | void * | handle ) | [protected, virtual, inherited] |
Close the socket.
- Parameters:
-
handle Socket handle
- Returns:
- 0 on success, negative on failure
- Note:
- On failure, any memory associated with the socket must still be cleaned up
Definition at line 64 of file ESP32Stack.cpp.
int socket_connect | ( | void * | handle, |
const SocketAddress & | address | ||
) | [protected, virtual, inherited] |
Connects this TCP socket to the server.
- Parameters:
-
handle Socket handle address SocketAddress to connect to
- Returns:
- 0 on success, negative on failure
Definition at line 144 of file ESP32Stack.cpp.
int socket_listen | ( | void * | handle, |
int | backlog | ||
) | [protected, virtual, inherited] |
Start listening for incoming connections.
- Parameters:
-
handle Socket handle backlog Number of pending connections that can be queued up at any one time [Default: 1]
- Returns:
- 0 on success, negative on failure
Definition at line 122 of file ESP32Stack.cpp.
int socket_open | ( | void ** | handle, |
nsapi_protocol_t | proto | ||
) | [protected, virtual, inherited] |
Open a socket.
- Parameters:
-
handle Handle in which to store new socket proto Type of socket to open, NSAPI_TCP or NSAPI_UDP
- Returns:
- 0 on success, negative on failure
Definition at line 39 of file ESP32Stack.cpp.
int socket_recv | ( | void * | handle, |
void * | data, | ||
unsigned | size | ||
) | [protected, virtual, inherited] |
Receive data from the remote host.
- Parameters:
-
handle Socket handle data The buffer in which to store the data received from the host size The maximum length of the buffer
- Returns:
- Number of received bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 205 of file ESP32Stack.cpp.
int socket_recvfrom | ( | void * | handle, |
SocketAddress * | address, | ||
void * | buffer, | ||
unsigned | size | ||
) | [protected, virtual, inherited] |
Receive a packet from a remote endpoint.
- Parameters:
-
handle Socket handle address Destination for the remote SocketAddress or null buffer The buffer for storing the incoming packet data If a packet is too long to fit in the supplied buffer, excess bytes are discarded size The length of the buffer
- Returns:
- The number of received bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 247 of file ESP32Stack.cpp.
int socket_send | ( | void * | handle, |
const void * | data, | ||
unsigned | size | ||
) | [protected, virtual, inherited] |
Send data to the remote host.
- Parameters:
-
handle Socket handle data The buffer to send to the host size The length of the buffer to send
- Returns:
- Number of written bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 190 of file ESP32Stack.cpp.
int socket_sendto | ( | void * | handle, |
const SocketAddress & | address, | ||
const void * | data, | ||
unsigned | size | ||
) | [protected, virtual, inherited] |
Send a packet to a remote endpoint.
- Parameters:
-
handle Socket handle address The remote SocketAddress data The packet to be sent size The length of the packet to be sent
- Returns:
- The number of written bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 221 of file ESP32Stack.cpp.
Generated on Wed Jul 13 2022 05:33:38 by 1.7.2