Closed DawKaw closed 2 years ago
That's odd, I'll take a look at it.
PS: The manual dedcoding must have taken quite some time - I suggest giving Universal Radio Hacker a go ;)
Found out what's the issue - you're calling getPacketLength()
after readData()
, which is not a use case I expected. Internally, getPacketLength()
retrieves packet length of the last received packet from the radio, and is called by readData()
. However, once readData()
is called, the packet is considered processed (the FIFO gets emptied etc.) and if you call getPacketLength()
again, you're basically doing it before another packet arrives.
The solution is to simply call getPacketLength(false)
, which will return cached value of the last received packet and will not perform length update.
Alternatively, call getPacketLength()
prior to calling readData()
, which is the expected way to use the method (usually, you first need to know how much data you received, before you try to read them).
Thank you very much for your help. I didn't know that the getPacketLength() function affected the received buffer in this way. I corrected the code according to your tip, everything works fine. I was confused that in LoRa mode, receiving was still working properly.
Ps. I like the way your code is written.
The difference is that in FSK mode, packet length gets pulled from the same FIFO buffer as data. In LoRa mode, packet length is handled differently.
Thanks, I'm glad you like it!
I am trying to correctly communicate between the two SX1278 in FSK mode, but it fails. The first frame is received correctly. All the bytes go there, but not the next time. On subsequent frames, the byte informing about the frame length sticks to the beginning of the received buffer, and the last byte is lost. Such a phenomenon does not occur in LoRa mode.
I am using:
Transmitter repeatly sending "48 65 6C 6C 6F" (Hello). Receiver after restart, received first frame correctly, but not next. Below receiver side serial output:
Transmitting side code:
Receiving side code:
Here manual decoded transmision: