TheThingsNetwork / lorawan-devices

Device Repository for LoRaWAN devices
Apache License 2.0
197 stars 383 forks source link

Best practises guidelines ? #237

Closed Oliv4945 closed 3 years ago

Oliv4945 commented 3 years ago

Summary

Each manufacturer implemented the output of decodeUplink() in its own way. ex:

Elsys:

data: {
    temperature: 19.4,
    humidity: 66,
    vdd: 3584,
    distance: 300,
    pressure: 1015.559
  }

There is no indication of the unit used, some are SI (ex: temperature), some are not (ex: vdd is in mV) Battery is called vdd

Decentlab

data: {
    protocol_version: 2,
    device_id: 6429,
    distance: { displayName: 'Distance', value: 902, unit: 'mm' },
    number_of_valid_samples: {
      displayName: 'Number of valid samples',
      value: 15,
      unit: undefined
    },
    battery_voltage: { displayName: 'Battery voltage', value: 2.888, unit: 'V' }
  }

The unit is provided in a new object for each parameter Battery is called battery_voltage

Tektelic

data: {
    raw: '[01, 04, 05, 35, 02, 02, 02, EA, 0B, 68, 98]',
    port: '10',
    input1_frequency: 1333,
    input2_voltage: 746,
    relative_humidity: 76
  }

No unit Raw payload is provided, which is a duplicate for the input

Why do we need this?

It would be easier to use decoders output if the device repository have recommendations toward decoder implementer so all decoders are providing data in SI, or at least with the unit. It will also help if all data can share names like: "temperature instead" of "temp"...

What is already there? What do you see now?

Inconsistent decoder output

How do you propose to implement this?

Update guidelines to describe a format. I have no hard feeling about it, just have it consistent when possible

Can you do this yourself and submit a Pull Request?

Maybe

nejraselimovic commented 3 years ago

Thanks @Oliv4945, this is a nice suggestion indeed! @Jaime-Trinidad could you please help with defining a document with some best practices?

Jaime-Trinidad commented 3 years ago

Hi @Oliv4945 thank you for the suggestion, we will work on this.

nejraselimovic commented 3 years ago

References #33

Jaime-Trinidad commented 3 years ago

@Oliv4945 as every device maker make their decoders I added as a recommendation in the Device Repository README file, also will be a great feature for standardised files in the future. Please look PR #245

nejraselimovic commented 3 years ago

@Jaime-Trinidad I think there are still things to be addressed here, besides units - you could also add a note in #245 to tell people they should use full variable names instead of abbreviations (temperature vs temp).

Jaime-Trinidad commented 3 years ago

@nejraselimovic you are right, I'm was thinking in two things for the moment, also thinking this can impact on file size:

in Decentlab example they use almost 40 lines of code only for their units.

Oliv4945 commented 3 years ago

Hi,

Sorry I replied late but I agree with @nejraselimovic and would recommend to go a step further:

Explain how to specify unit and the value ex: voltage: { "value": 3.3, "unit": "V"} or {voltage_V: 3.3} Even more I'll recommend to use SI units or specify that each unit should be used for a lot of physical values. ex: a pressure can be 1000 Pa (SI unit) but also 0.01 Bar, 10 mBar or 0.145 Psi