Skip to content

Commit

Permalink
version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrus committed Aug 1, 2018
1 parent 79aaad3 commit 3a10dc6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions examples/example.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console: 0 */
const ccznp = require('../index.js');

const spCfg = {
Expand Down
13 changes: 8 additions & 5 deletions lib/zpiObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ ZpiObject.prototype.frame = function() {
this.args.forEach(function(arg, idx) {
const type = arg.type;
const val = arg.value;
let msb;
let lsb;
let tempBuf;
let idxbuf;

switch (type) {
case 'uint8':
Expand All @@ -170,15 +174,14 @@ ZpiObject.prototype.frame = function() {
break;
case 'longaddr':
// string '0x00124b00019c2ee9'
const msb = parseInt(val.slice(2, 10), 16);
const lsb = parseInt(val.slice(10), 16);
msb = parseInt(val.slice(2, 10), 16);
lsb = parseInt(val.slice(10), 16);

dataBuf = dataBuf.uint32le(lsb).uint32le(msb);
break;
case 'listbuffer':
// [ 0x0001, 0x0002, 0x0003, ... ]
const tempBuf = new Buffer(val.length * 2);
let idxbuf;
tempBuf = new Buffer(val.length * 2);

for (idxbuf = 0; idxbuf < val.length; idxbuf += 1) {
tempBuf.writeUInt16LE(val[idxbuf], idxbuf * 2);
Expand Down Expand Up @@ -399,7 +402,7 @@ function bindTableList(buf, listcount) {
item: {},
thisItemLen: 0,
};
const itemLen = 21;
let itemLen = 21;
const item = {};
let i = 0;

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zigbee-bridge-znp",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",

"description": "The interface for a host to communicate with TI CC253X Zigbee Network Processor(ZNP) over a serial port.",
Expand Down Expand Up @@ -58,6 +58,6 @@
"mocha": "^2.5.3",

"eslint": "5.2.0",
"eslint-config-open-zigbee": "0.0.2"
"eslint-config-open-zigbee": "0.0.3"
}
}
2 changes: 1 addition & 1 deletion test/ccznp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('Functional Check', function() {
ccznp._unpi.send = () => {};
ccznp.request('SYS', 'ping', {}, function(err, result) {
if (err) {
console.log(err);
throw err;
} else if (result === rsp && ccznp._spinLock === false) {
done();
}
Expand Down
8 changes: 4 additions & 4 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ function randomArgForParse(type, name) {
case 'preLenBeaconlist':
preBufLen = chance.integer({min: 1, max: 2}) * 21;
return preBufLen / 21;
case 'uint8ZdoInd':
return chance.integer({min: 0, max: 255});
case 'dynbuffer':
testBuf = new Buffer(preBufLen);
for (k = 0; k < preBufLen; k += 1) {
Expand All @@ -210,6 +208,8 @@ function framer() {
this.args.forEach(function(arg, idx) {
const type = arg.type;
const val = arg.value;
let msb;
let lsb;

switch (type) {
case 'uint8':
Expand Down Expand Up @@ -240,8 +240,8 @@ function framer() {
dataBuf = dataBuf.uint16(val);
break;
case 'longaddr':
const msb = parseInt(val.slice(2, 10), 16);
const lsb = parseInt(val.slice(10), 16);
msb = parseInt(val.slice(2, 10), 16);
lsb = parseInt(val.slice(10), 16);

dataBuf = dataBuf.uint32le(lsb).uint32le(msb);
break;
Expand Down

0 comments on commit 3a10dc6

Please sign in to comment.