Example sketch showing how to create a simple messageing server with the NRF24 class. It is designed to work with the example nrf24_ping_client. It also works with ping_client from the Mirf library
#include <NRF24.h>
#include <SPI.h>
void setup()
{
Serial.begin(9600);
while (!Serial)
;
Serial.println("NRF24 init failed");
Serial.println("setChannel failed");
Serial.println("setThisAddress failed");
Serial.println("setPayloadSize failed");
Serial.println("setRF failed");
Serial.println("initialised");
}
void loop()
{
unsigned long data;
uint8_t len = sizeof(data);
if (!nrf24.
recv((uint8_t*)&data, &len))
Serial.println("read failed");
Serial.println("setTransmitAddress failed");
if (!nrf24.
send((uint8_t*)&data,
sizeof(data)))
Serial.println("send failed");
{
Serial.println("waitPacketSent failed");
}
}