PiSupply / RAK811-Arduino

Arduino Library for Pi Supply LoRa Node Shield
MIT License
7 stars 7 forks source link

rk_sendBytes() delivers a payload that ends with a random number of extra characters #12

Open pedbry opened 3 years ago

pedbry commented 3 years ago

I'm using the RAK811 library (downloaded in may 2021) in my devices (Arduino Uno with a RAK811-shield) and I have had no problem sending simple payloads to my application in The Things Network. They are picked up by my two local TTIG:s and I can check them in the TTN-Console (V2).

But I did get a little problem when I wanted to read from a set of DS18B20 temperature-sensors with CayenneLPP and then send the resulting lpp.buffer to my application with the rk_sendBytes() function in the RAK811 library. When I checked in my TTN-Console the payloads were not decoded to temperature-fields etc. The payload seemed to end with a random number of extra characters.

Example

When I saw the result and had a closer look at the code I realized that the problem might be that the function that converts the lpp.buffer to a string doesn't add a finishing zero.

I have now added the extra line indicated in the code below to my RAK811.cpp:

image

I have tested my solution and it seems to be stable.

Might this be something that @rbricheno can fix?

I have also made a comment about this here: https://github.com/PiSupply/RAK811-Arduino/issues/6#issuecomment-850843358

Pedbry