The setup consists of one Rx unit which links with three Tx units in Call Response mode.
All three Tx units send data to the Rx unit once every 0.5 sec and get data back.
Just before doing the whole code i just want to clarify ... it appears that in this scheme the Rx node address is never used. I am just providing only the address part for clarity and the Write / Read functions for clarity... kind of pseudo code.
Rx module code segments :
byte rf_Address[][6] = {"1_PRX", "2_PTX", "3_PTX", "4_PTX"} ;
setup()
{
radio.begin();
radio.openReadingPipe(1, rf_Address[1]);
radio.openReadingPipe(2, rf_Address[2]);
radio.openReadingPipe(3, rf_Address[3]);
radio.enableAckPayload();
radio.startListening();
}
loop
{
byte pipeRxd;
if ( radio.available(&pipeRxd)) {
switch (pipeRxd) {
case 1:
radio.read( &dataFromTx1, sizeof(dataFromTx1)); // Return boolean checked in actual code
radio.writeAckPayload(1, &ackDataToTx1, sizeof(ackDataToTx1));
break;
case 2:
radio.read( &dataFromTx2, sizeof(dataFromTx2)); // Return boolean checked in actual code
radio.writeAckPayload(2, &ackDataToTx2, sizeof(ackDataToTx2));
break;
case 3:
radio.read( &dataFromTx3, sizeof(dataFromTx3)); // Return boolean checked in actual code
radio.writeAckPayload(3, &ackDataToTx3, sizeof(ackDataToTx3));
break;
default :
break;
}
}
}
And following is the Tx code ( rest two Tx are identical )
byte rf_Address[][6] = {"1_PRX", "2_PTX"} ;
setup()
{
radio.begin();
}
loop
{
radio.openWritingPipe(rf_Address[1]);
if ( radio.write(&dataToRx1, sizeof(dataToRx1) )
{
if ( radio.isAckPayloadAvailable()
{
radio.read(&ackFromRx1, sizeof(ackFromRx1));
}
}
delay(500);
}
If you see the code above nowhere the Rx address is made use of .. I have a demo of the above setup working ok. But i just want to be sure that i am not missing out anything before the code is firmed up for a new project.