nrf24 communiction

i am really struggling to get my messages back and forth from my nrf cards. all the circuity including filtering caps are there. the problem is when im sending and receiving the messages. the layout is 4 different nrf cards. what i call the master sends a message to device 2 then device 2 responds with a answer, then the master send a message to device 3 and this continues to go on. the sending of the packets happens successfully but when it comes to reading the responses i and loosing the messages because i think they are arriving at the wrong time or before the master gets a chance to read the incoming message from device 2 it has already sent a request to device 3. my codes long ive been working at this for days now i cant seem to come up with a solution. hopefully someones willing to help me sort this out. please forgive me im not really good at asking the right questions. after every message request "state" changes to 1 and triggers reading of the responses.

in short this is the code im having problems with,

if (state >= 1) { //then read incoming messages
    readBothResponses();
  }
 
 if (updateState == 1) { //send this request then hopefully read the response before moving on
    requestRX1update();
    retryRefreshMarker = millis();
  }

  if (millis() - retryRefreshMarker > 50) { //send this request , get response then move on
    if (updateState == 2) {
      requestRX2update();
      retryRefreshMarker = millis();
    }

    if (millis() - retryRefreshMarker > 80) { // same
      if (updateState == 3) {
        requestRX3update();
        updateState = 4;  //now move to last request.
        retryRefreshMarker = millis();
      }
      if (millis() - retryRefreshMarker > 0) { //please ignore the useless millis
        if (updateState == 4) {
          if (millis() - paramsdelay >= 500) {
            requestRX3Paramsupdate();
            paramsdelay = millis();

          }
          updateState = 5;
          retryRefreshMarker = millis();
        }
        if (millis() - retryRefreshMarker > 250) {  //start this all over again
          updateState = 1;
        }
      }
    }
  }


  
void requestRX1update() {  /////first address send command to request a value 
  //Serial.println("4");
  float Array2[1] = {RX1Request};
  wirelessSPI.stopListening();
  wirelessSPI.openWritingPipe(pAddress2);  //sending to the correct address
  if (!wirelessSPI.write( &Array2, sizeof(Array2))) {
    updateState = 2;

    phUpdateCounter++;
  }
  else {
 
   
    wirelessSPI.stopListening();
    wirelessSPI.openReadingPipe(1, pAddress2);
    wirelessSPI.startListening();
    state = 1;
    updateState = 2;
  }
}
void requestRX2update() { //next request
  Serial.println("3");
  float Array[1] = {RX2Request};
  wirelessSPI.stopListening();
  wirelessSPI.openWritingPipe(pAddress);
  if (!wirelessSPI.write( &Array, sizeof(Array))) {
    updateState = 3;
    Serial.println("dose fail");
    doseLinkStatusCounter++;
    if (debug) {
      myGLCD.setColor(0, 0, 0); //set1 color black
      myGLCD.fillRect(5, 114, 310, 134); //write over numbers
      myGLCD.setColor(255, 128, 0); // set color green
      myGLCD.print("Dose Control RX2 Failed" , 10, 115);
    }
  }
  else {
    //   Serial.println("status request sent");
    if (debug) {
      myGLCD.setColor(0, 0, 0); //set color black
      myGLCD.fillRect(5, 114, 310, 134); //write over numbers
      myGLCD.setColor(255, 128, 0); // set color green
      myGLCD.print("Dose Control RX2 Sent" , 10, 115);
    }
     //   Serial.println("dose okay");
    wirelessSPI.stopListening();
    wirelessSPI.openReadingPipe(1, pAddress);
    wirelessSPI.startListening();
    state = 1;
    updateState = 3;
  }
}
void requestRX3Paramsupdate() {
  Serial.println("3");
  wirelessSPI.stopListening();
  wirelessSPI.openWritingPipe(pAddress1);
  float Array[3] = {RX3ShowParams};
  if (!wirelessSPI.write( &Array, sizeof(Array))) {
    //wirelessSPI.flush_tx();
    updateState = 1;
    //wirelessSPI.flush_tx();
    wirelessSPI.flush_rx();
  }
  else {
    wirelessSPI.flush_tx();
    wirelessSPI.stopListening();
    wirelessSPI.openReadingPipe(1, pAddress1);
    wirelessSPI.startListening();
    state = 1;

    updateState = 1;
  }
}

void requestRX3update() {
  
  wirelessSPI.stopListening();
  wirelessSPI.openWritingPipe(pAddress1);
  float Array[3] = {16.61};
  if (!wirelessSPI.write( &Array, sizeof(Array))) {
    updateState = 1;
    Serial.println("rx3 failed");
    if (debug) {
      myGLCD.print("Timer Module RX3 Failed" , 10, 150);
    
    }
  }
  else {
    if (debug) {
      myGLCD.setColor(0, 0, 0); //set color black
      myGLCD.fillRect(5, 148, 310, 167); //write over numbers
      myGLCD.setColor(255, 128, 0); // set color green
      myGLCD.print("Timer Module RX3 Sent" , 10, 150);
    }
    Serial.println("rx3 passed");
    wirelessSPI.stopListening();
    wirelessSPI.openReadingPipe(1, pAddress1);
    wirelessSPI.startListening();
    state = 1;
  }
}

void readBothResponses() {
  //Serial.println("read both");
  if (statecounter >= 5) {
    state = 0;
    statecounter = 0;
  }
  statecounter ++;
  while (wirelessSPI.available()) {
    wirelessSPI.read( &incomingArray, sizeof(incomingArray) );
    float incomingResponse2 = float(incomingArray[0]);
    if (incomingResponse2 == RX3ShowParams) {
      timerInfoResetdelay = millis();
      timer1OnTime =  incomingArray[1];
      timer1OffTime = incomingArray[2];
      timer2OnTime =  incomingArray[3];
      timer2OffTime = incomingArray[4];

    }
    if (incomingResponse2 == RX3ShowParams2) {
      timerInfoResetdelay = millis();
      timer3OnTime =  incomingArray[1];
      timer3OffTime = incomingArray[2];
      timer4OnTime =  incomingArray[3];
      timer4OffTime = incomingArray[4];

    }
    if (incomingResponse2 == 1Update) {

    
    }
    if (incomingResponse2 == RX2Value1) {
      dosecount++;
      Serial.println("dose link");
      doseLinkStatus = true;
      doseLinkStatusCounter = 0;
      doseUpCount = incomingArray[1];
      doseDownCount = incomingArray[2];
    }
    if (incomingResponse2 == timerUpdateCommand) {
      timercount++;
      timerMonitorMillis = millis();
      Serial.println(incomingArray[5]);
      timer1Status = float(incomingArray[1]);
      timer2Status = float(incomingArray[2]);
      timer3Status = float(incomingArray[3]);
      timer4Status = float(incomingArray[4]);
      timerRunStatus = float(incomingArray[5]);
    }
    state = 0;
    wirelessSPI.flush_rx();
  }
}

notsolowki:
before the master gets a chance to read the incoming message from device 2 it has already sent a request to device 3.

Maybe don't do that?

my codes long

And, incomplete.

Have a look at this Simple nRF24L01+ Tutorial.

It includes an example for a master and 2 slaves that can easily be extended to a larger number of slaves. By putting the master in charge and using the ackPayload technique there should no confusion.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R