Server side of simple client/server pair using RF22ReliableDatagram class
#include <RF22ReliableDatagram.h>
#include <RF22.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
void setup()
{
Serial.begin(9600);
if (!rf22.init())
Serial.println("RF22 init failed");
}
uint8_t data[] = "And hello back to you";
uint8_t buf[RF22_MAX_MESSAGE_LEN];
void loop()
{
while (1)
{
uint8_t len = sizeof(buf);
uint8_t from;
if (rf22.recvfromAck(buf, &len, &from))
{
Serial.print("got request from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
if (!rf22.sendtoWait(data, sizeof(data), from))
Serial.println("sendtoWait failed");
}
}
}