TheThingsNetwork / lorawan-devices

Device Repository for LoRaWAN devices
Apache License 2.0
191 stars 367 forks source link

Generic Node Payload Formatter update #638

Closed azerimaker closed 1 year ago

azerimaker commented 1 year ago

Summary

Already existing Generic Node (SE) payload formatter is incomplete, since couple of month we added button state as well. Therefore it would be nice to have it updated. Please use the JS payload formatter below.

Why do we need this?

Button states are now omitted from the decoded payload.

What is already there? What do you see now?

Existing payload formatter is incomplete.

What is missing? What do you want to see?

Updated payload formatter is also given in the documentation.

function decodeUplink(input) {
  var data = {};
  data.batt_volt = (input.bytes[0]/10);
  data.temperature = (((input.bytes[1] << 8) + input.bytes[2]) - 500)/10;
  data.humidity = ((input.bytes[3] << 8) + input.bytes[4])/10;
  data.button = input.bytes[5];

  return {
    data: data,
  };
}

Can you do this yourself and submit a Pull Request?

@Jaime-Trinidad please check.

KrishnaIyer commented 1 year ago

@Jaime-Trinidad: Please check if this update is needed.