zigbee-herdsman 5.0.4 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +3 -0
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/typedoc.yaml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +29 -0
- package/biome.json +1 -1
- package/dist/adapter/ember/ezsp/buffalo.d.ts +0 -2
- package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.js +0 -4
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.js +0 -2
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +5 -0
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +7 -0
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +8 -11
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/events.d.ts +2 -1
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/helpers/request.d.ts.map +1 -1
- package/dist/controller/helpers/request.js +2 -1
- package/dist/controller/helpers/request.js.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.d.ts +2 -4
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +2 -0
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/model/device.d.ts +13 -24
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +88 -129
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +17 -16
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +31 -16
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts +6 -6
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +5 -3
- package/dist/controller/model/group.js.map +1 -1
- package/dist/controller/model/index.d.ts +1 -0
- package/dist/controller/model/index.d.ts.map +1 -1
- package/dist/controller/model/index.js +3 -1
- package/dist/controller/model/index.js.map +1 -1
- package/dist/controller/model/zigbeeEntity.d.ts +8 -0
- package/dist/controller/model/zigbeeEntity.d.ts.map +1 -0
- package/dist/controller/model/zigbeeEntity.js +11 -0
- package/dist/controller/model/zigbeeEntity.js.map +1 -0
- package/dist/controller/tstype.d.ts +39 -0
- package/dist/controller/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.d.ts +32 -17
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.js +257 -121
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/cluster.js +156 -33
- package/dist/zspec/zcl/definition/cluster.js.map +1 -1
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts +2 -0
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js +348 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts +7238 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.js +3 -0
- package/dist/zspec/zcl/definition/clusters-types.js.map +1 -0
- package/dist/zspec/zcl/definition/enums.d.ts +14 -6
- package/dist/zspec/zcl/definition/enums.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/enums.js +15 -6
- package/dist/zspec/zcl/definition/enums.js.map +1 -1
- package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/foundation.js +43 -15
- package/dist/zspec/zcl/definition/foundation.js.map +1 -1
- package/dist/zspec/zcl/definition/tstype.d.ts +105 -11
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/index.d.ts +1 -0
- package/dist/zspec/zcl/index.d.ts.map +1 -1
- package/dist/zspec/zcl/index.js.map +1 -1
- package/dist/zspec/zcl/utils.d.ts +1 -1
- package/dist/zspec/zcl/utils.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.js +1 -1
- package/dist/zspec/zcl/utils.js.map +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zspec/zcl/zclFrame.js +32 -20
- package/dist/zspec/zcl/zclFrame.js.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.d.ts +0 -6
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.js +0 -8
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter/ember/ezsp/buffalo.ts +0 -5
- package/src/adapter/ember/uart/ash.ts +0 -2
- package/src/adapter/ezsp/driver/driver.ts +1 -1
- package/src/buffalo/buffalo.ts +8 -0
- package/src/controller/controller.ts +13 -16
- package/src/controller/events.ts +2 -1
- package/src/controller/greenPower.ts +4 -4
- package/src/controller/helpers/request.ts +3 -1
- package/src/controller/helpers/zclFrameConverter.ts +13 -17
- package/src/controller/model/device.ts +103 -148
- package/src/controller/model/endpoint.ts +112 -64
- package/src/controller/model/group.ts +33 -9
- package/src/controller/model/index.ts +1 -0
- package/src/controller/model/zigbeeEntity.ts +30 -0
- package/src/controller/tstype.ts +251 -16
- package/src/zspec/zcl/buffaloZcl.ts +323 -238
- package/src/zspec/zcl/definition/cluster.ts +156 -33
- package/src/zspec/zcl/definition/clusters-typegen.ts +588 -0
- package/src/zspec/zcl/definition/clusters-types.ts +7331 -0
- package/src/zspec/zcl/definition/enums.ts +14 -5
- package/src/zspec/zcl/definition/foundation.ts +43 -15
- package/src/zspec/zcl/definition/tstype.ts +118 -8
- package/src/zspec/zcl/index.ts +1 -0
- package/src/zspec/zcl/utils.ts +1 -1
- package/src/zspec/zcl/zclFrame.ts +37 -19
- package/src/zspec/zdo/buffaloZdo.ts +0 -9
- package/test/controller.test.ts +356 -896
- package/test/greenpower.test.ts +0 -12
- package/test/zcl.test.ts +13 -11
- package/test/zspec/zcl/buffalo.test.ts +216 -74
- package/test/zspec/zcl/frame.test.ts +62 -28
- package/test/zspec/zcl/utils.test.ts +4 -4
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import { Buffalo } from "../../buffalo";
|
|
2
2
|
import { BuffaloZclDataType, DataType } from "./definition/enums";
|
|
3
3
|
import type { BuffaloZclOptions } from "./definition/tstype";
|
|
4
|
-
export interface GPDChannelConfiguration {
|
|
5
|
-
commandID: number;
|
|
6
|
-
operationalChannel: number;
|
|
7
|
-
basic: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface GPDCommissioningReply {
|
|
10
|
-
commandID: number;
|
|
11
|
-
options: number;
|
|
12
|
-
/** expected valid if corresponding `options` bits set */
|
|
13
|
-
panID?: number;
|
|
14
|
-
/** expected valid if corresponding `options` bits set */
|
|
15
|
-
securityKey?: Buffer;
|
|
16
|
-
/** expected valid if corresponding `options` bits set */
|
|
17
|
-
keyMic?: number;
|
|
18
|
-
/** expected valid if corresponding `options` bits set */
|
|
19
|
-
frameCounter?: number;
|
|
20
|
-
}
|
|
21
4
|
export declare class BuffaloZcl extends Buffalo {
|
|
5
|
+
private writeZclUInt8;
|
|
6
|
+
private readZclUInt8;
|
|
7
|
+
private writeZclUInt16;
|
|
8
|
+
private readZclUInt16;
|
|
9
|
+
private writeZclUInt24;
|
|
10
|
+
private readZclUInt24;
|
|
11
|
+
private writeZclUInt32;
|
|
12
|
+
private readZclUInt32;
|
|
13
|
+
private writeZclUInt40;
|
|
14
|
+
private readZclUInt40;
|
|
15
|
+
private writeZclUInt48;
|
|
16
|
+
private readZclUInt48;
|
|
17
|
+
private writeZclUInt56;
|
|
18
|
+
private readZclUInt56;
|
|
19
|
+
private writeZclUInt64;
|
|
20
|
+
private readZclUInt64;
|
|
21
|
+
private writeZclInt8;
|
|
22
|
+
private readZclInt8;
|
|
23
|
+
private writeZclInt16;
|
|
24
|
+
private readZclInt16;
|
|
25
|
+
private writeZclInt24;
|
|
26
|
+
private readZclInt24;
|
|
27
|
+
private writeZclInt32;
|
|
28
|
+
private readZclInt32;
|
|
29
|
+
private writeZclInt40;
|
|
30
|
+
private readZclInt40;
|
|
31
|
+
private writeZclInt48;
|
|
32
|
+
private readZclInt48;
|
|
33
|
+
private writeZclInt56;
|
|
34
|
+
private readZclInt56;
|
|
35
|
+
private writeZclInt64;
|
|
36
|
+
private readZclInt64;
|
|
22
37
|
private writeOctetStr;
|
|
23
38
|
private readOctetStr;
|
|
24
39
|
private writeCharStr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffaloZcl.d.ts","sourceRoot":"","sources":["../../../src/zspec/zcl/buffaloZcl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAA0B,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"buffaloZcl.d.ts","sourceRoot":"","sources":["../../../src/zspec/zcl/buffaloZcl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAA0B,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EACR,iBAAiB,EAkBpB,MAAM,qBAAqB,CAAC;AAc7B,qBAAa,UAAW,SAAQ,OAAO;IAYnC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,OAAO;IAcf,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,QAAQ;IAgBhB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,yBAAyB;IA4BjC,OAAO,CAAC,aAAa;IAoDrB,OAAO,CAAC,YAAY;IA8IpB,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,sBAAsB;IAuB9B,OAAO,CAAC,4BAA4B;IAYpC,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,YAAY;IA0Bb,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAqOxF,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,GAAG,GAAG;CAkMpF"}
|
|
@@ -48,62 +48,204 @@ const EXTENSION_FIELD_SETS_DATA_TYPE = {
|
|
|
48
48
|
768: [enums_1.DataType.UINT16, enums_1.DataType.UINT16, enums_1.DataType.UINT16, enums_1.DataType.UINT8, enums_1.DataType.UINT8, enums_1.DataType.UINT8, enums_1.DataType.UINT16, enums_1.DataType.UINT16],
|
|
49
49
|
};
|
|
50
50
|
class BuffaloZcl extends buffalo_1.Buffalo {
|
|
51
|
+
// TODO: shuffles quite a lot of code (ZH is mostly typed `string | number` and ZHC requires lots of scrutiny)
|
|
52
|
+
// private writeZclBoolean(value: boolean | undefined): void {
|
|
53
|
+
// this.writeUInt8(value === undefined ? 0xff : value ? 1 : 0);
|
|
54
|
+
// }
|
|
55
|
+
// private readZclBoolean(): boolean | undefined {
|
|
56
|
+
// const value = this.readUInt8();
|
|
57
|
+
// return value === 0xff ? undefined : !!value;
|
|
58
|
+
// }
|
|
59
|
+
writeZclUInt8(value) {
|
|
60
|
+
this.writeUInt8(Number.isNaN(value) ? 0xff : value);
|
|
61
|
+
}
|
|
62
|
+
readZclUInt8() {
|
|
63
|
+
const value = this.readUInt8();
|
|
64
|
+
return value === 0xff ? Number.NaN : value;
|
|
65
|
+
}
|
|
66
|
+
writeZclUInt16(value) {
|
|
67
|
+
this.writeUInt16(Number.isNaN(value) ? 0xffff : value);
|
|
68
|
+
}
|
|
69
|
+
readZclUInt16() {
|
|
70
|
+
const value = this.readUInt16();
|
|
71
|
+
return value === 0xffff ? Number.NaN : value;
|
|
72
|
+
}
|
|
73
|
+
writeZclUInt24(value) {
|
|
74
|
+
this.writeUInt24(Number.isNaN(value) ? 0xffffff : value);
|
|
75
|
+
}
|
|
76
|
+
readZclUInt24() {
|
|
77
|
+
const value = this.readUInt24();
|
|
78
|
+
return value === 0xffffff ? Number.NaN : value;
|
|
79
|
+
}
|
|
80
|
+
writeZclUInt32(value) {
|
|
81
|
+
this.writeUInt32(Number.isNaN(value) ? 0xffffffff : value);
|
|
82
|
+
}
|
|
83
|
+
readZclUInt32() {
|
|
84
|
+
const value = this.readUInt32();
|
|
85
|
+
return value === 0xffffffff ? Number.NaN : value;
|
|
86
|
+
}
|
|
87
|
+
writeZclUInt40(value) {
|
|
88
|
+
this.writeUInt40(Number.isNaN(value) ? 0xffffffffff : value);
|
|
89
|
+
}
|
|
90
|
+
readZclUInt40() {
|
|
91
|
+
const value = this.readUInt40();
|
|
92
|
+
return value === 0xffffffffff ? Number.NaN : value;
|
|
93
|
+
}
|
|
94
|
+
writeZclUInt48(value) {
|
|
95
|
+
this.writeUInt48(Number.isNaN(value) ? 0xffffffffffff : value);
|
|
96
|
+
}
|
|
97
|
+
readZclUInt48() {
|
|
98
|
+
const value = this.readUInt48();
|
|
99
|
+
return value === 0xffffffffffff ? Number.NaN : value;
|
|
100
|
+
}
|
|
101
|
+
writeZclUInt56(value) {
|
|
102
|
+
this.writeUInt56(value === undefined ? 0xffffffffffffffn : value);
|
|
103
|
+
}
|
|
104
|
+
readZclUInt56() {
|
|
105
|
+
const value = this.readUInt56();
|
|
106
|
+
return value === 0xffffffffffffffn ? undefined : value;
|
|
107
|
+
}
|
|
108
|
+
writeZclUInt64(value) {
|
|
109
|
+
this.writeUInt64(value === undefined ? 0xffffffffffffffffn : value);
|
|
110
|
+
}
|
|
111
|
+
readZclUInt64() {
|
|
112
|
+
const value = this.readUInt64();
|
|
113
|
+
return value === 0xffffffffffffffffn ? undefined : value;
|
|
114
|
+
}
|
|
115
|
+
writeZclInt8(value) {
|
|
116
|
+
this.writeInt8(Number.isNaN(value) ? -0x80 : value);
|
|
117
|
+
}
|
|
118
|
+
readZclInt8() {
|
|
119
|
+
const value = this.readInt8();
|
|
120
|
+
return value === -0x80 ? Number.NaN : value;
|
|
121
|
+
}
|
|
122
|
+
writeZclInt16(value) {
|
|
123
|
+
this.writeInt16(Number.isNaN(value) ? -0x8000 : value);
|
|
124
|
+
}
|
|
125
|
+
readZclInt16() {
|
|
126
|
+
const value = this.readInt16();
|
|
127
|
+
return value === -0x8000 ? Number.NaN : value;
|
|
128
|
+
}
|
|
129
|
+
writeZclInt24(value) {
|
|
130
|
+
this.writeInt24(Number.isNaN(value) ? -0x800000 : value);
|
|
131
|
+
}
|
|
132
|
+
readZclInt24() {
|
|
133
|
+
const value = this.readInt24();
|
|
134
|
+
return value === -0x800000 ? Number.NaN : value;
|
|
135
|
+
}
|
|
136
|
+
writeZclInt32(value) {
|
|
137
|
+
this.writeInt32(Number.isNaN(value) ? -0x80000000 : value);
|
|
138
|
+
}
|
|
139
|
+
readZclInt32() {
|
|
140
|
+
const value = this.readInt32();
|
|
141
|
+
return value === -0x80000000 ? Number.NaN : value;
|
|
142
|
+
}
|
|
143
|
+
writeZclInt40(value) {
|
|
144
|
+
this.writeInt40(Number.isNaN(value) ? -0x8000000000 : value);
|
|
145
|
+
}
|
|
146
|
+
readZclInt40() {
|
|
147
|
+
const value = this.readInt40();
|
|
148
|
+
return value === -0x8000000000 ? Number.NaN : value;
|
|
149
|
+
}
|
|
150
|
+
writeZclInt48(value) {
|
|
151
|
+
this.writeInt48(Number.isNaN(value) ? -0x800000000000 : value);
|
|
152
|
+
}
|
|
153
|
+
readZclInt48() {
|
|
154
|
+
const value = this.readInt48();
|
|
155
|
+
return value === -0x800000000000 ? Number.NaN : value;
|
|
156
|
+
}
|
|
157
|
+
writeZclInt56(value) {
|
|
158
|
+
this.writeInt56(value === undefined ? -0x80000000000000n : value);
|
|
159
|
+
}
|
|
160
|
+
readZclInt56() {
|
|
161
|
+
const value = this.readInt56();
|
|
162
|
+
return value === -0x80000000000000n ? undefined : value;
|
|
163
|
+
}
|
|
164
|
+
writeZclInt64(value) {
|
|
165
|
+
this.writeInt64(value === undefined ? -0x8000000000000000n : value);
|
|
166
|
+
}
|
|
167
|
+
readZclInt64() {
|
|
168
|
+
const value = this.readInt64();
|
|
169
|
+
return value === -0x8000000000000000n ? undefined : value;
|
|
170
|
+
}
|
|
51
171
|
writeOctetStr(value) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
172
|
+
if (value) {
|
|
173
|
+
this.writeUInt8(value.length);
|
|
174
|
+
this.writeBuffer(value, value.length);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.writeUInt8(0xff); // non-value
|
|
178
|
+
}
|
|
55
179
|
}
|
|
56
180
|
readOctetStr() {
|
|
57
|
-
const length = this.
|
|
58
|
-
return
|
|
181
|
+
const length = this.readZclUInt8();
|
|
182
|
+
return Number.isNaN(length) ? Buffer.from([]) : this.readBuffer(length);
|
|
59
183
|
}
|
|
60
184
|
writeCharStr(value) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
185
|
+
if (value) {
|
|
186
|
+
if (typeof value === "string") {
|
|
187
|
+
this.writeUInt8(Buffer.byteLength(value, "utf8"));
|
|
188
|
+
this.writeUtf8String(value);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// XXX: value.length not written?
|
|
192
|
+
this.writeBuffer(value, value.length);
|
|
193
|
+
}
|
|
65
194
|
}
|
|
66
195
|
else {
|
|
67
|
-
//
|
|
68
|
-
this.writeBuffer(value, value.length);
|
|
196
|
+
this.writeUInt8(0xff); // non-value
|
|
69
197
|
}
|
|
70
198
|
}
|
|
71
199
|
readCharStr() {
|
|
72
|
-
const length = this.
|
|
73
|
-
return length
|
|
200
|
+
const length = this.readZclUInt8();
|
|
201
|
+
return Number.isNaN(length) ? "" : this.readUtf8String(length);
|
|
74
202
|
}
|
|
75
203
|
writeLongOctetStr(value) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
204
|
+
if (value) {
|
|
205
|
+
this.writeUInt16(value.length);
|
|
206
|
+
this.writeBuffer(value, value.length);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.writeUInt16(0xffff); // non-value
|
|
210
|
+
}
|
|
79
211
|
}
|
|
80
212
|
readLongOctetStr() {
|
|
81
|
-
const length = this.
|
|
82
|
-
return
|
|
213
|
+
const length = this.readZclUInt16();
|
|
214
|
+
return Number.isNaN(length) ? Buffer.from([]) : this.readBuffer(length);
|
|
83
215
|
}
|
|
84
216
|
writeLongCharStr(value) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
217
|
+
if (value) {
|
|
218
|
+
this.writeUInt16(Buffer.byteLength(value, "utf8"));
|
|
219
|
+
this.writeUtf8String(value);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.writeUInt16(0xffff); // non-value
|
|
223
|
+
}
|
|
88
224
|
}
|
|
89
225
|
readLongCharStr() {
|
|
90
|
-
const length = this.
|
|
91
|
-
return length
|
|
226
|
+
const length = this.readZclUInt16();
|
|
227
|
+
return Number.isNaN(length) ? "" : this.readUtf8String(length);
|
|
92
228
|
}
|
|
93
229
|
writeArray(value) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
230
|
+
if (value) {
|
|
231
|
+
const elTypeNumeric = typeof value.elementType === "number" ? value.elementType : enums_1.DataType[value.elementType];
|
|
232
|
+
this.writeUInt8(elTypeNumeric);
|
|
233
|
+
this.writeUInt16(value.elements.length);
|
|
234
|
+
for (const element of value.elements) {
|
|
235
|
+
this.write(elTypeNumeric, element, {});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.writeUInt8(enums_1.DataType.NO_DATA); // XXX: correct value?
|
|
240
|
+
this.writeUInt16(0xffff); // non-value
|
|
100
241
|
}
|
|
101
242
|
}
|
|
102
243
|
readArray() {
|
|
103
244
|
const values = [];
|
|
104
245
|
const elementType = this.readUInt8();
|
|
105
|
-
const numberOfElements = this.
|
|
106
|
-
if (numberOfElements
|
|
246
|
+
const numberOfElements = this.readZclUInt16();
|
|
247
|
+
if (!Number.isNaN(numberOfElements)) {
|
|
248
|
+
// not non-value
|
|
107
249
|
for (let i = 0; i < numberOfElements; i++) {
|
|
108
250
|
const value = this.read(elementType, {});
|
|
109
251
|
values.push(value);
|
|
@@ -112,19 +254,22 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
112
254
|
return values;
|
|
113
255
|
}
|
|
114
256
|
writeStruct(value) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
257
|
+
if (value) {
|
|
258
|
+
this.writeUInt16(value.length);
|
|
259
|
+
for (const v of value) {
|
|
260
|
+
this.writeUInt8(v.elmType);
|
|
261
|
+
this.write(v.elmType, v.elmVal, {});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.writeUInt16(0xffff); // non-value
|
|
122
266
|
}
|
|
123
267
|
}
|
|
124
268
|
readStruct() {
|
|
125
269
|
const values = [];
|
|
126
|
-
const numberOfElements = this.
|
|
127
|
-
if (numberOfElements
|
|
270
|
+
const numberOfElements = this.readZclUInt16();
|
|
271
|
+
if (!Number.isNaN(numberOfElements)) {
|
|
272
|
+
// not non-value
|
|
128
273
|
for (let i = 0; i < numberOfElements; i++) {
|
|
129
274
|
const elementType = this.readUInt8();
|
|
130
275
|
const value = this.read(elementType, {});
|
|
@@ -134,39 +279,39 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
134
279
|
return values;
|
|
135
280
|
}
|
|
136
281
|
writeToD(value) {
|
|
137
|
-
this.writeUInt8(value.hours
|
|
138
|
-
this.writeUInt8(value.minutes
|
|
139
|
-
this.writeUInt8(value.seconds
|
|
140
|
-
this.writeUInt8(value.hundredths
|
|
282
|
+
this.writeUInt8(value.hours == null || Number.isNaN(value.hours) ? 0xff : value.hours);
|
|
283
|
+
this.writeUInt8(value.minutes == null || Number.isNaN(value.minutes) ? 0xff : value.minutes);
|
|
284
|
+
this.writeUInt8(value.seconds == null || Number.isNaN(value.seconds) ? 0xff : value.seconds);
|
|
285
|
+
this.writeUInt8(value.hundredths == null || Number.isNaN(value.hundredths) ? 0xff : value.hundredths);
|
|
141
286
|
}
|
|
142
287
|
readToD() {
|
|
143
|
-
const hours = this.
|
|
144
|
-
const minutes = this.
|
|
145
|
-
const seconds = this.
|
|
146
|
-
const hundredths = this.
|
|
288
|
+
const hours = this.readZclUInt8();
|
|
289
|
+
const minutes = this.readZclUInt8();
|
|
290
|
+
const seconds = this.readZclUInt8();
|
|
291
|
+
const hundredths = this.readZclUInt8();
|
|
147
292
|
return {
|
|
148
|
-
hours
|
|
149
|
-
minutes
|
|
150
|
-
seconds
|
|
151
|
-
hundredths
|
|
293
|
+
hours,
|
|
294
|
+
minutes,
|
|
295
|
+
seconds,
|
|
296
|
+
hundredths,
|
|
152
297
|
};
|
|
153
298
|
}
|
|
154
299
|
writeDate(value) {
|
|
155
|
-
this.writeUInt8(value.year
|
|
156
|
-
this.writeUInt8(value.month
|
|
157
|
-
this.writeUInt8(value.dayOfMonth
|
|
158
|
-
this.writeUInt8(value.dayOfWeek
|
|
300
|
+
this.writeUInt8(value.year == null || Number.isNaN(value.year) ? 0xff : value.year - 1900);
|
|
301
|
+
this.writeUInt8(value.month == null || Number.isNaN(value.month) ? 0xff : value.month);
|
|
302
|
+
this.writeUInt8(value.dayOfMonth == null || Number.isNaN(value.dayOfMonth) ? 0xff : value.dayOfMonth);
|
|
303
|
+
this.writeUInt8(value.dayOfWeek == null || Number.isNaN(value.dayOfWeek) ? 0xff : value.dayOfWeek);
|
|
159
304
|
}
|
|
160
305
|
readDate() {
|
|
161
|
-
const year = this.
|
|
162
|
-
const month = this.
|
|
163
|
-
const dayOfMonth = this.
|
|
164
|
-
const dayOfWeek = this.
|
|
306
|
+
const year = this.readZclUInt8();
|
|
307
|
+
const month = this.readZclUInt8();
|
|
308
|
+
const dayOfMonth = this.readZclUInt8();
|
|
309
|
+
const dayOfWeek = this.readZclUInt8();
|
|
165
310
|
return {
|
|
166
|
-
year: year
|
|
167
|
-
month
|
|
168
|
-
dayOfMonth
|
|
169
|
-
dayOfWeek
|
|
311
|
+
year: year + 1900, // remains NaN if year is NaN
|
|
312
|
+
month,
|
|
313
|
+
dayOfMonth,
|
|
314
|
+
dayOfWeek,
|
|
170
315
|
};
|
|
171
316
|
}
|
|
172
317
|
//--- BuffaloZclDataType
|
|
@@ -292,9 +437,15 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
292
437
|
// 0xf6: ZCL Tunneling
|
|
293
438
|
}
|
|
294
439
|
readGpdFrame(options) {
|
|
440
|
+
if (options.payload?.payloadSize === undefined) {
|
|
441
|
+
throw new Error("Cannot read GPD_FRAME without required payload options specified");
|
|
442
|
+
}
|
|
443
|
+
if (Number.isNaN(options.payload.payloadSize) || options.payload.payloadSize === 0) {
|
|
444
|
+
return {}; // non-value, don't move position
|
|
445
|
+
}
|
|
295
446
|
// ensure offset by options.payload.payloadSize (if any) at end of parsing to not cause issues with spec changes (until supported)
|
|
296
447
|
const startPosition = this.position;
|
|
297
|
-
if (options.payload
|
|
448
|
+
if (options.payload.commandID === 0xe0) {
|
|
298
449
|
// Commisioning
|
|
299
450
|
const frame = {
|
|
300
451
|
deviceID: this.readUInt8(),
|
|
@@ -356,29 +507,20 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
356
507
|
frame.currentContactStatus = this.readUInt8();
|
|
357
508
|
}
|
|
358
509
|
}
|
|
359
|
-
|
|
360
|
-
this.position = startPosition + options.payload.payloadSize;
|
|
361
|
-
}
|
|
510
|
+
this.setPosition(startPosition + options.payload.payloadSize);
|
|
362
511
|
return frame;
|
|
363
512
|
}
|
|
364
|
-
if (options.payload
|
|
513
|
+
if (options.payload.commandID === 0xe3) {
|
|
365
514
|
// Channel Request
|
|
366
515
|
const channelOpts = this.readUInt8();
|
|
367
|
-
|
|
368
|
-
if (options.payload?.payloadSize) {
|
|
369
|
-
this.position = startPosition + options.payload.payloadSize;
|
|
370
|
-
}
|
|
371
|
-
/* v8 ignore stop */
|
|
516
|
+
this.setPosition(startPosition + options.payload.payloadSize);
|
|
372
517
|
return {
|
|
373
518
|
nextChannel: channelOpts & 0xf,
|
|
374
519
|
nextNextChannel: channelOpts >> 4,
|
|
375
520
|
};
|
|
376
521
|
}
|
|
377
|
-
if (options.payload
|
|
522
|
+
if (options.payload.commandID === 0xa1) {
|
|
378
523
|
// Manufacturer-specific Attribute Reporting
|
|
379
|
-
if (options.payload.payloadSize === undefined) {
|
|
380
|
-
throw new Error("Cannot read GPD_FRAME with commandID=0xA1 without payloadSize options specified");
|
|
381
|
-
}
|
|
382
524
|
const start = this.position;
|
|
383
525
|
const frame = {
|
|
384
526
|
manufacturerCode: this.readUInt16(),
|
|
@@ -399,17 +541,11 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
399
541
|
}
|
|
400
542
|
frame.attributes[attribute] = this.read(type, options);
|
|
401
543
|
}
|
|
402
|
-
this.
|
|
544
|
+
this.setPosition(startPosition + options.payload.payloadSize);
|
|
403
545
|
return frame;
|
|
404
546
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return { raw: this.readBuffer(options.payload.payloadSize) };
|
|
408
|
-
}
|
|
409
|
-
if (options.payload?.payloadSize) {
|
|
410
|
-
this.position = startPosition + options.payload.payloadSize;
|
|
411
|
-
}
|
|
412
|
-
return {};
|
|
547
|
+
// might contain `gppNwkAddr`, `gppGpdLink` & `mic` from ZCL cluster after this, so limit by `payloadSize`
|
|
548
|
+
return { raw: this.readBuffer(options.payload.payloadSize) };
|
|
413
549
|
}
|
|
414
550
|
writeStructuredSelector(value) {
|
|
415
551
|
if (value != null) {
|
|
@@ -523,12 +659,12 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
523
659
|
case enums_1.DataType.UNKNOWN: {
|
|
524
660
|
return; // nothing to write
|
|
525
661
|
}
|
|
526
|
-
case enums_1.DataType.DATA8:
|
|
527
662
|
case enums_1.DataType.BOOLEAN:
|
|
663
|
+
case enums_1.DataType.DATA8:
|
|
528
664
|
case enums_1.DataType.BITMAP8:
|
|
529
665
|
case enums_1.DataType.UINT8:
|
|
530
666
|
case enums_1.DataType.ENUM8: {
|
|
531
|
-
this.
|
|
667
|
+
this.writeZclUInt8(value);
|
|
532
668
|
break;
|
|
533
669
|
}
|
|
534
670
|
case enums_1.DataType.DATA16:
|
|
@@ -537,13 +673,13 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
537
673
|
case enums_1.DataType.ENUM16:
|
|
538
674
|
case enums_1.DataType.CLUSTER_ID:
|
|
539
675
|
case enums_1.DataType.ATTR_ID: {
|
|
540
|
-
this.
|
|
676
|
+
this.writeZclUInt16(value);
|
|
541
677
|
break;
|
|
542
678
|
}
|
|
543
679
|
case enums_1.DataType.DATA24:
|
|
544
680
|
case enums_1.DataType.BITMAP24:
|
|
545
681
|
case enums_1.DataType.UINT24: {
|
|
546
|
-
this.
|
|
682
|
+
this.writeZclUInt24(value);
|
|
547
683
|
break;
|
|
548
684
|
}
|
|
549
685
|
case enums_1.DataType.DATA32:
|
|
@@ -551,63 +687,63 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
551
687
|
case enums_1.DataType.UINT32:
|
|
552
688
|
case enums_1.DataType.UTC:
|
|
553
689
|
case enums_1.DataType.BAC_OID: {
|
|
554
|
-
this.
|
|
690
|
+
this.writeZclUInt32(value);
|
|
555
691
|
break;
|
|
556
692
|
}
|
|
557
693
|
case enums_1.DataType.DATA40:
|
|
558
694
|
case enums_1.DataType.BITMAP40:
|
|
559
695
|
case enums_1.DataType.UINT40: {
|
|
560
|
-
this.
|
|
696
|
+
this.writeZclUInt40(value);
|
|
561
697
|
break;
|
|
562
698
|
}
|
|
563
699
|
case enums_1.DataType.DATA48:
|
|
564
700
|
case enums_1.DataType.BITMAP48:
|
|
565
701
|
case enums_1.DataType.UINT48: {
|
|
566
|
-
this.
|
|
702
|
+
this.writeZclUInt48(value);
|
|
567
703
|
break;
|
|
568
704
|
}
|
|
569
705
|
case enums_1.DataType.DATA56:
|
|
570
706
|
case enums_1.DataType.BITMAP56:
|
|
571
707
|
case enums_1.DataType.UINT56: {
|
|
572
|
-
this.
|
|
708
|
+
this.writeZclUInt56(value);
|
|
573
709
|
break;
|
|
574
710
|
}
|
|
575
711
|
case enums_1.DataType.DATA64:
|
|
576
712
|
case enums_1.DataType.BITMAP64:
|
|
577
713
|
case enums_1.DataType.UINT64: {
|
|
578
|
-
this.
|
|
714
|
+
this.writeZclUInt64(value);
|
|
579
715
|
break;
|
|
580
716
|
}
|
|
581
717
|
case enums_1.DataType.INT8: {
|
|
582
|
-
this.
|
|
718
|
+
this.writeZclInt8(value);
|
|
583
719
|
break;
|
|
584
720
|
}
|
|
585
721
|
case enums_1.DataType.INT16: {
|
|
586
|
-
this.
|
|
722
|
+
this.writeZclInt16(value);
|
|
587
723
|
break;
|
|
588
724
|
}
|
|
589
725
|
case enums_1.DataType.INT24: {
|
|
590
|
-
this.
|
|
726
|
+
this.writeZclInt24(value);
|
|
591
727
|
break;
|
|
592
728
|
}
|
|
593
729
|
case enums_1.DataType.INT32: {
|
|
594
|
-
this.
|
|
730
|
+
this.writeZclInt32(value);
|
|
595
731
|
break;
|
|
596
732
|
}
|
|
597
733
|
case enums_1.DataType.INT40: {
|
|
598
|
-
this.
|
|
734
|
+
this.writeZclInt40(value);
|
|
599
735
|
break;
|
|
600
736
|
}
|
|
601
737
|
case enums_1.DataType.INT48: {
|
|
602
|
-
this.
|
|
738
|
+
this.writeZclInt48(value);
|
|
603
739
|
break;
|
|
604
740
|
}
|
|
605
741
|
case enums_1.DataType.INT56: {
|
|
606
|
-
this.
|
|
742
|
+
this.writeZclInt56(value);
|
|
607
743
|
break;
|
|
608
744
|
}
|
|
609
745
|
case enums_1.DataType.INT64: {
|
|
610
|
-
this.
|
|
746
|
+
this.writeZclInt64(value);
|
|
611
747
|
break;
|
|
612
748
|
}
|
|
613
749
|
// case DataType.SEMI_PREC: {
|
|
@@ -748,12 +884,12 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
748
884
|
case enums_1.DataType.UNKNOWN: {
|
|
749
885
|
return; // nothing to write
|
|
750
886
|
}
|
|
751
|
-
case enums_1.DataType.DATA8:
|
|
752
887
|
case enums_1.DataType.BOOLEAN:
|
|
888
|
+
case enums_1.DataType.DATA8:
|
|
753
889
|
case enums_1.DataType.BITMAP8:
|
|
754
890
|
case enums_1.DataType.UINT8:
|
|
755
891
|
case enums_1.DataType.ENUM8: {
|
|
756
|
-
return this.
|
|
892
|
+
return this.readZclUInt8();
|
|
757
893
|
}
|
|
758
894
|
case enums_1.DataType.DATA16:
|
|
759
895
|
case enums_1.DataType.BITMAP16:
|
|
@@ -761,63 +897,63 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
761
897
|
case enums_1.DataType.ENUM16:
|
|
762
898
|
case enums_1.DataType.CLUSTER_ID:
|
|
763
899
|
case enums_1.DataType.ATTR_ID: {
|
|
764
|
-
return this.
|
|
900
|
+
return this.readZclUInt16();
|
|
765
901
|
}
|
|
766
902
|
case enums_1.DataType.DATA24:
|
|
767
903
|
case enums_1.DataType.BITMAP24:
|
|
768
904
|
case enums_1.DataType.UINT24: {
|
|
769
|
-
return this.
|
|
905
|
+
return this.readZclUInt24();
|
|
770
906
|
}
|
|
771
907
|
case enums_1.DataType.DATA32:
|
|
772
908
|
case enums_1.DataType.BITMAP32:
|
|
773
909
|
case enums_1.DataType.UINT32:
|
|
774
910
|
case enums_1.DataType.UTC:
|
|
775
911
|
case enums_1.DataType.BAC_OID: {
|
|
776
|
-
return this.
|
|
912
|
+
return this.readZclUInt32();
|
|
777
913
|
}
|
|
778
914
|
case enums_1.DataType.DATA40:
|
|
779
915
|
case enums_1.DataType.BITMAP40:
|
|
780
916
|
case enums_1.DataType.UINT40: {
|
|
781
|
-
return this.
|
|
917
|
+
return this.readZclUInt40();
|
|
782
918
|
}
|
|
783
919
|
case enums_1.DataType.DATA48:
|
|
784
920
|
case enums_1.DataType.BITMAP48:
|
|
785
921
|
case enums_1.DataType.UINT48: {
|
|
786
|
-
return this.
|
|
922
|
+
return this.readZclUInt48();
|
|
787
923
|
}
|
|
788
924
|
case enums_1.DataType.DATA56:
|
|
789
925
|
case enums_1.DataType.BITMAP56:
|
|
790
926
|
case enums_1.DataType.UINT56: {
|
|
791
|
-
return this.
|
|
927
|
+
return this.readZclUInt56();
|
|
792
928
|
}
|
|
793
929
|
case enums_1.DataType.DATA64:
|
|
794
930
|
case enums_1.DataType.BITMAP64:
|
|
795
931
|
case enums_1.DataType.UINT64: {
|
|
796
|
-
return this.
|
|
932
|
+
return this.readZclUInt64();
|
|
797
933
|
}
|
|
798
934
|
case enums_1.DataType.INT8: {
|
|
799
|
-
return this.
|
|
935
|
+
return this.readZclInt8();
|
|
800
936
|
}
|
|
801
937
|
case enums_1.DataType.INT16: {
|
|
802
|
-
return this.
|
|
938
|
+
return this.readZclInt16();
|
|
803
939
|
}
|
|
804
940
|
case enums_1.DataType.INT24: {
|
|
805
|
-
return this.
|
|
941
|
+
return this.readZclInt24();
|
|
806
942
|
}
|
|
807
943
|
case enums_1.DataType.INT32: {
|
|
808
|
-
return this.
|
|
944
|
+
return this.readZclInt32();
|
|
809
945
|
}
|
|
810
946
|
case enums_1.DataType.INT40: {
|
|
811
|
-
return this.
|
|
947
|
+
return this.readZclInt40();
|
|
812
948
|
}
|
|
813
949
|
case enums_1.DataType.INT48: {
|
|
814
|
-
return this.
|
|
950
|
+
return this.readZclInt48();
|
|
815
951
|
}
|
|
816
952
|
case enums_1.DataType.INT56: {
|
|
817
|
-
return this.
|
|
953
|
+
return this.readZclInt56();
|
|
818
954
|
}
|
|
819
955
|
case enums_1.DataType.INT64: {
|
|
820
|
-
return this.
|
|
956
|
+
return this.readZclInt64();
|
|
821
957
|
}
|
|
822
958
|
// case DataType.SEMI_PREC: {
|
|
823
959
|
// // https://tc39.es/proposal-float16array/
|