Newbie questions

Started by waraytek, January 30, 2017, 07:37:23 PM

waraytek

#15
Hello everyone, I think I have  a working prototype. The following is how the program works.
1. Node#1 transmits ("FROMNode1-2#") to Node#2, when  received blinks an LED.
2. Then Node#2 transmit ("FROMNode2-3#")  to Node#3
3. Then Node#3 blinks an LED if the message arrived from Node#2.

I think I have a simple prototype of relaying the message, but I noticed Node#2 LED blinks faster than Node#3. Could this mean that Node#3 have delays twice of that from Node#2?
Below is what I'm using..
Node#1(Transmitter)
delay(1000);  // Wait 1 second between transmits, could also 'sleep' here!  
  char radiopacket[20] = "FROMNode1-2#";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
    
  if (radio.sendWithRetry(RECEIVER, radiopacket, strlen(radiopacket))) { //target node Id, message as string or byte array, message length
    Serial.println("OK");
  }

Node#2(Transmit and Receive) same with Node#3
//check if received message contains message
    if (strstr((char *)radio.DATA, "FROMNode1-2#"))
    {
        char radiopacket[20] = "FROMNode2-3#";
        itoa(packetnum++, radiopacket+13, 10);
        Serial.print("Sending "); Serial.println(radiopacket);
          
        if (radio.sendWithRetry(2, radiopacket, strlen(radiopacket))) { //target node Id, message as string or byte array, message length
          Serial.println("OK");
         
        }


Just want to ask if there is a better way to test in relaying messages to all nodes.

Thanks,
waraytek