Skip to content

Commit 83258f8

Browse files
authored
fix(bitmap): decoder was decoding bitmaps with leading false incorrectly (#14)
* fix(bitmap): decoder was decoding bitmaps with leading false incorrectly #13 * fix gopath * Revert "fix gopath" This reverts commit 8b538ed. * GOPATH fixes * more fixes * chore: build fixes * chore: lcov * chore: build fixes * use apt addon * reinit semantic release
1 parent 2b852f3 commit 83258f8

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
language: node_js
2+
addons:
3+
apt:
4+
packages:
5+
- lcov
26
cache:
37
yarn: true
48
directories:
@@ -8,10 +12,9 @@ notifications:
812
node_js:
913
- stable
1014
before_install:
11-
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace:$GOPATH"
15+
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
1216
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
1317
- go get -v github.com/robertkrimen/otto/otto # Download otto JS interpreter
14-
- sudo apt-get install lcov
1518
script:
1619
- yarn lint
1720
- FORCE_COLOR=true yarn test

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lora-serialization",
3-
"version": "3.0.0",
3+
"version": "0.0.0-development",
44
"description": "LoraWAN serialization/deserialization library for The Things Network",
55
"main": "src/index.js",
66
"directories": {
@@ -38,7 +38,7 @@
3838
"eslint": "^3.0.1",
3939
"lcov-result-merger": "^1.2.0",
4040
"nyc": "^10.1.2",
41-
"semantic-release": "^6.3.2"
41+
"semantic-release": "^6.3.6"
4242
},
4343
"config": {
4444
"commitizen": {

src/decoder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var bitmap = function(byte) {
8282
throw new Error('Bitmap must have exactly 1 byte');
8383
}
8484
var i = bytesToInt(byte);
85-
var bm = Number(i).toString(2).split('').map(Number).map(Boolean);
85+
var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean);
8686
return ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
8787
.reduce(function(obj, pos, index) {
8888
obj[pos] = bm[index];

test/base.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,15 @@ module.exports = {
2525
h: true
2626
},
2727
bitmapBytes: new Buffer([253]),
28+
bitmap2: {
29+
a: false,
30+
b: true,
31+
c: false,
32+
d: false,
33+
e: false,
34+
f: false,
35+
g: false,
36+
h: false
37+
},
38+
bitmap2Bytes: new Buffer([64]),
2839
};

test/decoder/bitmap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ test('should be possible to decode a bitmap', t => {
1414
t.deepEqual(decoder.bitmap(base.bitmapBytes), base.bitmap);
1515
t.pass();
1616
});
17+
test('should be possible to decode a bitmap with leading false', t => {
18+
t.deepEqual(decoder.bitmap(base.bitmap2Bytes), base.bitmap2);
19+
t.pass();
20+
});

0 commit comments

Comments
 (0)