thesolarnomad / lora-serialization

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

Decode Bitmap returns wrong values if the first bit is false. #13

Closed ssozonoff closed 7 years ago

ssozonoff commented 7 years ago

message .addBitmap(false, true, false, true, false, false, false, false)

Returns less than 8 flags and the values seem to be offset.

joscha commented 7 years ago

Thanks for the report @ssozonoff - I am on mobile right now - can you write a failing test case and/or give an example?

ssozonoff commented 7 years ago

Hi,

As far as I am concerned the below does not deserialise correctly TTN side. There are only 6 flags returned from a-g

Setting the first value to true and we get flags for a-h

        message          
          .addTemperature(measuredvbat)
          .addBitmap(false, true, false, false, false, false, false, false);

TTN Side decoded = decode(bytes, [temperature, bitmap], ['battery', 'status']);

{
  "battery": 3.68,
  "status": {
    "a": true,
    "b": false,
    "c": false,
    "d": false,
    "e": false,
    "f": false,
    "g": false
  }
}
joscha commented 7 years ago

@ssozonoff sorry about the long wait, this is now fixed and released in lora-serialization@3.0.1