jgromes / RadioLib

Universal wireless communication library for embedded devices
https://jgromes.github.io/RadioLib/
MIT License
1.57k stars 393 forks source link

First byte in the byte array received is the length of the array #408

Closed jbirmingham40 closed 2 years ago

jbirmingham40 commented 2 years ago

I tested out your RF69_Receive and RF69_Transmit examples using the commented out code for sending byte arrays. The byte array returned does not match the one sent. After some debugging it appears that you are prepending the size before sending the array and not removing it before returning the array. If I skip the first element of the array I get what I expect however this is probably not what you intended.

jbirmingham40 commented 2 years ago

Something else is going on. It seems that I have to send in an array of 64 bytes in order to get the correct results. I worked around the issue. You can close this.

jgromes commented 2 years ago

prepending the size before sending the array

That is intentional, and is how RF69 operates in variable packet length mode (which is the default).

However, there was indeed a bug in the logic resolving the number of actually received bytes vs. the number of bytes user wants to read. It should be fixed now, thanks for reporting.