Simplest possible example of using RF24Network with nrf_to_nrf library (instead of RF24) with encryption. Put this sketch on one node, and helloworld_tx.pde on the other. Tx will send Rx a nice message every 2 seconds which rx will print out for us.
#include <nrf_to_nrf.h>
uint8_t myKey[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 };
nrf_to_nrf radio;
RF52Network network(radio);
const uint16_t this_node = 00;
const uint16_t other_node = 01;
struct payload_t {
unsigned long ms;
unsigned long counter;
};
void setup(void) {
Serial.begin(115200);
while (!Serial) {
}
Serial.println(F("RF24Network/examples/helloworld_rx/"));
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
}
}
radio.setKey(myKey);
radio.enableEncryption = true;
radio.enableDynamicPayloads(123);
radio.setChannel(90);
network.begin( this_node);
}
void loop(void) {
network.update();
while (network.available()) {
payload_t payload;
network.read(header, &payload, sizeof(payload));
Serial.print(F("Received packet: counter="));
Serial.print(payload.counter);
Serial.print(F(", origin timestamp="));
Serial.println(payload.ms);
}
}