I'm trying to send a small picture (about 1KB) with LoRa. I turned the picture into small packets about 200 bayt and want to send it with that way. To do that I'll need a ACK mechanism. Basically I'll send a packet to receiver and receiver will send me the packet number as ACK. If I receive ACK from transmitter then I'll send the next packet. It'll go all along the packets.
The part that I stuck is sending ACK from receiver. I can send ACK for just one time if I receive the packet without error. But just one sending process is not enough to work. Need to send continuously old ACK data. So transmitter can catch that easily and jump to the next packet.
I'm not sure that I explain correctly but If you ask a part I'll try to explain it much better.
It's not working correctly. There are a lot of radio.sleep or begin functions, I'm actually not sure that is I need them but I worked better then without them. And there's a weird things like sometimes when I change the code Arduino waits like 7 seconds however there's no any delay function. I think that is listening time or something but I cannot find it in the libraries.
You have only posted a small piece of code without context which makes it very difficult to give clear advice. Posting the whole sketch will prevent lots of questions and make it much easier to help as per the forum guidelines.
Is the code you have posted called as a function - if so from where, is the code just a part of the loop function - if so what else is setting the variables? For example packetsReceived appears to be used but no indication of what it is set to.
If a packet arrives for example truncated will you acknowledge that packet - would you even know?
Does the sender automatically resend a unacknowledged packet, if so how do you treat the arrival of a duplicate packet?
Not sure what you mean by "Need to send continuously old ACK data." can you expand on that?
Thank you for your comment. The code that I mention is just a loop part of receiver code. Because there aren't any problem in the other parts. I need help in just using two way communication in Arduino with using Radiolib library.
"Need to send continuously old ACK data" I wanted to say If transmitter couldn't receive the ACK then receiver will send ACK again.
"If a packet arrives for example truncated will you acknowledge that packet - would you even know?"
I've a CRC mechanism so if a receive the packet without problem (state == ERR_NONE) then I can send ACK.
"Does the sender automatically resend a unacknowledged packet, if so how do you treat the arrival of a duplicate packet?"
There are like 10 packets, in front of packets they have a packet number. I'll send them in order, like I'll send first packet until I receive first packet's ACK data. Then sender will start to sending second packet.
These projects use my library that includes sequence numbers and acks and resends for Radio
LoRa/Radio Long Range Garage Door Controller – A point-to-point LoRa in-car remote control and garage door receiver. 128bit security and indication the door has reached the required position. The door can also be controlled from your Android mobile, via a WiFi to Radio bridge, with a visual display of the door's position