zigbee-herdsman 0.44.0 → 0.46.0
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/adapter/ember/ezsp/buffalo.js +4 -4
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.js +19 -19
- package/dist/adapter/ember/ezsp/ezsp.js.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts +1 -0
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.js +9 -0
- package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +4 -2
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.js +154 -25
- package/dist/adapter/z-stack/znp/buffaloZnp.js.map +1 -1
- package/dist/adapter/z-stack/znp/tstype.d.ts +4 -3
- package/dist/adapter/z-stack/znp/tstype.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.js +2 -2
- package/dist/adapter/z-stack/znp/zpiObject.js.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts +7 -8
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.js +150 -100
- package/dist/adapter/zigate/driver/buffaloZiGate.js.map +1 -1
- package/dist/adapter/zigate/driver/commandType.d.ts +2 -1
- package/dist/adapter/zigate/driver/commandType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/commandType.js +56 -52
- package/dist/adapter/zigate/driver/commandType.js.map +1 -1
- package/dist/adapter/zigate/driver/messageType.d.ts +2 -1
- package/dist/adapter/zigate/driver/messageType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/messageType.js +113 -108
- package/dist/adapter/zigate/driver/messageType.js.map +1 -1
- package/dist/adapter/zigate/driver/parameterType.d.ts +8 -1
- package/dist/adapter/zigate/driver/parameterType.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/parameterType.js +9 -0
- package/dist/adapter/zigate/driver/parameterType.js.map +1 -1
- package/dist/adapter/zigate/driver/ziGateObject.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/ziGateObject.js +4 -5
- package/dist/adapter/zigate/driver/ziGateObject.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +21 -18
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +72 -167
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/buffalo/index.d.ts +1 -2
- package/dist/buffalo/index.d.ts.map +1 -1
- package/dist/buffalo/index.js +1 -26
- package/dist/buffalo/index.js.map +1 -1
- package/dist/zcl/buffaloZcl.d.ts +40 -27
- package/dist/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zcl/buffaloZcl.js +666 -350
- package/dist/zcl/buffaloZcl.js.map +1 -1
- package/dist/zcl/definition/cluster.js +2327 -2327
- package/dist/zcl/definition/cluster.js.map +1 -1
- package/dist/zcl/definition/dataType.d.ts +119 -56
- package/dist/zcl/definition/dataType.d.ts.map +1 -1
- package/dist/zcl/definition/dataType.js +119 -58
- package/dist/zcl/definition/dataType.js.map +1 -1
- package/dist/zcl/definition/foundation.d.ts +3 -4
- package/dist/zcl/definition/foundation.d.ts.map +1 -1
- package/dist/zcl/definition/foundation.js +118 -80
- package/dist/zcl/definition/foundation.js.map +1 -1
- package/dist/zcl/definition/tstype.d.ts +0 -3
- package/dist/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zcl/definition/tstype.js.map +1 -1
- package/dist/zcl/tstype.d.ts +26 -8
- package/dist/zcl/tstype.d.ts.map +1 -1
- package/dist/zcl/tstype.js +13 -3
- package/dist/zcl/tstype.js.map +1 -1
- package/dist/zcl/utils.d.ts.map +1 -1
- package/dist/zcl/utils.js +14 -17
- package/dist/zcl/utils.js.map +1 -1
- package/dist/zcl/zclFrame.d.ts +4 -4
- package/dist/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zcl/zclFrame.js +19 -24
- package/dist/zcl/zclFrame.js.map +1 -1
- package/package.json +1 -1
- package/dist/buffalo/tstype.d.ts +0 -9
- package/dist/buffalo/tstype.d.ts.map +0 -1
- package/dist/buffalo/tstype.js +0 -3
- package/dist/buffalo/tstype.js.map +0 -1
package/dist/zcl/buffaloZcl.js
CHANGED
|
@@ -24,102 +24,123 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const buffalo_1 = require("../buffalo");
|
|
27
|
+
const utils_1 = require("../utils");
|
|
27
28
|
const logger_1 = require("../utils/logger");
|
|
28
29
|
const definition_1 = require("./definition");
|
|
29
30
|
const tstype_1 = require("./tstype");
|
|
30
31
|
const Utils = __importStar(require("./utils"));
|
|
31
32
|
const NS = 'zh:controller:buffalozcl';
|
|
32
|
-
const
|
|
33
|
-
'boolean': 'uint8',
|
|
34
|
-
'bitmap8': 'uint8',
|
|
35
|
-
'enum8': 'uint8',
|
|
36
|
-
'data8': 'uint8',
|
|
37
|
-
'data16': 'uint16',
|
|
38
|
-
'bitmap16': 'uint16',
|
|
39
|
-
'uint16': 'uint16',
|
|
40
|
-
'enum16': 'uint16',
|
|
41
|
-
'clusterId': 'uint16',
|
|
42
|
-
'attrId': 'uint16',
|
|
43
|
-
'data24': 'uint24',
|
|
44
|
-
'bitmap24': 'uint24',
|
|
45
|
-
'data32': 'uint32',
|
|
46
|
-
'bitmap32': 'uint32',
|
|
47
|
-
'uint32': 'uint32',
|
|
48
|
-
'tod': 'uint32',
|
|
49
|
-
'date': 'uint32',
|
|
50
|
-
'utc': 'uint32',
|
|
51
|
-
'bacOid': 'uint32',
|
|
52
|
-
'singlePrec': 'floatle',
|
|
53
|
-
'doublePrec': 'doublele',
|
|
54
|
-
'bitmap40': 'uint40',
|
|
55
|
-
'data40': 'uint40',
|
|
56
|
-
'bitmap48': 'uint48',
|
|
57
|
-
'data48': 'uint48',
|
|
58
|
-
'bitmap56': 'uint56',
|
|
59
|
-
'data56': 'uint56',
|
|
60
|
-
'bitmap64': 'uint64',
|
|
61
|
-
'data64': 'uint64',
|
|
62
|
-
'ieeeAddr': 'uint64',
|
|
63
|
-
'longOctetStr': 'longCharStr',
|
|
64
|
-
'secKey': 'buffer16',
|
|
65
|
-
'noData': 'EMPTY',
|
|
66
|
-
'unknown': 'EMPTY',
|
|
67
|
-
'bag': 'array',
|
|
68
|
-
'set': 'array',
|
|
69
|
-
};
|
|
33
|
+
const SEC_KEY_LENGTH = 16;
|
|
70
34
|
const extensionFieldSetsDateTypeLookup = {
|
|
71
|
-
6: [
|
|
72
|
-
8: [
|
|
73
|
-
258: [
|
|
74
|
-
768: [
|
|
35
|
+
6: [definition_1.DataType.UINT8],
|
|
36
|
+
8: [definition_1.DataType.UINT8],
|
|
37
|
+
258: [definition_1.DataType.UINT8, definition_1.DataType.UINT8],
|
|
38
|
+
768: [definition_1.DataType.UINT16, definition_1.DataType.UINT16, definition_1.DataType.UINT16, definition_1.DataType.UINT8, definition_1.DataType.UINT8, definition_1.DataType.UINT8, definition_1.DataType.UINT16, definition_1.DataType.UINT16],
|
|
75
39
|
};
|
|
76
40
|
class BuffaloZcl extends buffalo_1.Buffalo {
|
|
77
|
-
|
|
78
|
-
|
|
41
|
+
// TODO: remove read/write int "SB" versions in favor of plain numbers, implemented in buffalo.ts
|
|
42
|
+
writeUInt40SB(value) {
|
|
43
|
+
this.writeUInt32(value[1]);
|
|
44
|
+
this.writeUInt8(value[0]);
|
|
79
45
|
}
|
|
80
|
-
|
|
81
|
-
this.
|
|
46
|
+
readUInt40SB() {
|
|
47
|
+
const lsb = this.readUInt32();
|
|
48
|
+
const msb = this.readUInt8();
|
|
49
|
+
return [msb, lsb];
|
|
82
50
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const numberOfElements = this.readUInt16();
|
|
87
|
-
for (let i = 0; i < numberOfElements; i++) {
|
|
88
|
-
const value = this.read(elementType, {});
|
|
89
|
-
values.push(value);
|
|
90
|
-
}
|
|
91
|
-
return values;
|
|
51
|
+
writeUInt48SB(value) {
|
|
52
|
+
this.writeUInt32(value[1]);
|
|
53
|
+
this.writeUInt16(value[0]);
|
|
92
54
|
}
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
value.elements.forEach(element => {
|
|
98
|
-
this.write(definition_1.DataType[elTypeNumeric], element, {});
|
|
99
|
-
});
|
|
55
|
+
readUInt48SB() {
|
|
56
|
+
const lsb = this.readUInt32();
|
|
57
|
+
const msb = this.readUInt16();
|
|
58
|
+
return [msb, lsb];
|
|
100
59
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
60
|
+
writeUInt56SB(value) {
|
|
61
|
+
const temp = Buffer.alloc(8);
|
|
62
|
+
temp.writeUInt32LE(value[1], 0);
|
|
63
|
+
temp.writeUInt32LE(value[0], 4);
|
|
64
|
+
this.writeBuffer(temp.subarray(0, 7), 7);
|
|
65
|
+
}
|
|
66
|
+
readUInt56SB() {
|
|
67
|
+
const lsb = this.readUInt32();
|
|
68
|
+
const xsb = this.readUInt16();
|
|
69
|
+
const msb = this.readUInt8();
|
|
70
|
+
return [msb, xsb, lsb];
|
|
71
|
+
}
|
|
72
|
+
readUInt64SB() {
|
|
73
|
+
// XXX: not following pattern, should return as [msb, lsb]
|
|
74
|
+
return this.readIeeeAddr();
|
|
75
|
+
}
|
|
76
|
+
writeUInt64SB(value) {
|
|
77
|
+
// XXX: not following pattern, should pass as number[]
|
|
78
|
+
const msb = parseInt(value.slice(2, 10), 16);
|
|
79
|
+
const lsb = parseInt(value.slice(10), 16);
|
|
80
|
+
this.writeUInt32(lsb);
|
|
81
|
+
this.writeUInt32(msb);
|
|
82
|
+
}
|
|
83
|
+
writeInt40SB(value) {
|
|
84
|
+
this.writeInt32(value[1]);
|
|
85
|
+
this.writeInt8(value[0]);
|
|
86
|
+
}
|
|
87
|
+
readInt40SB() {
|
|
88
|
+
const lsb = this.readInt32();
|
|
89
|
+
const msb = this.readInt8();
|
|
90
|
+
return [msb, lsb];
|
|
91
|
+
}
|
|
92
|
+
writeInt56SB(value) {
|
|
93
|
+
const temp = Buffer.alloc(8);
|
|
94
|
+
temp.writeInt32LE(value[1], 0);
|
|
95
|
+
temp.writeInt32LE(value[0], 4);
|
|
96
|
+
this.writeBuffer(temp.subarray(0, 7), 7);
|
|
97
|
+
}
|
|
98
|
+
readInt56SB() {
|
|
99
|
+
const lsb = this.readInt32();
|
|
100
|
+
const xsb = this.readInt16();
|
|
101
|
+
const msb = this.readInt8();
|
|
102
|
+
return [msb, xsb, lsb];
|
|
103
|
+
}
|
|
104
|
+
writeInt64SB(value) {
|
|
105
|
+
this.writeInt32(value[1]);
|
|
106
|
+
this.writeInt32(value[0]);
|
|
107
|
+
}
|
|
108
|
+
readInt64SB() {
|
|
109
|
+
const lsb = this.readInt32();
|
|
110
|
+
const msb = this.readInt32();
|
|
111
|
+
return [msb, lsb];
|
|
112
|
+
}
|
|
113
|
+
writeOctetStr(value) {
|
|
114
|
+
// TODO: this does not allow "non-value" 0xFF
|
|
115
|
+
this.writeUInt8(value.length);
|
|
116
|
+
this.writeBuffer(value, value.length);
|
|
110
117
|
}
|
|
111
118
|
readOctetStr() {
|
|
112
119
|
const length = this.readUInt8();
|
|
113
|
-
return this.readBuffer(length);
|
|
120
|
+
return (length < 0xFF) ? this.readBuffer(length) : Buffer.from([]); // non-value
|
|
121
|
+
}
|
|
122
|
+
writeCharStr(value) {
|
|
123
|
+
// TODO: this does not allow "non-value" 0xFF
|
|
124
|
+
if (typeof value === 'string') {
|
|
125
|
+
this.writeUInt8(value.length);
|
|
126
|
+
this.writeUtf8String(value);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.writeBuffer(value, value.length);
|
|
130
|
+
}
|
|
114
131
|
}
|
|
115
132
|
readCharStr(options) {
|
|
116
133
|
const length = this.readUInt8();
|
|
134
|
+
// TODO: this workaround should be moved to a custom type
|
|
117
135
|
if (options.attrId === 65281) {
|
|
118
136
|
const value = {};
|
|
137
|
+
if (length === 0xFF) {
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
119
140
|
// Xiaomi struct parsing
|
|
120
141
|
for (let i = 0; i < length; i++) {
|
|
121
142
|
const index = this.readUInt8();
|
|
122
|
-
const dataType =
|
|
143
|
+
const dataType = this.readUInt8();
|
|
123
144
|
value[index] = this.read(dataType, {});
|
|
124
145
|
if (this.position === this.buffer.length) {
|
|
125
146
|
break;
|
|
@@ -128,64 +149,107 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
128
149
|
return value;
|
|
129
150
|
}
|
|
130
151
|
else {
|
|
131
|
-
return this.readUtf8String(length);
|
|
152
|
+
return (length < 0xFF) ? this.readUtf8String(length) : '';
|
|
132
153
|
}
|
|
133
154
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.writeBuffer(value, value.length);
|
|
141
|
-
}
|
|
155
|
+
writeLongOctetStr(value) {
|
|
156
|
+
// TODO: this does not allow "non-value" 0xFF
|
|
157
|
+
this.writeUInt16(value.length);
|
|
158
|
+
this.writeBuffer(value, value.length);
|
|
142
159
|
}
|
|
143
|
-
|
|
160
|
+
readLongOctetStr() {
|
|
144
161
|
const length = this.readUInt16();
|
|
145
|
-
return this.
|
|
162
|
+
return (length < 0xFFFF) ? this.readBuffer(length) : Buffer.from([]); // non-value
|
|
146
163
|
}
|
|
147
164
|
writeLongCharStr(value) {
|
|
165
|
+
// TODO: this does not allow "non-value" 0xFF
|
|
148
166
|
this.writeUInt16(value.length);
|
|
149
167
|
this.writeUtf8String(value);
|
|
150
168
|
}
|
|
151
|
-
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
169
|
+
readLongCharStr() {
|
|
170
|
+
const length = this.readUInt16();
|
|
171
|
+
return (length < 0xFFFF) ? this.readUtf8String(length) : ''; // non-value
|
|
154
172
|
}
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
writeArray(value) {
|
|
174
|
+
const elTypeNumeric = typeof value.elementType === 'number' ? value.elementType : definition_1.DataType[value.elementType];
|
|
175
|
+
this.writeUInt8(elTypeNumeric);
|
|
176
|
+
// TODO: this does not allow writing "non-value" 0xFFFF
|
|
177
|
+
this.writeUInt16(value.elements.length);
|
|
178
|
+
for (const element of value.elements) {
|
|
179
|
+
this.write(elTypeNumeric, element, {});
|
|
180
|
+
}
|
|
181
|
+
;
|
|
182
|
+
}
|
|
183
|
+
readArray() {
|
|
184
|
+
const values = [];
|
|
185
|
+
const elementType = this.readUInt8();
|
|
186
|
+
const numberOfElements = this.readUInt16();
|
|
187
|
+
if (numberOfElements < 0xFFFF) {
|
|
188
|
+
for (let i = 0; i < numberOfElements; i++) {
|
|
189
|
+
const value = this.read(elementType, {});
|
|
190
|
+
values.push(value);
|
|
166
191
|
}
|
|
167
|
-
value.push({ extField, clstId, len });
|
|
168
192
|
}
|
|
169
|
-
return
|
|
193
|
+
return values;
|
|
170
194
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
writeStruct(value) {
|
|
196
|
+
// XXX: from ZCL spec: "The zeroth element may not be written to."
|
|
197
|
+
// how does this translates to writing here?
|
|
198
|
+
// TODO: this does not allow writing "non-value" 0xFFFF
|
|
199
|
+
this.writeUInt16(value.length);
|
|
200
|
+
for (const v of value) {
|
|
201
|
+
this.writeUInt8(v.elmType);
|
|
202
|
+
this.write(v.elmType, v.elmVal, {});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
readStruct() {
|
|
206
|
+
const values = [];
|
|
207
|
+
const numberOfElements = this.readUInt16();
|
|
208
|
+
if (numberOfElements < 0xFFFF) {
|
|
209
|
+
for (let i = 0; i < numberOfElements; i++) {
|
|
210
|
+
const elementType = this.readUInt8();
|
|
211
|
+
const value = this.read(elementType, {});
|
|
212
|
+
values.push({ elmType: elementType, elmVal: value });
|
|
213
|
+
}
|
|
178
214
|
}
|
|
215
|
+
return values;
|
|
179
216
|
}
|
|
217
|
+
writeToD(value) {
|
|
218
|
+
this.writeUInt8(value.hours ?? 0xFF);
|
|
219
|
+
this.writeUInt8(value.minutes ?? 0xFF);
|
|
220
|
+
this.writeUInt8(value.seconds ?? 0xFF);
|
|
221
|
+
this.writeUInt8(value.hundredths ?? 0xFF);
|
|
222
|
+
}
|
|
223
|
+
readToD() {
|
|
224
|
+
const hours = this.readUInt8();
|
|
225
|
+
const minutes = this.readUInt8();
|
|
226
|
+
const seconds = this.readUInt8();
|
|
227
|
+
const hundredths = this.readUInt8();
|
|
228
|
+
return { hours, minutes, seconds, hundredths };
|
|
229
|
+
}
|
|
230
|
+
writeDate(value) {
|
|
231
|
+
this.writeUInt8(value.year != null ? (value.year - 1900) : 0xFF);
|
|
232
|
+
this.writeUInt8(value.month ?? 0xFF);
|
|
233
|
+
this.writeUInt8(value.dayOfMonth ?? 0xFF);
|
|
234
|
+
this.writeUInt8(value.dayOfWeek ?? 0xFF);
|
|
235
|
+
}
|
|
236
|
+
readDate() {
|
|
237
|
+
const year = this.readUInt8() + 1900;
|
|
238
|
+
const month = this.readUInt8();
|
|
239
|
+
const dayOfMonth = this.readUInt8();
|
|
240
|
+
const dayOfWeek = this.readUInt8();
|
|
241
|
+
return { year, month, dayOfMonth, dayOfWeek };
|
|
242
|
+
}
|
|
243
|
+
//--- BuffaloZclDataType
|
|
180
244
|
writeListZoneInfo(values) {
|
|
181
245
|
for (const value of values) {
|
|
182
246
|
this.writeUInt8(value.zoneID);
|
|
183
247
|
this.writeUInt16(value.zoneStatus);
|
|
184
248
|
}
|
|
185
249
|
}
|
|
186
|
-
readListZoneInfo(
|
|
250
|
+
readListZoneInfo(length) {
|
|
187
251
|
const value = [];
|
|
188
|
-
for (let i = 0; i <
|
|
252
|
+
for (let i = 0; i < length; i++) {
|
|
189
253
|
value.push({
|
|
190
254
|
zoneID: this.readUInt8(),
|
|
191
255
|
zoneStatus: this.readUInt16(),
|
|
@@ -193,9 +257,48 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
193
257
|
}
|
|
194
258
|
return value;
|
|
195
259
|
}
|
|
260
|
+
writeExtensionFieldSets(values) {
|
|
261
|
+
for (const value of values) {
|
|
262
|
+
this.writeUInt16(value.clstId);
|
|
263
|
+
this.writeUInt8(value.len);
|
|
264
|
+
value.extField.forEach((entry, index) => {
|
|
265
|
+
this.write(extensionFieldSetsDateTypeLookup[value.clstId][index], entry, {});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
readExtensionFieldSets() {
|
|
270
|
+
const value = [];
|
|
271
|
+
while (this.isMore()) {
|
|
272
|
+
const clstId = this.readUInt16();
|
|
273
|
+
const len = this.readUInt8();
|
|
274
|
+
const end = this.getPosition() + len;
|
|
275
|
+
let index = 0;
|
|
276
|
+
const extField = [];
|
|
277
|
+
while (this.getPosition() < end) {
|
|
278
|
+
extField.push(this.read(extensionFieldSetsDateTypeLookup[clstId][index], {}));
|
|
279
|
+
index++;
|
|
280
|
+
}
|
|
281
|
+
value.push({ extField, clstId, len });
|
|
282
|
+
}
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
writeListThermoTransitions(value) {
|
|
286
|
+
for (const entry of value) {
|
|
287
|
+
this.writeUInt16(entry.transitionTime);
|
|
288
|
+
if (entry.heatSetpoint != null) {
|
|
289
|
+
this.writeUInt16(entry.heatSetpoint);
|
|
290
|
+
}
|
|
291
|
+
if (entry.coolSetpoint != null) {
|
|
292
|
+
this.writeUInt16(entry.coolSetpoint);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
196
296
|
readListThermoTransitions(options) {
|
|
197
|
-
|
|
198
|
-
|
|
297
|
+
if (options.payload == null || options.payload.mode == null || options.payload.numoftrans == null) {
|
|
298
|
+
throw new Error('Cannot read LIST_THERMO_TRANSITIONS without required payload options specified');
|
|
299
|
+
}
|
|
300
|
+
const heat = options.payload.mode & 1;
|
|
301
|
+
const cool = options.payload.mode & 2;
|
|
199
302
|
const result = [];
|
|
200
303
|
for (let i = 0; i < options.payload.numoftrans; i++) {
|
|
201
304
|
const entry = {
|
|
@@ -211,20 +314,53 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
211
314
|
}
|
|
212
315
|
return result;
|
|
213
316
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
317
|
+
writeGdpFrame(value) {
|
|
318
|
+
if (value.commandID == 0xF0) { // Commissioning Reply
|
|
319
|
+
const v = value;
|
|
320
|
+
const panIDPresent = v.options & (1 << 0);
|
|
321
|
+
const gpdSecurityKeyPresent = v.options & (1 << 1);
|
|
322
|
+
const gpdKeyEncryption = v.options & (1 << 2);
|
|
323
|
+
const securityLevel = v.options & (3 << 3) >> 3;
|
|
324
|
+
const hasGPDKeyMIC = gpdKeyEncryption && gpdSecurityKeyPresent;
|
|
325
|
+
const hasFrameCounter = gpdSecurityKeyPresent &&
|
|
326
|
+
gpdKeyEncryption &&
|
|
327
|
+
(securityLevel === 0b10 || securityLevel === 0b11);
|
|
328
|
+
this.writeUInt8(1 +
|
|
329
|
+
(panIDPresent ? 2 : 0) +
|
|
330
|
+
(gpdSecurityKeyPresent ? 16 : 0) +
|
|
331
|
+
(hasGPDKeyMIC ? 4 : 0) +
|
|
332
|
+
(hasFrameCounter ? 4 : 0)); // Length
|
|
333
|
+
this.writeUInt8(v.options);
|
|
334
|
+
if (panIDPresent) {
|
|
335
|
+
this.writeUInt16(v.panID);
|
|
219
336
|
}
|
|
220
|
-
if (
|
|
221
|
-
this.
|
|
337
|
+
if (gpdSecurityKeyPresent) {
|
|
338
|
+
this.writeBuffer(v.securityKey, 16);
|
|
339
|
+
}
|
|
340
|
+
if (hasGPDKeyMIC) {
|
|
341
|
+
this.writeUInt32(v.keyMic);
|
|
222
342
|
}
|
|
343
|
+
if (hasFrameCounter) {
|
|
344
|
+
this.writeUInt32(v.frameCounter);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (value.commandID == 0xF3) { // Channel configuration
|
|
348
|
+
const v = value;
|
|
349
|
+
this.writeUInt8(1);
|
|
350
|
+
this.writeUInt8(v.operationalChannel & 0xF | ((v.basic ? 1 : 0) << 4));
|
|
351
|
+
}
|
|
352
|
+
else if (value.commandID == 0xF4 ||
|
|
353
|
+
value.commandID == 0xF5 ||
|
|
354
|
+
(value.commandID >= 0xF7 && value.commandID <= 0xFF)) {
|
|
355
|
+
// Other commands sent to GPD
|
|
356
|
+
const v = value;
|
|
357
|
+
this.writeUInt8(v.buffer.length);
|
|
358
|
+
this.writeBuffer(v.buffer, v.buffer.length);
|
|
223
359
|
}
|
|
224
360
|
}
|
|
225
361
|
readGdpFrame(options) {
|
|
226
362
|
// Commisioning
|
|
227
|
-
if (options.payload
|
|
363
|
+
if (options.payload?.commandID === 0xE0) {
|
|
228
364
|
const frame = {
|
|
229
365
|
deviceID: this.readUInt8(),
|
|
230
366
|
options: this.readUInt8(),
|
|
@@ -277,15 +413,18 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
277
413
|
return frame;
|
|
278
414
|
// Channel Request
|
|
279
415
|
}
|
|
280
|
-
else if (options.payload
|
|
416
|
+
else if (options.payload?.commandID === 0xE3) {
|
|
281
417
|
const options = this.readUInt8();
|
|
282
418
|
return {
|
|
283
419
|
nextChannel: options & 0xF,
|
|
284
|
-
nextNextChannel: options >> 4
|
|
420
|
+
nextNextChannel: options >> 4,
|
|
285
421
|
};
|
|
286
422
|
// Manufacturer-specific Attribute Reporting
|
|
287
423
|
}
|
|
288
|
-
else if (options.payload
|
|
424
|
+
else if (options.payload?.commandID == 0xA1) {
|
|
425
|
+
if (options.payload.payloadSize == null) {
|
|
426
|
+
throw new Error('Cannot read GDP_FRAME with commandID=0xA1 without payloadSize options specified');
|
|
427
|
+
}
|
|
289
428
|
const start = this.position;
|
|
290
429
|
const frame = {
|
|
291
430
|
manufacturerCode: this.readUInt16(),
|
|
@@ -303,59 +442,52 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
303
442
|
catch {
|
|
304
443
|
logger_1.logger.info("Unknown attribute " + attributeID + " in cluster " + cluster.name, NS);
|
|
305
444
|
}
|
|
306
|
-
frame.attributes[attribute] = this.read(
|
|
445
|
+
frame.attributes[attribute] = this.read(type, options);
|
|
307
446
|
}
|
|
308
447
|
return frame;
|
|
309
448
|
}
|
|
310
449
|
else if (this.position != this.buffer.length) {
|
|
311
|
-
return { raw: this.buffer.
|
|
450
|
+
return { raw: this.buffer.subarray(this.position) };
|
|
312
451
|
}
|
|
313
452
|
else {
|
|
314
453
|
return {};
|
|
315
454
|
}
|
|
316
455
|
}
|
|
317
|
-
|
|
318
|
-
if (value
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const hasFrameCounter = gpdSecurityKeyPresent &&
|
|
326
|
-
gpdKeyEncryption &&
|
|
327
|
-
(securityLevel === 0b10 || securityLevel === 0b11);
|
|
328
|
-
this.writeUInt8(1 +
|
|
329
|
-
(panIDPresent ? 2 : 0) +
|
|
330
|
-
(gpdSecurityKeyPresent ? 16 : 0) +
|
|
331
|
-
(hasGPDKeyMIC ? 4 : 0) +
|
|
332
|
-
(hasFrameCounter ? 4 : 0)); // Length
|
|
333
|
-
this.writeUInt8(v.options);
|
|
334
|
-
if (panIDPresent) {
|
|
335
|
-
this.writeUInt16(v.panID);
|
|
336
|
-
}
|
|
337
|
-
if (gpdSecurityKeyPresent) {
|
|
338
|
-
this.writeBuffer(v.securityKey, 16);
|
|
339
|
-
}
|
|
340
|
-
if (hasGPDKeyMIC) {
|
|
341
|
-
this.writeUInt32(v.keyMic);
|
|
342
|
-
}
|
|
343
|
-
if (hasFrameCounter) {
|
|
344
|
-
this.writeUInt32(v.frameCounter);
|
|
456
|
+
writeStructuredSelector(value) {
|
|
457
|
+
if (value != null) {
|
|
458
|
+
const indexes = value.indexes || [];
|
|
459
|
+
const indicatorType = value.indicatorType || tstype_1.StructuredIndicatorType.Whole;
|
|
460
|
+
const indicator = indexes.length + indicatorType;
|
|
461
|
+
this.writeUInt8(indicator);
|
|
462
|
+
for (const index of indexes) {
|
|
463
|
+
this.writeUInt16(index);
|
|
345
464
|
}
|
|
346
465
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
466
|
+
}
|
|
467
|
+
readStructuredSelector() {
|
|
468
|
+
/** [0-15] range */
|
|
469
|
+
const indicator = this.readUInt8();
|
|
470
|
+
if (indicator === 0) {
|
|
471
|
+
// no indexes, whole attribute value is to be read
|
|
472
|
+
return { indicatorType: tstype_1.StructuredIndicatorType.Whole };
|
|
351
473
|
}
|
|
352
|
-
else
|
|
353
|
-
|
|
354
|
-
(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
474
|
+
else {
|
|
475
|
+
const indexes = [];
|
|
476
|
+
for (let i = 0; i < indicator; i++) {
|
|
477
|
+
const index = this.readUInt16();
|
|
478
|
+
indexes.push(index);
|
|
479
|
+
}
|
|
480
|
+
return { indexes };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
writeListTuyaDataPointValues(dpValues) {
|
|
484
|
+
for (const dpValue of dpValues) {
|
|
485
|
+
this.writeUInt8(dpValue.dp);
|
|
486
|
+
this.writeUInt8(dpValue.datatype);
|
|
487
|
+
const dataLen = dpValue.data.length;
|
|
488
|
+
this.writeUInt8((dataLen >> 8) & 0xFF);
|
|
489
|
+
this.writeUInt8(dataLen & 0xFF);
|
|
490
|
+
this.writeBuffer(dpValue.data, dataLen);
|
|
359
491
|
}
|
|
360
492
|
}
|
|
361
493
|
readListTuyaDataPointValues() {
|
|
@@ -375,14 +507,11 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
375
507
|
}
|
|
376
508
|
return value;
|
|
377
509
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this.
|
|
382
|
-
|
|
383
|
-
this.writeUInt8((dataLen >> 8) & 0xFF);
|
|
384
|
-
this.writeUInt8(dataLen & 0xFF);
|
|
385
|
-
this.writeBuffer(dpValue.data, dataLen);
|
|
510
|
+
writeListMiboxerZones(values) {
|
|
511
|
+
this.writeUInt8(values.length);
|
|
512
|
+
for (const value of values) {
|
|
513
|
+
this.writeUInt16(value.groupId);
|
|
514
|
+
this.writeUInt8(value.zoneNum);
|
|
386
515
|
}
|
|
387
516
|
}
|
|
388
517
|
readListMiboxerZones() {
|
|
@@ -396,193 +525,380 @@ class BuffaloZcl extends buffalo_1.Buffalo {
|
|
|
396
525
|
}
|
|
397
526
|
return value;
|
|
398
527
|
}
|
|
399
|
-
readBigEndianUInt24() {
|
|
400
|
-
return this.readBuffer(3).readUIntBE(0, 3);
|
|
401
|
-
}
|
|
402
|
-
writeListMiboxerZones(values) {
|
|
403
|
-
this.writeUInt8(values.length);
|
|
404
|
-
for (const value of values) {
|
|
405
|
-
this.writeUInt16(value.groupId);
|
|
406
|
-
this.writeUInt8(value.zoneNum);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
528
|
writeBigEndianUInt24(value) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.writeBuffer(buffer.reverse(), 3);
|
|
413
|
-
}
|
|
414
|
-
readUInt40() {
|
|
415
|
-
const lsb = this.readUInt32();
|
|
416
|
-
const msb = this.readUInt8();
|
|
417
|
-
return [msb, lsb];
|
|
418
|
-
}
|
|
419
|
-
writeUInt40(value) {
|
|
420
|
-
this.writeUInt32(value[1]);
|
|
421
|
-
this.writeUInt8(value[0]);
|
|
422
|
-
}
|
|
423
|
-
readUInt48() {
|
|
424
|
-
const lsb = this.readUInt32();
|
|
425
|
-
const msb = this.readUInt16();
|
|
426
|
-
return [msb, lsb];
|
|
427
|
-
}
|
|
428
|
-
writeUInt48(value) {
|
|
429
|
-
this.writeUInt32(value[1]);
|
|
430
|
-
this.writeUInt16(value[0]);
|
|
431
|
-
}
|
|
432
|
-
readUInt56() {
|
|
433
|
-
const lsb = this.readUInt32();
|
|
434
|
-
const xsb = this.readUInt16();
|
|
435
|
-
const msb = this.readUInt8();
|
|
436
|
-
return [msb, xsb, lsb];
|
|
529
|
+
this.buffer.writeUIntBE(value, this.position, 3);
|
|
530
|
+
this.position += 3;
|
|
437
531
|
}
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
this.writeBuffer(temp.slice(0, 7), 7);
|
|
443
|
-
}
|
|
444
|
-
readUInt64() {
|
|
445
|
-
return this.readIeeeAddr();
|
|
446
|
-
}
|
|
447
|
-
writeUInt64(value) {
|
|
448
|
-
const msb = parseInt(value.slice(2, 10), 16);
|
|
449
|
-
const lsb = parseInt(value.slice(10), 16);
|
|
450
|
-
this.writeUInt32(lsb);
|
|
451
|
-
this.writeUInt32(msb);
|
|
452
|
-
}
|
|
453
|
-
writeStructuredSelector(value) {
|
|
454
|
-
if (value != null) {
|
|
455
|
-
const indexes = value.indexes || [];
|
|
456
|
-
const indicatorType = value.indicatorType || tstype_1.StructuredIndicatorType.WriteWhole;
|
|
457
|
-
const indicator = indexes.length + indicatorType;
|
|
458
|
-
this.writeUInt8(indicator);
|
|
459
|
-
for (const index of indexes) {
|
|
460
|
-
this.writeUInt16(index);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
532
|
+
readBigEndianUInt24() {
|
|
533
|
+
const value = this.buffer.readUIntBE(this.position, 3);
|
|
534
|
+
this.position += 3;
|
|
535
|
+
return value;
|
|
463
536
|
}
|
|
537
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
464
538
|
write(type, value, options) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
539
|
+
switch (type) {
|
|
540
|
+
case definition_1.DataType.NO_DATA:
|
|
541
|
+
case definition_1.DataType.UNKNOWN: {
|
|
542
|
+
return; // nothing to write
|
|
543
|
+
}
|
|
544
|
+
case definition_1.DataType.DATA8:
|
|
545
|
+
case definition_1.DataType.BOOLEAN:
|
|
546
|
+
case definition_1.DataType.BITMAP8:
|
|
547
|
+
case definition_1.DataType.UINT8:
|
|
548
|
+
case definition_1.DataType.ENUM8: {
|
|
549
|
+
return this.writeUInt8(value);
|
|
550
|
+
}
|
|
551
|
+
case definition_1.DataType.DATA16:
|
|
552
|
+
case definition_1.DataType.BITMAP16:
|
|
553
|
+
case definition_1.DataType.UINT16:
|
|
554
|
+
case definition_1.DataType.ENUM16:
|
|
555
|
+
case definition_1.DataType.CLUSTER_ID:
|
|
556
|
+
case definition_1.DataType.ATTR_ID: {
|
|
557
|
+
return this.writeUInt16(value);
|
|
558
|
+
}
|
|
559
|
+
case definition_1.DataType.DATA24:
|
|
560
|
+
case definition_1.DataType.BITMAP24:
|
|
561
|
+
case definition_1.DataType.UINT24: {
|
|
562
|
+
return this.writeUInt24(value);
|
|
563
|
+
}
|
|
564
|
+
case definition_1.DataType.DATA32:
|
|
565
|
+
case definition_1.DataType.BITMAP32:
|
|
566
|
+
case definition_1.DataType.UINT32:
|
|
567
|
+
case definition_1.DataType.UTC:
|
|
568
|
+
case definition_1.DataType.BAC_OID: {
|
|
569
|
+
return this.writeUInt32(value);
|
|
570
|
+
}
|
|
571
|
+
case definition_1.DataType.DATA40:
|
|
572
|
+
case definition_1.DataType.BITMAP40:
|
|
573
|
+
case definition_1.DataType.UINT40: {
|
|
574
|
+
return this.writeUInt40SB(value);
|
|
575
|
+
}
|
|
576
|
+
case definition_1.DataType.DATA48:
|
|
577
|
+
case definition_1.DataType.BITMAP48:
|
|
578
|
+
case definition_1.DataType.UINT48: {
|
|
579
|
+
return this.writeUInt48SB(value);
|
|
580
|
+
}
|
|
581
|
+
case definition_1.DataType.DATA56:
|
|
582
|
+
case definition_1.DataType.BITMAP56:
|
|
583
|
+
case definition_1.DataType.UINT56: {
|
|
584
|
+
return this.writeUInt56SB(value);
|
|
585
|
+
}
|
|
586
|
+
case definition_1.DataType.DATA64:
|
|
587
|
+
case definition_1.DataType.BITMAP64:
|
|
588
|
+
case definition_1.DataType.UINT64: {
|
|
589
|
+
return this.writeUInt64SB(value);
|
|
590
|
+
}
|
|
591
|
+
case definition_1.DataType.INT8: {
|
|
592
|
+
return this.writeInt8(value);
|
|
593
|
+
}
|
|
594
|
+
case definition_1.DataType.INT16: {
|
|
595
|
+
return this.writeInt16(value);
|
|
596
|
+
}
|
|
597
|
+
case definition_1.DataType.INT24: {
|
|
598
|
+
return this.writeInt24(value);
|
|
599
|
+
}
|
|
600
|
+
case definition_1.DataType.INT32: {
|
|
601
|
+
return this.writeInt32(value);
|
|
602
|
+
}
|
|
603
|
+
case definition_1.DataType.INT40: {
|
|
604
|
+
return this.writeInt40SB(value);
|
|
605
|
+
}
|
|
606
|
+
case definition_1.DataType.INT48: {
|
|
607
|
+
return this.writeInt48(value);
|
|
608
|
+
}
|
|
609
|
+
case definition_1.DataType.INT56: {
|
|
610
|
+
return this.writeInt56SB(value);
|
|
611
|
+
}
|
|
612
|
+
case definition_1.DataType.INT64: {
|
|
613
|
+
return this.writeInt64SB(value);
|
|
614
|
+
}
|
|
615
|
+
// case DataType.SEMI_PREC: {
|
|
616
|
+
// // https://tc39.es/proposal-float16array/
|
|
617
|
+
// // not currently used
|
|
618
|
+
// return this.writeSemiFloatLE(value);
|
|
619
|
+
// }
|
|
620
|
+
case definition_1.DataType.SINGLE_PREC: {
|
|
621
|
+
return this.writeFloatLE(value);
|
|
622
|
+
}
|
|
623
|
+
case definition_1.DataType.DOUBLE_PREC: {
|
|
624
|
+
return this.writeDoubleLE(value);
|
|
625
|
+
}
|
|
626
|
+
case definition_1.DataType.OCTET_STR: {
|
|
627
|
+
return this.writeOctetStr(value);
|
|
628
|
+
}
|
|
629
|
+
case definition_1.DataType.CHAR_STR: {
|
|
630
|
+
return this.writeCharStr(value);
|
|
631
|
+
}
|
|
632
|
+
case definition_1.DataType.LONG_OCTET_STR: {
|
|
633
|
+
return this.writeLongOctetStr(value);
|
|
634
|
+
}
|
|
635
|
+
case definition_1.DataType.LONG_CHAR_STR: {
|
|
636
|
+
return this.writeLongCharStr(value);
|
|
637
|
+
}
|
|
638
|
+
case definition_1.DataType.ARRAY:
|
|
639
|
+
case definition_1.DataType.SET:
|
|
640
|
+
case definition_1.DataType.BAG: {
|
|
641
|
+
return this.writeArray(value);
|
|
642
|
+
}
|
|
643
|
+
case definition_1.DataType.STRUCT: {
|
|
644
|
+
return this.writeStruct(value);
|
|
645
|
+
}
|
|
646
|
+
case definition_1.DataType.TOD: {
|
|
647
|
+
return this.writeToD(value);
|
|
648
|
+
}
|
|
649
|
+
case definition_1.DataType.DATE: {
|
|
650
|
+
return this.writeDate(value);
|
|
651
|
+
}
|
|
652
|
+
case definition_1.DataType.IEEE_ADDR: {
|
|
653
|
+
return this.writeIeeeAddr(value);
|
|
654
|
+
}
|
|
655
|
+
case definition_1.DataType.SEC_KEY: {
|
|
656
|
+
return this.writeBuffer(value, SEC_KEY_LENGTH);
|
|
657
|
+
}
|
|
658
|
+
case definition_1.BuffaloZclDataType.USE_DATA_TYPE: {
|
|
659
|
+
if (options.dataType == null) {
|
|
660
|
+
if (Buffer.isBuffer(value) || (0, utils_1.IsNumberArray)(value)) {
|
|
661
|
+
return this.writeBuffer(value, value.length);
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
throw new Error('Cannot write USE_DATA_TYPE without dataType option specified');
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return this.write(options.dataType, value, options);
|
|
668
|
+
}
|
|
669
|
+
case definition_1.BuffaloZclDataType.LIST_UINT8: {
|
|
670
|
+
return this.writeListUInt8(value);
|
|
671
|
+
}
|
|
672
|
+
case definition_1.BuffaloZclDataType.LIST_UINT16: {
|
|
673
|
+
return this.writeListUInt16(value);
|
|
674
|
+
}
|
|
675
|
+
case definition_1.BuffaloZclDataType.LIST_UINT24: {
|
|
676
|
+
return this.writeListUInt24(value);
|
|
677
|
+
}
|
|
678
|
+
case definition_1.BuffaloZclDataType.LIST_UINT32: {
|
|
679
|
+
return this.writeListUInt32(value);
|
|
680
|
+
}
|
|
681
|
+
case definition_1.BuffaloZclDataType.LIST_ZONEINFO: {
|
|
682
|
+
return this.writeListZoneInfo(value);
|
|
683
|
+
}
|
|
684
|
+
case definition_1.BuffaloZclDataType.EXTENSION_FIELD_SETS: {
|
|
685
|
+
return this.writeExtensionFieldSets(value);
|
|
686
|
+
}
|
|
687
|
+
case definition_1.BuffaloZclDataType.LIST_THERMO_TRANSITIONS: {
|
|
688
|
+
return this.writeListThermoTransitions(value);
|
|
689
|
+
}
|
|
690
|
+
case definition_1.BuffaloZclDataType.BUFFER: {
|
|
691
|
+
return this.writeBuffer(value, value.length);
|
|
692
|
+
}
|
|
693
|
+
case definition_1.BuffaloZclDataType.GDP_FRAME: {
|
|
694
|
+
return this.writeGdpFrame(value);
|
|
695
|
+
}
|
|
696
|
+
case definition_1.BuffaloZclDataType.STRUCTURED_SELECTOR: {
|
|
697
|
+
return this.writeStructuredSelector(value);
|
|
698
|
+
}
|
|
699
|
+
case definition_1.BuffaloZclDataType.LIST_TUYA_DATAPOINT_VALUES: {
|
|
700
|
+
return this.writeListTuyaDataPointValues(value);
|
|
701
|
+
}
|
|
702
|
+
case definition_1.BuffaloZclDataType.LIST_MIBOXER_ZONES: {
|
|
703
|
+
return this.writeListMiboxerZones(value);
|
|
704
|
+
}
|
|
705
|
+
case definition_1.BuffaloZclDataType.BIG_ENDIAN_UINT24: {
|
|
706
|
+
return this.writeBigEndianUInt24(value);
|
|
707
|
+
}
|
|
708
|
+
default: {
|
|
709
|
+
// In case the type is undefined, write it as a buffer to easily allow for custom types
|
|
710
|
+
// e.g. for https://github.com/Koenkk/zigbee-herdsman/issues/127
|
|
711
|
+
if (Buffer.isBuffer(value) || (0, utils_1.IsNumberArray)(value)) {
|
|
712
|
+
return this.writeBuffer(value, value.length);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
524
715
|
}
|
|
716
|
+
throw new Error(`Write for '${type}' not available`);
|
|
525
717
|
}
|
|
718
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
526
719
|
read(type, options) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
720
|
+
switch (type) {
|
|
721
|
+
case definition_1.DataType.NO_DATA:
|
|
722
|
+
case definition_1.DataType.UNKNOWN: {
|
|
723
|
+
return; // nothing to write
|
|
724
|
+
}
|
|
725
|
+
case definition_1.DataType.DATA8:
|
|
726
|
+
case definition_1.DataType.BOOLEAN:
|
|
727
|
+
case definition_1.DataType.BITMAP8:
|
|
728
|
+
case definition_1.DataType.UINT8:
|
|
729
|
+
case definition_1.DataType.ENUM8: {
|
|
730
|
+
return this.readUInt8();
|
|
731
|
+
}
|
|
732
|
+
case definition_1.DataType.DATA16:
|
|
733
|
+
case definition_1.DataType.BITMAP16:
|
|
734
|
+
case definition_1.DataType.UINT16:
|
|
735
|
+
case definition_1.DataType.ENUM16:
|
|
736
|
+
case definition_1.DataType.CLUSTER_ID:
|
|
737
|
+
case definition_1.DataType.ATTR_ID: {
|
|
738
|
+
return this.readUInt16();
|
|
739
|
+
}
|
|
740
|
+
case definition_1.DataType.DATA24:
|
|
741
|
+
case definition_1.DataType.BITMAP24:
|
|
742
|
+
case definition_1.DataType.UINT24: {
|
|
743
|
+
return this.readUInt24();
|
|
744
|
+
}
|
|
745
|
+
case definition_1.DataType.DATA32:
|
|
746
|
+
case definition_1.DataType.BITMAP32:
|
|
747
|
+
case definition_1.DataType.UINT32:
|
|
748
|
+
case definition_1.DataType.UTC:
|
|
749
|
+
case definition_1.DataType.BAC_OID: {
|
|
750
|
+
return this.readUInt32();
|
|
751
|
+
}
|
|
752
|
+
case definition_1.DataType.DATA40:
|
|
753
|
+
case definition_1.DataType.BITMAP40:
|
|
754
|
+
case definition_1.DataType.UINT40: {
|
|
755
|
+
return this.readUInt40SB();
|
|
756
|
+
}
|
|
757
|
+
case definition_1.DataType.DATA48:
|
|
758
|
+
case definition_1.DataType.BITMAP48:
|
|
759
|
+
case definition_1.DataType.UINT48: {
|
|
760
|
+
return this.readUInt48SB();
|
|
761
|
+
}
|
|
762
|
+
case definition_1.DataType.DATA56:
|
|
763
|
+
case definition_1.DataType.BITMAP56:
|
|
764
|
+
case definition_1.DataType.UINT56: {
|
|
765
|
+
return this.readUInt56SB();
|
|
766
|
+
}
|
|
767
|
+
case definition_1.DataType.DATA64:
|
|
768
|
+
case definition_1.DataType.BITMAP64:
|
|
769
|
+
case definition_1.DataType.UINT64: {
|
|
770
|
+
return this.readUInt64SB();
|
|
771
|
+
}
|
|
772
|
+
case definition_1.DataType.INT8: {
|
|
773
|
+
return this.readInt8();
|
|
774
|
+
}
|
|
775
|
+
case definition_1.DataType.INT16: {
|
|
776
|
+
return this.readInt16();
|
|
777
|
+
}
|
|
778
|
+
case definition_1.DataType.INT24: {
|
|
779
|
+
return this.readInt24();
|
|
780
|
+
}
|
|
781
|
+
case definition_1.DataType.INT32: {
|
|
782
|
+
return this.readInt32();
|
|
783
|
+
}
|
|
784
|
+
case definition_1.DataType.INT40: {
|
|
785
|
+
return this.readInt40SB();
|
|
786
|
+
}
|
|
787
|
+
case definition_1.DataType.INT48: {
|
|
788
|
+
return this.readInt48();
|
|
789
|
+
}
|
|
790
|
+
case definition_1.DataType.INT56: {
|
|
791
|
+
return this.readInt56SB();
|
|
792
|
+
}
|
|
793
|
+
case definition_1.DataType.INT64: {
|
|
794
|
+
return this.readInt64SB();
|
|
795
|
+
}
|
|
796
|
+
// case DataType.SEMI_PREC: {
|
|
797
|
+
// // https://tc39.es/proposal-float16array/
|
|
798
|
+
// // not currently used
|
|
799
|
+
// return this.readSemiFloatLE();
|
|
800
|
+
// }
|
|
801
|
+
case definition_1.DataType.SINGLE_PREC: {
|
|
802
|
+
return this.readFloatLE();
|
|
803
|
+
}
|
|
804
|
+
case definition_1.DataType.DOUBLE_PREC: {
|
|
805
|
+
return this.readDoubleLE();
|
|
806
|
+
}
|
|
807
|
+
case definition_1.DataType.OCTET_STR: {
|
|
808
|
+
return this.readOctetStr();
|
|
809
|
+
}
|
|
810
|
+
case definition_1.DataType.CHAR_STR: {
|
|
811
|
+
return this.readCharStr(options);
|
|
812
|
+
}
|
|
813
|
+
case definition_1.DataType.LONG_OCTET_STR: {
|
|
814
|
+
return this.readLongOctetStr();
|
|
815
|
+
}
|
|
816
|
+
case definition_1.DataType.LONG_CHAR_STR: {
|
|
817
|
+
return this.readLongCharStr();
|
|
818
|
+
}
|
|
819
|
+
case definition_1.DataType.ARRAY:
|
|
820
|
+
case definition_1.DataType.SET:
|
|
821
|
+
case definition_1.DataType.BAG: {
|
|
822
|
+
return this.readArray();
|
|
823
|
+
}
|
|
824
|
+
case definition_1.DataType.STRUCT: {
|
|
825
|
+
return this.readStruct();
|
|
826
|
+
}
|
|
827
|
+
case definition_1.DataType.TOD: {
|
|
828
|
+
return this.readToD();
|
|
829
|
+
}
|
|
830
|
+
case definition_1.DataType.DATE: {
|
|
831
|
+
return this.readDate();
|
|
832
|
+
}
|
|
833
|
+
case definition_1.DataType.IEEE_ADDR: {
|
|
834
|
+
return this.readIeeeAddr();
|
|
835
|
+
}
|
|
836
|
+
case definition_1.DataType.SEC_KEY: {
|
|
837
|
+
return this.readBuffer(SEC_KEY_LENGTH);
|
|
838
|
+
}
|
|
839
|
+
case definition_1.BuffaloZclDataType.USE_DATA_TYPE: {
|
|
840
|
+
if (options.dataType == null) {
|
|
841
|
+
return this.readBuffer(options.length ?? this.buffer.length);
|
|
842
|
+
}
|
|
843
|
+
return this.read(options.dataType, options);
|
|
844
|
+
}
|
|
845
|
+
case definition_1.BuffaloZclDataType.LIST_UINT8: {
|
|
846
|
+
if (options.length == null) {
|
|
847
|
+
throw new Error('Cannot read LIST_UINT8 without length option specified');
|
|
848
|
+
}
|
|
849
|
+
return this.readListUInt8(options.length);
|
|
850
|
+
}
|
|
851
|
+
case definition_1.BuffaloZclDataType.LIST_UINT16: {
|
|
852
|
+
if (options.length == null) {
|
|
853
|
+
throw new Error('Cannot read LIST_UINT16 without length option specified');
|
|
854
|
+
}
|
|
855
|
+
return this.readListUInt16(options.length);
|
|
856
|
+
}
|
|
857
|
+
case definition_1.BuffaloZclDataType.LIST_UINT24: {
|
|
858
|
+
if (options.length == null) {
|
|
859
|
+
throw new Error('Cannot read LIST_UINT24 without length option specified');
|
|
860
|
+
}
|
|
861
|
+
return this.readListUInt24(options.length);
|
|
862
|
+
}
|
|
863
|
+
case definition_1.BuffaloZclDataType.LIST_UINT32: {
|
|
864
|
+
if (options.length == null) {
|
|
865
|
+
throw new Error('Cannot read LIST_UINT32 without length option specified');
|
|
866
|
+
}
|
|
867
|
+
return this.readListUInt32(options.length);
|
|
868
|
+
}
|
|
869
|
+
case definition_1.BuffaloZclDataType.LIST_ZONEINFO: {
|
|
870
|
+
if (options.length == null) {
|
|
871
|
+
throw new Error('Cannot read LIST_ZONEINFO without length option specified');
|
|
872
|
+
}
|
|
873
|
+
return this.readListZoneInfo(options.length);
|
|
874
|
+
}
|
|
875
|
+
case definition_1.BuffaloZclDataType.EXTENSION_FIELD_SETS: {
|
|
876
|
+
return this.readExtensionFieldSets();
|
|
877
|
+
}
|
|
878
|
+
case definition_1.BuffaloZclDataType.LIST_THERMO_TRANSITIONS: {
|
|
879
|
+
return this.readListThermoTransitions(options);
|
|
880
|
+
}
|
|
881
|
+
case definition_1.BuffaloZclDataType.BUFFER: {
|
|
882
|
+
// if length option not specified, read the whole buffer
|
|
883
|
+
return this.readBuffer(options.length ?? this.buffer.length);
|
|
884
|
+
}
|
|
885
|
+
case definition_1.BuffaloZclDataType.GDP_FRAME: {
|
|
886
|
+
return this.readGdpFrame(options);
|
|
887
|
+
}
|
|
888
|
+
case definition_1.BuffaloZclDataType.STRUCTURED_SELECTOR: {
|
|
889
|
+
return this.readStructuredSelector();
|
|
890
|
+
}
|
|
891
|
+
case definition_1.BuffaloZclDataType.LIST_TUYA_DATAPOINT_VALUES: {
|
|
892
|
+
return this.readListTuyaDataPointValues();
|
|
893
|
+
}
|
|
894
|
+
case definition_1.BuffaloZclDataType.LIST_MIBOXER_ZONES: {
|
|
895
|
+
return this.readListMiboxerZones();
|
|
896
|
+
}
|
|
897
|
+
case definition_1.BuffaloZclDataType.BIG_ENDIAN_UINT24: {
|
|
898
|
+
return this.readBigEndianUInt24();
|
|
899
|
+
}
|
|
585
900
|
}
|
|
901
|
+
throw new Error(`Read for '${type}' not available`);
|
|
586
902
|
}
|
|
587
903
|
}
|
|
588
904
|
exports.default = BuffaloZcl;
|