Example sketch showing how to create a simple messageing server with the RF22 class. RF22 class does not provide for addressing or reliability. It is designed to work with the other example rf22_client
#include <SPI.h>
#include <RF22.h>
#include <SoftwareSPI.h>
RF22 rf22(SS, 0, &Software_spi);
void setup()
{
Serial.begin(9600);
if (!rf22.init())
Serial.println("RF22 init failed");
}
void loop()
{
if (rf22.available())
{
uint8_t buf[RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf22.recv(buf, &len))
{
Serial.print("got request: ");
Serial.println((char*)buf);
uint8_t data[] = "And hello back to you";
rf22.send(data, sizeof(data));
rf22.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}