25 #define PASSWORD "12345678"
26 #define HOST_NAME "172.16.5.12"
27 #define HOST_PORT (5416)
34 Serial.print(
"setup begin\r\n");
36 Serial.print(
"FW Version:");
40 Serial.print(
"to station + softap ok\r\n");
42 Serial.print(
"to station + softap err\r\n");
45 if (wifi.
joinAP(SSID, PASSWORD)) {
46 Serial.print(
"Join AP success\r\n");
50 Serial.print(
"Join AP failure\r\n");
54 Serial.print(
"single ok\r\n");
56 Serial.print(
"single err\r\n");
59 Serial.print(
"setup end\r\n");
64 uint8_t buffer[128] = {0};
67 Serial.print(
"register udp ok\r\n");
69 Serial.print(
"register udp err\r\n");
72 char *hello =
"Hello, this is client!";
73 wifi.
send((
const uint8_t*)hello, strlen(hello));
75 uint32_t len = wifi.
recv(buffer,
sizeof(buffer), 10000);
77 Serial.print(
"Received:[");
78 for(uint32_t i = 0; i < len; i++) {
79 Serial.print((
char)buffer[i]);
81 Serial.print(
"]\r\n");
85 Serial.print(
"unregister udp ok\r\n");
87 Serial.print(
"unregister udp err\r\n");
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
bool joinAP(String ssid, String pwd, uint8_t pattern=3)
Join in AP.
String getVersion(void)
Get the version of AT Command Set.
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 unregisterUDP(void)
Unregister UDP port number in single mode.
bool disableMUX(void)
Disable IP MUX(single connection mode).
bool registerUDP(String addr, uint32_t port)
Register UDP port number in single mode.
bool setOprToStationSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station + softap.
Provide an easy-to-use way to manipulate ESP8266.