LowPowerLab Forum

Hardware support => RF - Range - Antennas - RFM69 library => Topic started by: dave_sausages on September 02, 2016, 11:55:00 PM

Title: Is there a "data has been sent" flag in RadioHead?
Post by: dave_sausages 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.
Title: Re: Is there a "data has been sent" flag?
Post by: dave_sausages 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?
Title: Re: Is there a "data has been sent" flag?
Post by: perky 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.
Title: Re: Is there a "data has been sent" flag?
Post by: Felix 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.
Title: Re: Is there a "data has been sent" flag in RadioHead?
Post by: Tostaki 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 (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)
Title: Re: Is there a "data has been sent" flag in RadioHead?
Post by: dave_sausages 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 (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.

Title: Re: Is there a "data has been sent" flag in RadioHead?
Post by: Tostaki 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 (https://lowpowerlab.com/forum/rf-range-antennas-rfm69-library/mega-rfm95w-my-experience-with-radiohead-lib/)

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