Need feed back if message received from broadcast

Started by waraytek, March 23, 2017, 11:57:51 AM

waraytek

Hello everyone, I need to send a message over the network and by broadcast (NODEID =255) in order for the listener to give response when it received the message. The code I'm below doesn't  seem to send the message "HelloThere".
if (strstr((char *)radio.DATA, "WhoIsAlive"))
    {
   
    int vlen = 4; 
    char varNodeID[vlen];
    strNODEID.toCharArray(varNodeID,vlen); 
    Serial.print("Got It!! ");Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
     if (radio.sendWithRetry(radio.SENDERID,"HelloThere",10)) { //target node Id, message as string or byte array, message length
        //check if sender wanted an ACK
      if (radio.ACKRequested())
      {
        radio.sendACK();
        Serial.println(" - ACK sent");
      }
        Blink(LED, 50, 3); //blink LED 3 times, 50ms between blinks 
     } 
      radio.receiveDone(); //put radio in RX mode
      Serial.flush();
     
    } 

Am I missing something in the process causing it not to work?

Thanks,
waraytek

perky

Do you say broadcast? I suspect you're not actually requesting an ACK as that would generally result in collisions..
Mark.

TomWS

You won't get an ACKrequested from radio.sendWithRetry():
     if (radio.sendWithRetry(radio.SENDERID,"HelloThere",10)) { //target node Id, message as string or byte array, message length
        //check if sender wanted an ACK
      if (radio.ACKRequested())
      {
        radio.sendACK();
        Serial.println(" - ACK sent");
      }

Also note that the '\0' termination on "HelloThere" won't be transmitted as you've set the length to just the number of characters.  This might also be the case in your broadcasted data.

Tom


waraytek

@perky And  @TomWS
Thank you for the response and I appreciate your time. I will try it again...again thanks for your suggestions.