Skip to content

Commit

Permalink
feat: Add tunnel cluter (#806)
Browse files Browse the repository at this point in the history
* Add tunnel cluter

* add test case

* fix lint error
  • Loading branch information
xsp1989 committed Nov 20, 2023
1 parent 09a24e8 commit e4d8cbe
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/controller/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const CommandsLookup: {[s: string]: MessagePayloadType} = {
'zosungSendIRCode00': 'commandZosungSendIRCode00',
'zosungSendIRCode03Resp': 'zosungSendIRCode03Resp',
'zosungSendIRCode05Resp': 'zosungSendIRCode05Resp',
'transferDataResp': 'transferDataResp',

// Schneider
'schneiderWiserThermostatBoost':'commandSchneiderWiserThermostatBoost',
Expand Down Expand Up @@ -161,7 +162,8 @@ type MessagePayloadType =
'commandMoveToHue' | 'commandStore'| 'commandWiserSmartSetSetpoint' | 'commandWiserSmartCalibrateValve' |
'commandSiglisZigfredButtonEvent' | 'commandDanfossSetpointCommand' | 'commandZosungSendIRCode00' |
'commandZosungSendIRCode01' | 'commandZosungSendIRCode02'|'commandZosungSendIRCode04' | 'zosungSendIRCode03Resp' |
'zosungSendIRCode05Resp' | 'commandMcuGatewayConnectionStatus' | 'commandSchneiderWiserThermostatBoost';
'zosungSendIRCode05Resp' | 'commandMcuGatewayConnectionStatus' | 'commandSchneiderWiserThermostatBoost' |
'transferDataResp';

interface MessagePayload {
type: MessagePayloadType;
Expand Down
2 changes: 2 additions & 0 deletions src/zcl/buffaloZcl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ class BuffaloZcl extends Buffalo {
return this.readArray();
} else if (type === 'struct') {
return this.readStruct();
} else if (type === 'BUFFER') {
return this.readBuffer(this.buffer.length);
} else {
// TODO: remove uppercase once dataTypes are snake case
return super.read(type.toUpperCase(), options);
Expand Down
23 changes: 23 additions & 0 deletions src/zcl/definition/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,29 @@ const Cluster: {
},
},
},
tunneling: {
ID: 0x0704,
attributes: {
},
commands: {
transferData: {
ID: 2,
parameters: [
{name: 'tunnelID', type: DataType.uint16},
{name: 'data', type: BuffaloZclDataType.BUFFER},
],
},
},
commandsResponse: {
transferDataResp: {
ID: 1,
parameters: [
{name: 'tunnelID', type: DataType.uint16},
{name: 'data', type: BuffaloZclDataType.BUFFER},
],
},
},
},
telecommunicationsInformation: {
ID: 2304,
attributes: {
Expand Down
7 changes: 7 additions & 0 deletions test/zcl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1644,4 +1644,11 @@ describe('Zcl', () => {
expect(buffalo.getPosition()).toBe(4);
expect(buffer).toStrictEqual(expected);
});

it('BuffaloZcl read BUFFER', () => {
const buffer = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]);
const buffalo = new BuffaloZcl(buffer);
const value = buffalo.read(BuffaloZclDataType[BuffaloZclDataType.BUFFER], {});
expect(value).toStrictEqual(Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]));
});
});

0 comments on commit e4d8cbe

Please sign in to comment.