Skip to content

Commit

Permalink
Suport PTM 216Z raw data. Koenkk/zigbee2mqtt#3322
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Apr 15, 2020
1 parent 6db9e76 commit c7d43cb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/zcl/buffaloZcl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ class BuffaloZcl extends Buffalo {
keyMic: this.readUInt32(),
outgoingCounter: this.readUInt32(),
};
} else if (this.position != this.buffer.length) {
return {raw: this.buffer.slice(this.position)};
} else {
return {};
}

return {};
}

private readUInt40(): TsType.Value {
Expand Down
28 changes: 28 additions & 0 deletions test/zcl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,34 @@ describe('Zcl', () => {
expect(frame.Payload).toStrictEqual(payload);
});

it('ZclFrame from buffer GDP with extra data', () => {
const buffer = [0x11, 0x00, 0x00, 0xa0, 0x14, 0xfe, 0xf4, 0x46, 0x00, 0xe5, 0x04, 0x00, 0x00, 0x10, 0xff, 0x01];
const frame = Zcl.ZclFrame.fromBuffer(Zcl.Utils.getCluster("greenPower").ID, Buffer.from(buffer));
const header = {
commandIdentifier: 0,
frameControl: {
direction: 0,
disableDefaultResponse: true,
frameType: 1,
manufacturerSpecific: false,
},
manufacturerCode: null,
transactionSequenceNumber: 0,
};

const payload = {
srcID: 4650238,
commandFrame: {raw: Buffer.from([1])},
commandID: 16,
frameCounter: 1253,
options: 5280,
payloadSize: 255,
};

expect(frame.Header).toStrictEqual(header);
expect(frame.Payload).toStrictEqual(payload);
});

it('ZclFrame from buffer readRsp alias type', () => {
const buffer = [8, 1, 1, 1, 0, 0, 8, 3];
const frame = Zcl.ZclFrame.fromBuffer(Zcl.Utils.getCluster("genBasic").ID, Buffer.from(buffer));
Expand Down

0 comments on commit c7d43cb

Please sign in to comment.