Giter Site home page Giter Site logo

Comments (5)

joscha avatar joscha commented on May 22, 2024

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.

from lora-serialization.

shypard avatar shypard commented on May 22, 2024

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 :-)

from lora-serialization.

joscha avatar joscha commented on May 22, 2024

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?

from lora-serialization.

shypard avatar shypard commented on May 22, 2024

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.

from lora-serialization.

joscha avatar joscha commented on May 22, 2024

from lora-serialization.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.