Dopasowany do naszego firmware'u
Dependencies: ArduinoAPI
Fork of WeeESP8266 by
ESP8266 Class Reference
Provide an easy-to-use way to manipulate ESP8266. More...
#include <ESP8266.h>
Public Member Functions | |
ESP8266 (ArduinoSerial &uart) | |
Constuctor. | |
bool | kick (void) |
Verify ESP8266 whether live or not. | |
bool | restart (void) |
Restart ESP8266 by "AT+RST". | |
String | getVersion (void) |
Get the version of AT Command Set. | |
bool | setOprToStation (void) |
Set operation mode to staion. | |
bool | setOprToSoftAP (void) |
Set operation mode to softap. | |
bool | setOprToStationSoftAP (void) |
Set operation mode to station + softap. | |
String | getAPList (void) |
Search available AP list and return it. | |
bool | joinAP (String ssid, String pwd) |
Join in AP. | |
bool | leaveAP (void) |
Leave AP joined before. | |
bool | setSoftAPParam (String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4) |
Set SoftAP parameters. | |
String | getJoinedDeviceIP (void) |
Get the IP list of devices connected to SoftAP. | |
int | getIPStatus (void) |
Get the current status of connection(UDP and TCP). | |
String | getLocalIP (void) |
Get the IP address of ESP8266. | |
bool | enableMUX (void) |
Enable IP MUX(multiple connection mode). | |
bool | disableMUX (void) |
Disable IP MUX(single connection mode). | |
bool | createTCP (String addr, uint32_t port) |
Create TCP connection in single mode. | |
bool | releaseTCP (void) |
Release TCP connection in single mode. | |
bool | registerUDP (String addr, uint32_t port) |
Register UDP port number in single mode. | |
bool | unregisterUDP (void) |
Unregister UDP port number in single mode. | |
bool | createTCP (uint8_t mux_id, String addr, uint32_t port) |
Create TCP connection in multiple mode. | |
bool | releaseTCP (uint8_t mux_id) |
Release TCP connection in multiple mode. | |
bool | registerUDP (uint8_t mux_id, String addr, uint32_t port) |
Register UDP port number in multiple mode. | |
bool | unregisterUDP (uint8_t mux_id) |
Unregister UDP port number in multiple mode. | |
bool | setTCPServerTimeout (uint32_t timeout=180) |
Set the timeout of TCP Server. | |
bool | startTCPServer (uint32_t port=333) |
Start TCP Server(Only in multiple mode). | |
bool | stopTCPServer (void) |
Stop TCP Server(Only in multiple mode). | |
bool | send (const uint8_t *buffer, uint32_t len) |
Send data based on TCP or UDP builded already in single mode. | |
bool | send (uint8_t mux_id, const uint8_t *buffer, uint32_t len) |
Send data based on one of TCP or UDP builded already in multiple mode. | |
uint32_t | recv (uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) |
Receive data from TCP or UDP builded already in single mode. | |
uint32_t | recv (uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) |
Receive data from one of TCP or UDP builded already in multiple mode. | |
uint32_t | recv (uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) |
Receive data from all of TCP or UDP builded already in multiple mode. |
Detailed Description
Provide an easy-to-use way to manipulate ESP8266.
Definition at line 29 of file ESP8266.h.
Constructor & Destructor Documentation
ESP8266 | ( | ArduinoSerial & | uart ) |
Constuctor.
- Parameters:
-
uart - an reference of ArduinoSerial object with baud 9600.
Definition at line 24 of file ESP8266.cpp.
Member Function Documentation
bool createTCP | ( | String | addr, |
uint32_t | port | ||
) |
Create TCP connection in single mode.
- Parameters:
-
addr - the IP or domain name of the target host. port - the port number of the target host.
- Return values:
-
true - success. false - failure.
Definition at line 195 of file ESP8266.cpp.
bool createTCP | ( | uint8_t | mux_id, |
String | addr, | ||
uint32_t | port | ||
) |
Create TCP connection in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4). addr - the IP or domain name of the target host. port - the port number of the target host.
- Return values:
-
true - success. false - failure.
Definition at line 215 of file ESP8266.cpp.
bool disableMUX | ( | void | ) |
Disable IP MUX(single connection mode).
In single connection mode, only one TCP or UDP communication can be builded.
- Return values:
-
true - success. false - failure.
Definition at line 190 of file ESP8266.cpp.
bool enableMUX | ( | void | ) |
Enable IP MUX(multiple connection mode).
In multiple connection mode, a couple of TCP and UDP communication can be builded. They can be distinguished by the identifier of TCP or UDP named mux_id.
- Return values:
-
true - success. false - failure.
Definition at line 185 of file ESP8266.cpp.
String getAPList | ( | void | ) |
Search available AP list and return it.
- Returns:
- the list of available APs.
- Note:
- This method will occupy a lot of memeory(hundreds of Bytes to a couple of KBytes). Do not call this method unless you must and ensure that your board has enough memery left.
Definition at line 118 of file ESP8266.cpp.
int getIPStatus | ( | void | ) |
Get the current status of connection(UDP and TCP).
- Returns:
- the status. true - connected false - disconnected
Definition at line 147 of file ESP8266.cpp.
String getJoinedDeviceIP | ( | void | ) |
Get the IP list of devices connected to SoftAP.
- Returns:
- the list of IP.
- Note:
- This method should not be called when station mode.
Definition at line 140 of file ESP8266.cpp.
String getLocalIP | ( | void | ) |
String getVersion | ( | void | ) |
Get the version of AT Command Set.
- Returns:
- the string of version.
Definition at line 60 of file ESP8266.cpp.
bool joinAP | ( | String | ssid, |
String | pwd | ||
) |
Join in AP.
- Parameters:
-
ssid - SSID of AP to join in. pwd - Password of AP to join in.
- Return values:
-
true - success. false - failure.
- Note:
- This method will take a couple of seconds.
Definition at line 125 of file ESP8266.cpp.
bool kick | ( | void | ) |
Verify ESP8266 whether live or not.
Actually, this method will send command "AT" to ESP8266 and waiting for "OK".
- Return values:
-
true - alive. false - dead.
Definition at line 38 of file ESP8266.cpp.
bool leaveAP | ( | void | ) |
Leave AP joined before.
- Return values:
-
true - success. false - failure.
Definition at line 130 of file ESP8266.cpp.
uint32_t recv | ( | uint8_t * | buffer, |
uint32_t | buffer_size, | ||
uint32_t | timeout = 1000 |
||
) |
Receive data from TCP or UDP builded already in single mode.
- Parameters:
-
buffer - the buffer for storing data. buffer_size - the length of the buffer. timeout - the time waiting data.
- Returns:
- the length of data received actually.
Definition at line 265 of file ESP8266.cpp.
uint32_t recv | ( | uint8_t | mux_id, |
uint8_t * | buffer, | ||
uint32_t | buffer_size, | ||
uint32_t | timeout = 1000 |
||
) |
Receive data from one of TCP or UDP builded already in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4). buffer - the buffer for storing data. buffer_size - the length of the buffer. timeout - the time waiting data.
- Returns:
- the length of data received actually.
Definition at line 270 of file ESP8266.cpp.
uint32_t recv | ( | uint8_t * | coming_mux_id, |
uint8_t * | buffer, | ||
uint32_t | buffer_size, | ||
uint32_t | timeout = 1000 |
||
) |
Receive data from all of TCP or UDP builded already in multiple mode.
After return, coming_mux_id store the id of TCP or UDP from which data coming. User should read the value of coming_mux_id and decide what next to do.
- Parameters:
-
coming_mux_id - the identifier of TCP or UDP. buffer - the buffer for storing data. buffer_size - the length of the buffer. timeout - the time waiting data.
- Returns:
- the length of data received actually.
Definition at line 281 of file ESP8266.cpp.
bool registerUDP | ( | String | addr, |
uint32_t | port | ||
) |
Register UDP port number in single mode.
- Parameters:
-
addr - the IP or domain name of the target host. port - the port number of the target host.
- Return values:
-
true - success. false - failure.
Definition at line 205 of file ESP8266.cpp.
bool registerUDP | ( | uint8_t | mux_id, |
String | addr, | ||
uint32_t | port | ||
) |
Register UDP port number in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4). addr - the IP or domain name of the target host. port - the port number of the target host.
- Return values:
-
true - success. false - failure.
Definition at line 225 of file ESP8266.cpp.
bool releaseTCP | ( | uint8_t | mux_id ) |
Release TCP connection in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4).
- Return values:
-
true - success. false - failure.
Definition at line 220 of file ESP8266.cpp.
bool releaseTCP | ( | void | ) |
Release TCP connection in single mode.
- Return values:
-
true - success. false - failure.
Definition at line 200 of file ESP8266.cpp.
bool restart | ( | void | ) |
Restart ESP8266 by "AT+RST".
This method will take 3 seconds or more.
- Return values:
-
true - success. false - failure.
Definition at line 43 of file ESP8266.cpp.
bool send | ( | uint8_t | mux_id, |
const uint8_t * | buffer, | ||
uint32_t | len | ||
) |
Send data based on one of TCP or UDP builded already in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4). buffer - the buffer of data to send. len - the length of data to send.
- Return values:
-
true - success. false - failure.
Definition at line 260 of file ESP8266.cpp.
bool send | ( | const uint8_t * | buffer, |
uint32_t | len | ||
) |
Send data based on TCP or UDP builded already in single mode.
- Parameters:
-
buffer - the buffer of data to send. len - the length of data to send.
- Return values:
-
true - success. false - failure.
Definition at line 255 of file ESP8266.cpp.
bool setOprToSoftAP | ( | void | ) |
Set operation mode to softap.
- Return values:
-
true - success. false - failure.
Definition at line 84 of file ESP8266.cpp.
bool setOprToStation | ( | void | ) |
Set operation mode to staion.
- Return values:
-
true - success. false - failure.
Definition at line 67 of file ESP8266.cpp.
bool setOprToStationSoftAP | ( | void | ) |
Set operation mode to station + softap.
- Return values:
-
true - success. false - failure.
Definition at line 101 of file ESP8266.cpp.
bool setSoftAPParam | ( | String | ssid, |
String | pwd, | ||
uint8_t | chl = 7 , |
||
uint8_t | ecn = 4 |
||
) |
Set SoftAP parameters.
- Parameters:
-
ssid - SSID of SoftAP. pwd - PASSWORD of SoftAP. chl - the channel (1 - 13, default: 7). ecn - the way of encrypstion (0 - OPEN, 1 - WEP, 2 - WPA_PSK, 3 - WPA2_PSK, 4 - WPA_WPA2_PSK, default: 4).
- Note:
- This method should not be called when station mode.
Definition at line 135 of file ESP8266.cpp.
bool setTCPServerTimeout | ( | uint32_t | timeout = 180 ) |
Set the timeout of TCP Server.
- Parameters:
-
timeout - the duration for timeout by second(0 ~ 28800, default:180).
- Return values:
-
true - success. false - failure.
Definition at line 235 of file ESP8266.cpp.
bool startTCPServer | ( | uint32_t | port = 333 ) |
Start TCP Server(Only in multiple mode).
After started, user should call method: getIPStatus to know the status of TCP connections. The methods of receiving data can be called for user's any purpose. After communication, release the TCP connection is needed by calling method: releaseTCP with mux_id.
- Parameters:
-
port - the port number to listen(default: 333).
- Return values:
-
true - success. false - failure.
- See also:
- String getIPStatus(void);
- uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
- bool releaseTCP(uint8_t mux_id);
Definition at line 240 of file ESP8266.cpp.
bool stopTCPServer | ( | void | ) |
Stop TCP Server(Only in multiple mode).
- Return values:
-
true - success. false - failure.
Definition at line 248 of file ESP8266.cpp.
bool unregisterUDP | ( | void | ) |
Unregister UDP port number in single mode.
- Return values:
-
true - success. false - failure.
Definition at line 210 of file ESP8266.cpp.
bool unregisterUDP | ( | uint8_t | mux_id ) |
Unregister UDP port number in multiple mode.
- Parameters:
-
mux_id - the identifier of this TCP(available value: 0 - 4).
- Return values:
-
true - success. false - failure.
Definition at line 230 of file ESP8266.cpp.
Generated on Wed Jul 13 2022 11:14:17 by 1.7.2