Closed shypard closed 1 year ago
Hi,
My assumption is that the ttn side implementation no longer has .slice
implemented.
Can you try: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#calling_slice_on_non-array_objects
E.g.:
Array.prototype.slice.call(bytes, x, x + 1)
in your case and see if that works? If not, then we'll need to provide a slice implementation or manually pick the right bytes.
Many thanks @joscha for the (indirect) hint, I found the error!
Turned out the bytes
parameter was a dictionary, containing another key called bytes
. Running the following snippet:
function decodeUplink(bytes) {
throw new Error(JSON.stringify(bytes))
}
shows the passed bytes
object:
{
"bytes": [1, 2, 3],
"fPort":10
}
Now we can convert them using
data.fPort = uint8(bytes.bytes.slice(x, x + 1));
BR, Christian :-)
I see, great! Did you copy that sample from somewhere in the docs? If yes, would you mind opening a PR to fix it, please?
No, the bytes
data sample was from one of my tests. I just used the converter snippets from the README.md, like:
uint8(bytes.slice(x, x + 1)) // 10
I can however create a PR to replace the bytes
with bytes.bytes
or probably more understandable payload.bytes
, if you want.
Yes please!
On Thu, 20 Oct 2022, 10:45 Christian, @.***> wrote:
No, the bytes data sample was from one of my tests. I just used the converter snippets from the README.md https://github.com/thesolarnomad/lora-serialization/blob/master/README.md, like:
uint8(bytes.slice(x, x + 1)) // 10
I can however create a PR to replace the bytes with bytes.bytes or probably more understandable payload.bytes, if you want.
— Reply to this email directly, view it on GitHub https://github.com/thesolarnomad/lora-serialization/issues/52#issuecomment-1285241722, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABN5BXSRGDHNRA5NITR2VLWEEIELANCNFSM6AAAAAARI2CVQI . You are receiving this because you were mentioned.Message ID: @.***>
Hi!
First off, thanks for the Library, works great on Arduino / ESP Side. However I have still troubles decoding the data on the TTN side. For the uplink formatter I have got the example code as such:
However upon testing I am receiving the above error:
TypeError: Object has no member 'slice' at decodeUplink (<eval>:5:32(15))
Does thebytes
object need to be converted first, in order to useslice()
or should I use it differently?Thanks & BR :)