Let's say I have only 2 NRF radios.
I know NRF24 radios are not full duplex. So I want to keep them both listening and only stop listening to send a message.
If one sends one of the two messages
- abc
- def
and the one receiving will need to respond as such
- if abc is received do x
- if def is received do y
but won't know what message is being sent then how would I set this up?
I was thinking something like this:
radio 1
if (someValue == 1)
{
const char abc[] = "abc";
radio.stopListening();
delay(100);
radio.write(&abc, sizeof(abc));
delay(100);
radio.startListening();
delay(100);
if (someValue == 2)
{
const char def[] = "def";
radio.stopListening();
delay(100);
radio.write(&abc, sizeof(abc));
delay(100);
radio.startListening();
delay(100);
}
radio 2
if (radio.available())
{
char abc[32] = {0};
radio.read(&abc, sizeof(abc));
if (strcmp(abc, "abc"))
{
digitalWrite(pin 1, HIGH);
delay(100);
}
char AlarmOff[32] = {0};
radio.read(&def, sizeof(def));
if (strcmp(def, "def"))
{
digitalWrite(pin 2, HIGH);
delay(100);
}