thesolarnomad / lora-serialization

LoraWAN serialization/deserialization library for The Things Network
MIT License
165 stars 27 forks source link

Add example decodeUplink() function in README.md #53

Closed shypard closed 2 years ago

shypard commented 2 years ago

Hi, as discussed in #52 I added an example for the decodeUplink() function and updated all the bytes.slice with input.bytes.slice in the README.md .

The decodeUplink() function takes a input parameter, which contains the sent bytes (See TTN-Docu):

function decodeUplink(input) {
  // input has the following structure:
  // {
  //   "bytes": [1, 2, 3], // FRMPayload (byte array)
  //   "fPort": 1
  // }
  return {
    data: {
      bytes: input.bytes
    },
    warnings: ["warning 1", "warning 2"], // optional
    errors: ["error 1", "error 2"] // optional (if set, the decoding failed)
  };
}