Author Topic: Trouble switching between Tx and Rx mode  (Read 83 times)

zkorange

  • Newbie
  • *
  • Posts: 8
Trouble switching between Tx and Rx mode
« on: April 13, 2020, 04:18:59 PM »
I'm building a network of wearable devices that I would like to forward data (originating with a single central device) to the rest of the network.  The idea is that one device not in range of the central device, could get the data from a closer one.  In order to get the message to propagate, I need each device to be able to switch between Rx and Tx on each loop.

I'm using the Struct examples to package the data, so "Payload" refers to the typedef similar to the example.  I've stripped out all of the ACKs, Encryption, and ATC for my preliminary tests.  Here is a snippet of the code from my loop:

Code: [Select]
if (radio.receiveDone())
  {
    recData = *(Payload*)radio.DATA;
    if (recData.uptime > fwdData.uptime)) {
      fwdData = recData;
    }
  }

  radio.send(99,(const void*)(&fwdData), sizeof(fwdData)); /*this seems to be the problem line*/
  radio.receiveDone(); /*I've included this line because I saw it in the TxRxBlinky example, but it doesn't do the trick*/

It seems that calling "radio.send()" takes it out of Rx mode and it won't go back.  Without that line, the device receives everything properly, but will not forward the message to the rest of the network.

Any suggestions on how to get this relay system to work would be greatly appreciated!