Simplest possible example of using RF24Network. Put this sketch on one node, and helloworld_rx.pde on the other. Tx will send Rx a nice message every 2 seconds which rx will print out for us.
#include <SPI.h>
#include <RF24.h>
RF24 radio(7, 8);
const uint16_t this_node = 01;
const uint16_t other_node = 00;
const unsigned long interval = 2000;
unsigned long last_sent;
unsigned long packets_sent;
struct payload_t {
unsigned long ms;
unsigned long counter;
};
void setup(void) {
Serial.begin(115200);
while (!Serial) {
}
Serial.println(F("RF24Network/examples/helloworld_tx/"));
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
}
}
radio.setChannel(90);
network.begin( this_node);
}
void loop() {
network.update();
unsigned long now = millis();
if (now - last_sent >= interval) {
last_sent = now;
Serial.print(F("Sending... "));
payload_t payload = { millis(), packets_sent++ };
bool ok = network.write(header, &payload, sizeof(payload));
Serial.println(ok ? F("ok.") : F("failed."));
}
}
Definition RF24Network.h:384