An example of handling/prioritizing different types of data passing through the RF24Network
#include "printf.h"
#include <RF24.h>
RF24 radio(7, 8);
const uint16_t this_node = 00;
const uint16_t other_node = 01;
uint32_t myVariable = 0;
void setup() {
Serial.begin(115200);
printf_begin();
while (!Serial) {
}
Serial.println(F("RF24Network/examples/Network_Separation_RX/"));
if (!radio.begin()) {
Serial.println(F("Radio hardware not responding!"));
while (1) {
}
}
radio.setChannel(90);
network.begin( this_node);
radio.printDetails();
}
uint32_t sendTimer = 0;
#define EXTERNAL_DATA_MAX_SIZE MAX_PAYLOAD_SIZE
uint8_t dataBuffer[EXTERNAL_DATA_MAX_SIZE];
uint32_t userDataTimer = 0;
void loop() {
uint16_t size = network.frag_ptr->message_size;
memcpy(&dataBuffer, network.frag_ptr->message_buffer, network.frag_ptr->message_size);
Serial.print(F("External Data RX, size: "));
Serial.println(network.frag_ptr->message_size);
for (uint16_t i = 0; i < network.frag_ptr->message_size; i++) {
Serial.print(dataBuffer[i]);
Serial.print(F(":"));
}
Serial.println();
}
if (millis() - userDataTimer > 5000) {
userDataTimer = millis();
while (network.available()) {
uint16_t dataSize = network.peek(header);
uint32_t someVariable;
network.read(header, &someVariable, sizeof(someVariable));
Serial.print(F("RX User Data:\nHeader Type "));
Serial.print(header.
type);
Serial.print(F(" Value "));
Serial.println(someVariable);
} else {
network.read(header, &someVariable, 0);
}
}
}
}
Definition RF24Network.h:384
#define EXTERNAL_DATA_TYPE
Definition RF24Network.h:103