Skip to content

Commit 81c3150

Browse files
committed
Merge pull request #1270 from vindolin/master
Add message count and the chip ID to the request/response messages in the mesh example.
2 parents 70cf3c3 + 05aed73 commit 81c3150

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

libraries/ESP8266WiFiMesh/examples/HelloMesh/HelloMesh.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include <ESP8266WiFi.h>
22
#include <ESP8266WiFiMesh.h>
33

4+
unsigned int request_i = 0;
5+
unsigned int response_i = 0;
6+
47
/* Create the mesh node object */
58
ESP8266WiFiMesh mesh_node = ESP8266WiFiMesh(ESP.getChipId(), manageRequest);
69

@@ -17,7 +20,9 @@ String manageRequest(String request)
1720
Serial.println(request);
1821

1922
/* return a string to send back */
20-
return String("Hello world response.");
23+
char response[60];
24+
sprintf(response, "Hello world response #%d from Mesh_Node%d.", response_i++, ESP.getChipId());
25+
return response;
2126
}
2227

2328
void setup()
@@ -39,6 +44,8 @@ void loop()
3944
mesh_node.acceptRequest();
4045

4146
/* Scan for other nodes and send them a message */
42-
mesh_node.attemptScan("Hello world request.");
47+
char request[60];
48+
sprintf(request, "Hello world request #%d from Mesh_Node%d.", request_i++, ESP.getChipId());
49+
mesh_node.attemptScan(request);
4350
delay(1000);
4451
}

0 commit comments

Comments
 (0)