1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

Merge pull request #1270 from vindolin/master

Add message count and the chip ID to the request/response messages in the mesh example.
This commit is contained in:
Ivan Grokhotkov 2015-12-22 10:58:53 +03:00
commit 81c315046b

View File

@ -1,6 +1,9 @@
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMesh.h>
unsigned int request_i = 0;
unsigned int response_i = 0;
/* Create the mesh node object */
ESP8266WiFiMesh mesh_node = ESP8266WiFiMesh(ESP.getChipId(), manageRequest);
@ -17,7 +20,9 @@ String manageRequest(String request)
Serial.println(request);
/* return a string to send back */
return String("Hello world response.");
char response[60];
sprintf(response, "Hello world response #%d from Mesh_Node%d.", response_i++, ESP.getChipId());
return response;
}
void setup()
@ -39,6 +44,8 @@ void loop()
mesh_node.acceptRequest();
/* Scan for other nodes and send them a message */
mesh_node.attemptScan("Hello world request.");
char request[60];
sprintf(request, "Hello world request #%d from Mesh_Node%d.", request_i++, ESP.getChipId());
mesh_node.attemptScan(request);
delay(1000);
}