-
Notifications
You must be signed in to change notification settings - Fork 0
/
Echo_Node.ino
36 lines (25 loc) · 1.09 KB
/
Echo_Node.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//******************************************************************************************
/*Echo Node*/ *
//******************************************************************************************
#include "painlessMesh.h"
#define MESH_PREFIX "whateverYouLike"
#define MESH_PASSWORD "somethingSneaky"
#define MESH_PORT 5555
// Prototypes
void receivedCallback( uint32_t from, String &msg );
painlessMesh mesh;
void setup() {
Serial.begin(115200);
mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION ); // set before init() so that you can see startup messages
mesh.init( MESH_PREFIX, MESH_PASSWORD, MESH_PORT );
mesh.onReceive(&receivedCallback);
}
void loop() {
mesh.update();
}
void receivedCallback( uint32_t from, String &msg ) {
uint32_t dist= 3810272744;
Serial.printf("echoNode: Received from %u msg=%s\n", from, msg.c_str());
Serial.printf("echoNode: sending data to %u msg=%s\n", dist, msg.c_str());
mesh.sendSingle(dist, msg);
}