help with different send and receive commands please.

Started by dave_sausages, August 12, 2016, 03:52:27 PM

dave_sausages

So I've already made a project that sends gps coordinates between two devices using two 915MHz LoRa moteinos. The problem is I'm now looking to optimize my code as I want the project to do more things, but it seems to spend most of its time sending an receiving radio data and not being able to do other things. So....

What do the various radio commands do exactly?

I've been using "manager.sendtoWait" which I believe sends a packet and then pauses the program until it receives some data back from the device it just sent to. Is that correct? I'm thinking that maybe just a simple send and wait for acknowledgement commands might suit me better?

I found a "radio.sendWithRetry" command detailed by felix in https://lowpowerlab.com/forum/moteino/getting-started-with-sending-radiowireless-payloads/ which suggests that it just sends and waits for a simple acknowledgment, but I can't get it to work in my code. I changed "radio.sendWithRetry" to "manager.sendWithRetry" and it still won't work.

I have this code at the start of my program that I believe says I should call radio commands with "manager" and not radio is that correct?
RH_RF95 driver;

RHReliableDatagram manager(driver, CLIENT_ADDRESS);


If anyone can help steer me in the direction of how to understand these different send and receive functions, and examples of them being used, it would help me a lot.

And I'm using LoRa 915 moteinos if that helps.

Cheers

Dave


Felix


dave_sausages

#2
Thanks Felix,

After some searching I have found that "sendtowait" (what i was using) does indeed send some data, and then waits to hear an ack, or resends until it reaches the max number of re-tries. Details here in case anyone else is learning like me.http://www.airspayce.com/mikem/arduino/RadioHead/classRHReliableDatagram.html

I re-jigged my code and I now have nice one way comms working in a smooth manner (with acks of course).

And if I may be so bold: Is there an easy way to understand how the receiving of data works? For instance is it held in the buffer of the LoRa module until I call it? Or do I need to call "manager.recvfromAck" a lot? Basically one of my units is sending out it's GPS data using "sendtowait" once per second, and my other unit is almost constantly running manager.recvfromAck. So unit 1 sends and looks for ack, unit 2 constantly listens and then sends an ack when it receives data.

I am getting into real trouble when trying to get unit 2 to also send data to unit 1. My guess is either cross-talk (both tx at the same time), or unit 1 is not in receiving mode when unit 2 is sending.

Sorry for the questions, but everything I've been told on this forum has been written down by me and learnt.

Felix

Since I haven't used this library except for testing I can only guess that's how it works (as you describe). You put the radio in RX mode and then you repeatedly poll the radio to check if data was received in the buffers then you move that data and do whatever you need with it. That is also how RFM69 works. But again, RF95 is part of RadioHead, not really widely discussed here. But there are others who use LoRa quite a lot so they may add their knowledge if they see this thread.