24 #define PASSWORD "12345678"
25 #define HOST_NAME "172.16.5.12"
26 #define HOST_PORT (8090)
33 Serial.print(
"setup begin\r\n");
35 Serial.print(
"FW Version:");
39 Serial.print(
"to station + softap ok\r\n");
41 Serial.print(
"to station + softap err\r\n");
44 if (wifi.
joinAP(SSID, PASSWORD)) {
45 Serial.print(
"Join AP success\r\n");
49 Serial.print(
"Join AP failure\r\n");
53 Serial.print(
"single ok\r\n");
55 Serial.print(
"single err\r\n");
58 Serial.print(
"setup end\r\n");
63 uint8_t buffer[128] = {0};
65 if (wifi.
createTCP(HOST_NAME, HOST_PORT)) {
66 Serial.print(
"create tcp ok\r\n");
68 Serial.print(
"create tcp err\r\n");
71 char *hello =
"Hello, this is client!";
72 wifi.
send((
const uint8_t*)hello, strlen(hello));
74 uint32_t len = wifi.
recv(buffer,
sizeof(buffer), 10000);
76 Serial.print(
"Received:[");
77 for(uint32_t i = 0; i < len; i++) {
78 Serial.print((
char)buffer[i]);
80 Serial.print(
"]\r\n");
84 Serial.print(
"release tcp ok\r\n");
86 Serial.print(
"release tcp err\r\n");
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
String getVersion(void)
Get the version of AT Command Set.
bool releaseTCP(void)
Release TCP connection in single 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.
String getLocalIP(void)
Get the IP address of ESP8266.
The definition of class ESP8266.
bool setOprToStationSoftAP(void)
Set operation mode to station + softap.
bool createTCP(String addr, uint32_t port)
Create TCP connection in single mode.
bool disableMUX(void)
Disable IP MUX(single connection mode).
bool joinAP(String ssid, String pwd)
Join in AP.
Provide an easy-to-use way to manipulate ESP8266.