forked from mic159/ArduinoMesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRF_test.ino
41 lines (37 loc) · 842 Bytes
/
RF_test.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
37
38
39
40
41
#include <SPI.h>
#include "RF24.h"
#include "MeshBase.h"
class App : public MeshBase
{
public:
App() : MeshBase(9, 10) {}
protected:
virtual void OnMessage(const MeshBase::Message* meta, const void* data, uint8_t length)
{
Serial.print(meta->address_from, DEC);
Serial.print(" : ");
Serial.println((const char*)data);
}
virtual void OnNewPeer(Peer* p)
{
if (!IsReady()) return;
char buff[255];
int len = snprintf(buff, 255, "Hello %u", p->address);
Serial.print("Me : ");
Serial.println(buff);
SendMessage(p->address, type_user, buff, len + 1);
}
};
App app;
void setup()
{
Serial.begin(9600);
Serial.println("Starting RF_TEST");
randomSeed(analogRead(0));
app.Begin();
}
void loop()
{
app.Update();
delay(100);
}