Client side of RF22Router network chain
#include <RF22Router.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER1_ADDRESS 2
#define SERVER2_ADDRESS 3
#define SERVER3_ADDRESS 4
void setup()
{
Serial.begin(9600);
if (!rf22.init())
Serial.println("RF22 init failed");
rf22.addRouteTo(SERVER1_ADDRESS, SERVER1_ADDRESS);
rf22.addRouteTo(SERVER2_ADDRESS, SERVER1_ADDRESS);
rf22.addRouteTo(SERVER3_ADDRESS, SERVER1_ADDRESS);
}
uint8_t data[] = "Hello World!";
uint8_t buf[RF22_ROUTER_MAX_MESSAGE_LEN];
void loop()
{
while (1)
{
Serial.println("Sending to rf22_router_server2");
if (rf22.sendtoWait(data, sizeof(data), SERVER3_ADDRESS) != RF22_ROUTER_ERROR_NONE)
Serial.println("sendtoWait failed");
else
{
uint8_t len = sizeof(buf);
uint8_t from;
if (rf22.recvfromAckTimeout(buf, &len, 3000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is rf22_router_server1, rf22_router_server2 and rf22_router_server3 running?");
}
}
}
}