A more advanced version of helloworld_tx using fragmentation/reassembly and variable payload sizes
#include "printf.h"
#include <RF24.h>
RF24 radio(7, 8);
const uint16_t this_node = 01;
const uint16_t other_node = 00;
const unsigned long interval = 500;
unsigned long last_sent;
void setup(void) {
Serial.begin(115200);
while (!Serial) {
}
Serial.println(F("RF24Network/examples/helloworld_tx_advanced/"));
printf_begin();
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
}
}
radio.setChannel(90);
network.begin( this_node);
radio.printDetails();
dataBuffer[i] = i % 256;
}
}
uint16_t sizeofSend = 0;
bool stopSending = 0;
void loop() {
if (Serial.available()) {
Serial.read();
stopSending = !stopSending;
}
network.update();
unsigned long now = millis();
if (now - last_sent >= interval && !stopSending) {
last_sent = now;
Serial.print(F("Sending size "));
Serial.print(sizeofSend);
bool ok = network.write(header, &dataBuffer, sizeofSend++);
sizeofSend = 0;
}
Serial.println(ok ? F(" ok.") : F(" failed."));
}
}
#define MAX_PAYLOAD_SIZE
Maximum size of fragmented network frames and fragmentation cache.
Definition RF24Network_config.h:67
Definition RF24Network.h:384