JuReceiver/system_general/multicast.h

28 lines
662 B
C
Raw Permalink Normal View History

2023-09-10 15:33:34 +02:00
typedef struct {
byte type = 0xff;
byte channel;
uint64_t pipe;
char name[16] = "[UNNAMED]";
} nrfMulticast;
void RCMulticastTask() {
if (random(25) == 1) {
2023-09-17 13:57:28 +02:00
#if debug
2023-09-10 15:33:34 +02:00
Serial.println("Multicast!");
#endif
radio.stopListening();
radio.setChannel(multicastChannel);
radio.openWritingPipe(multicastAddress);
nrfMulticast data;
data.pipe = myPipe;
data.channel = myChannel;
2023-09-17 13:57:28 +02:00
#ifdef jName
char nameMult[16] = jName;
2023-09-10 15:33:34 +02:00
strncpy(data.name, nameMult, 16);
#endif
2023-09-17 13:57:28 +02:00
radio.write(&data, sizeof(data));
2023-09-10 15:33:34 +02:00
radio.setChannel(myChannel);
radio.startListening();
}
}