thesolarnomad / lora-serialization

LoraWAN serialization/deserialization library for The Things Network
MIT License
164 stars 26 forks source link

sign of temperature values ignored #9

Closed noerw closed 7 years ago

noerw commented 7 years ago

it's impossible to decode negative temperature values; the positive value is always returned. don't know if its an error in the decode or encode function, or both. see this code:

const ls = require('lora-serialization'),
  enc = ls.encoder, dec = ls.decoder;

const buf = enc.encode([-25.3], [enc.temperature]);

// { temperature: 25.3 }
console.log(dec.decode(buf, [dec.temperature], ['temperature']));
joscha commented 7 years ago

Hi, thanks for the report. I can confirm temperatures between -81 and 0 and temperatures greater 82 seem to be affected. Haven't looked into the exact cause, yet, happy to merge any PR.

noerw commented 7 years ago

thanks for the quick fix! :+1: