Author Topic: Is there a "data has been sent" flag in RadioHead?  (Read 1994 times)

dave_sausages

  • Newbie
  • *
  • Posts: 49
Is there a "data has been sent" flag in RadioHead?
« on: September 02, 2016, 11:55:00 PM »
So I've been trawling through the RadioHead documentation and I can't find any option to tell when the radio has finished transmitting, but I'm assuming I've just missed it.

I've found the "waitPacketSent" function that blocks until sent (why a library has any blocking functions I still don't understand), so there is a way for the AVR to tell when the radio has finished transmitting, I just can't find a non blocking way of doing it.

Oh and I'm using a LoRa radio with the rf95 library, so on super slow and long range transmissions (km's) it can take a couple of seconds to send a data packet. So having the program hang for a couple of seconds is both daft and wasteful of power.
« Last Edit: September 08, 2016, 08:27:57 AM by Felix »

dave_sausages

  • Newbie
  • *
  • Posts: 49
Re: Is there a "data has been sent" flag?
« Reply #1 on: September 07, 2016, 11:17:30 AM »
Surely someone here knows how to tell if a message is sent on a Moteino without blocking?
« Last Edit: September 07, 2016, 10:07:09 PM by dave_sausages »

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Is there a "data has been sent" flag?
« Reply #2 on: September 08, 2016, 06:31:51 AM »
I don't use any libraries in my stuff, but looking through the RadioHead code there is a handleInterrupt() routine that increments a _txGood variable via a packet sent interrupt. Maybe there's a similar thing in Felix's library.
Mark.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Is there a "data has been sent" flag?
« Reply #3 on: September 08, 2016, 08:27:15 AM »
He was asking about RadioHead, unfortunately not really familiar with it and haven't used it for my own nodes.

Tostaki

  • Newbie
  • *
  • Posts: 7
  • Country: fr
Re: Is there a "data has been sent" flag in RadioHead?
« Reply #4 on: September 08, 2016, 11:25:22 AM »
Seems your need is the call of yourDriver.mode() function.
As per this enum, the answer is in it.

http://www.airspayce.com/mikem/arduino/RadioHead/classRHGenericDriver.html#a7c96558708f18937bc2fa7341f217937

If the mode is not RHModeTx then, the message has been sent (successfully or not is another question)
« Last Edit: September 08, 2016, 11:27:00 AM by Tostaki »

dave_sausages

  • Newbie
  • *
  • Posts: 49
Re: Is there a "data has been sent" flag in RadioHead?
« Reply #5 on: September 08, 2016, 01:21:57 PM »
Seems your need is the call of yourDriver.mode() function.
As per this enum, the answer is in it.

http://www.airspayce.com/mikem/arduino/RadioHead/classRHGenericDriver.html#a7c96558708f18937bc2fa7341f217937

If the mode is not RHModeTx then, the message has been sent (successfully or not is another question)

Just to make sure I understand.....

If I execute this instruction:

Code: [Select]
rf95.send((uint8_t*)buffer, sendLen+1);

Then the Arduino sends the data to the buffer of the radio, and when all the data has been passed on to the radio module to send, it moves on from the instruction?

And when the radio module finishes sending the data, it automatically goes into receive mode? Or do I need to repeatedly try to an put it in receive mode? I'm guessing that I will need to constantly call the mode() function to test for the mode, and when it says RXmode, I know it must have finished sending.

The use of this library is still a little confusing to me.

How do I use the function rf95.mode()? Do I put a string inside the brackets that I was it to fill with RHModeTx or something? I can't find any examples of its use online to help.

« Last Edit: September 08, 2016, 01:28:09 PM by dave_sausages »

Tostaki

  • Newbie
  • *
  • Posts: 7
  • Country: fr
Re: Is there a "data has been sent" flag in RadioHead?
« Reply #6 on: September 14, 2016, 03:57:05 AM »
If you get a "RHModeTx" answers, the documentation explains that the TX is in process.


However, I'm using this code to make sure the payload is sent

Code: [Select]
rf95.send(mydata.txData, txData_size);
rf95.waitPacketSent(RF_TXTIMEOUT);

Here a sample of my full code using Radiohead

To go deeper in the Lib, there is the spiRead() method inherited from RHSPIDriver. Having a look on the SX1276 datasheet, the 0x11 & 0x12 registers migth contain the information you want
« Last Edit: September 14, 2016, 06:11:20 AM by Tostaki »