zigbee-herdsman 0.33.9 → 0.34.2

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.
Files changed (122) hide show
  1. package/.github/workflows/ci.yml +2 -2
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +27 -0
  4. package/dist/adapter/adapter.d.ts.map +1 -1
  5. package/dist/adapter/adapter.js +2 -1
  6. package/dist/adapter/adapter.js.map +1 -1
  7. package/dist/adapter/ember/adapter/emberAdapter.d.ts +818 -0
  8. package/dist/adapter/ember/adapter/emberAdapter.d.ts.map +1 -0
  9. package/dist/adapter/ember/adapter/emberAdapter.js +2991 -0
  10. package/dist/adapter/ember/adapter/emberAdapter.js.map +1 -0
  11. package/dist/adapter/ember/adapter/endpoints.d.ts +25 -0
  12. package/dist/adapter/ember/adapter/endpoints.d.ts.map +1 -0
  13. package/dist/adapter/ember/adapter/endpoints.js +66 -0
  14. package/dist/adapter/ember/adapter/endpoints.js.map +1 -0
  15. package/dist/adapter/ember/adapter/index.d.ts +3 -0
  16. package/dist/adapter/ember/adapter/index.d.ts.map +1 -0
  17. package/dist/adapter/ember/adapter/index.js +6 -0
  18. package/dist/adapter/ember/adapter/index.js.map +1 -0
  19. package/dist/adapter/ember/adapter/oneWaitress.d.ts +97 -0
  20. package/dist/adapter/ember/adapter/oneWaitress.d.ts.map +1 -0
  21. package/dist/adapter/ember/adapter/oneWaitress.js +226 -0
  22. package/dist/adapter/ember/adapter/oneWaitress.js.map +1 -0
  23. package/dist/adapter/ember/adapter/requestQueue.d.ts +59 -0
  24. package/dist/adapter/ember/adapter/requestQueue.d.ts.map +1 -0
  25. package/dist/adapter/ember/adapter/requestQueue.js +144 -0
  26. package/dist/adapter/ember/adapter/requestQueue.js.map +1 -0
  27. package/dist/adapter/ember/adapter/tokensManager.d.ts +69 -0
  28. package/dist/adapter/ember/adapter/tokensManager.d.ts.map +1 -0
  29. package/dist/adapter/ember/adapter/tokensManager.js +685 -0
  30. package/dist/adapter/ember/adapter/tokensManager.js.map +1 -0
  31. package/dist/adapter/ember/consts.d.ts +198 -0
  32. package/dist/adapter/ember/consts.d.ts.map +1 -0
  33. package/dist/adapter/ember/consts.js +253 -0
  34. package/dist/adapter/ember/consts.js.map +1 -0
  35. package/dist/adapter/ember/enums.d.ts +2184 -0
  36. package/dist/adapter/ember/enums.d.ts.map +1 -0
  37. package/dist/adapter/ember/enums.js +2391 -0
  38. package/dist/adapter/ember/enums.js.map +1 -0
  39. package/dist/adapter/ember/ezsp/buffalo.d.ts +156 -0
  40. package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -0
  41. package/dist/adapter/ember/ezsp/buffalo.js +1033 -0
  42. package/dist/adapter/ember/ezsp/buffalo.js.map +1 -0
  43. package/dist/adapter/ember/ezsp/consts.d.ts +116 -0
  44. package/dist/adapter/ember/ezsp/consts.d.ts.map +1 -0
  45. package/dist/adapter/ember/ezsp/consts.js +128 -0
  46. package/dist/adapter/ember/ezsp/consts.js.map +1 -0
  47. package/dist/adapter/ember/ezsp/enums.d.ts +879 -0
  48. package/dist/adapter/ember/ezsp/enums.d.ts.map +1 -0
  49. package/dist/adapter/ember/ezsp/enums.js +948 -0
  50. package/dist/adapter/ember/ezsp/enums.js.map +1 -0
  51. package/dist/adapter/ember/ezsp/ezsp.d.ts +2664 -0
  52. package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -0
  53. package/dist/adapter/ember/ezsp/ezsp.js +6449 -0
  54. package/dist/adapter/ember/ezsp/ezsp.js.map +1 -0
  55. package/dist/adapter/ember/types.d.ts +733 -0
  56. package/dist/adapter/ember/types.d.ts.map +1 -0
  57. package/dist/adapter/ember/types.js +3 -0
  58. package/dist/adapter/ember/types.js.map +1 -0
  59. package/dist/adapter/ember/uart/ash.d.ts +443 -0
  60. package/dist/adapter/ember/uart/ash.d.ts.map +1 -0
  61. package/dist/adapter/ember/uart/ash.js +1567 -0
  62. package/dist/adapter/ember/uart/ash.js.map +1 -0
  63. package/dist/adapter/ember/uart/consts.d.ts +91 -0
  64. package/dist/adapter/ember/uart/consts.d.ts.map +1 -0
  65. package/dist/adapter/ember/uart/consts.js +100 -0
  66. package/dist/adapter/ember/uart/consts.js.map +1 -0
  67. package/dist/adapter/ember/uart/enums.d.ts +191 -0
  68. package/dist/adapter/ember/uart/enums.d.ts.map +1 -0
  69. package/dist/adapter/ember/uart/enums.js +197 -0
  70. package/dist/adapter/ember/uart/enums.js.map +1 -0
  71. package/dist/adapter/ember/uart/parser.d.ts +10 -0
  72. package/dist/adapter/ember/uart/parser.d.ts.map +1 -0
  73. package/dist/adapter/ember/uart/parser.js +41 -0
  74. package/dist/adapter/ember/uart/parser.js.map +1 -0
  75. package/dist/adapter/ember/uart/queues.d.ts +85 -0
  76. package/dist/adapter/ember/uart/queues.d.ts.map +1 -0
  77. package/dist/adapter/ember/uart/queues.js +212 -0
  78. package/dist/adapter/ember/uart/queues.js.map +1 -0
  79. package/dist/adapter/ember/uart/writer.d.ts +15 -0
  80. package/dist/adapter/ember/uart/writer.d.ts.map +1 -0
  81. package/dist/adapter/ember/uart/writer.js +48 -0
  82. package/dist/adapter/ember/uart/writer.js.map +1 -0
  83. package/dist/adapter/ember/utils/initters.d.ts +20 -0
  84. package/dist/adapter/ember/utils/initters.d.ts.map +1 -0
  85. package/dist/adapter/ember/utils/initters.js +58 -0
  86. package/dist/adapter/ember/utils/initters.js.map +1 -0
  87. package/dist/adapter/ember/utils/math.d.ts +51 -0
  88. package/dist/adapter/ember/utils/math.d.ts.map +1 -0
  89. package/dist/adapter/ember/utils/math.js +102 -0
  90. package/dist/adapter/ember/utils/math.js.map +1 -0
  91. package/dist/adapter/ember/zdo.d.ts +921 -0
  92. package/dist/adapter/ember/zdo.d.ts.map +1 -0
  93. package/dist/adapter/ember/zdo.js +723 -0
  94. package/dist/adapter/ember/zdo.js.map +1 -0
  95. package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
  96. package/dist/adapter/ezsp/adapter/ezspAdapter.js +28 -22
  97. package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
  98. package/dist/adapter/ezsp/driver/driver.d.ts +1 -2
  99. package/dist/adapter/ezsp/driver/driver.d.ts.map +1 -1
  100. package/dist/adapter/ezsp/driver/driver.js +21 -21
  101. package/dist/adapter/ezsp/driver/driver.js.map +1 -1
  102. package/dist/adapter/ezsp/driver/ezsp.d.ts +2 -0
  103. package/dist/adapter/ezsp/driver/ezsp.d.ts.map +1 -1
  104. package/dist/adapter/ezsp/driver/ezsp.js +24 -5
  105. package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
  106. package/dist/adapter/ezsp/driver/parser.d.ts +1 -2
  107. package/dist/adapter/ezsp/driver/parser.d.ts.map +1 -1
  108. package/dist/adapter/ezsp/driver/parser.js +29 -40
  109. package/dist/adapter/ezsp/driver/parser.js.map +1 -1
  110. package/dist/adapter/ezsp/driver/uart.d.ts +1 -0
  111. package/dist/adapter/ezsp/driver/uart.d.ts.map +1 -1
  112. package/dist/adapter/ezsp/driver/uart.js +38 -13
  113. package/dist/adapter/ezsp/driver/uart.js.map +1 -1
  114. package/dist/adapter/ezsp/driver/writer.d.ts.map +1 -1
  115. package/dist/adapter/ezsp/driver/writer.js +10 -13
  116. package/dist/adapter/ezsp/driver/writer.js.map +1 -1
  117. package/dist/adapter/tstype.d.ts +1 -1
  118. package/dist/adapter/tstype.d.ts.map +1 -1
  119. package/dist/utils/backup.d.ts.map +1 -1
  120. package/dist/utils/backup.js +4 -0
  121. package/dist/utils/backup.js.map +1 -1
  122. package/package.json +1 -1
@@ -0,0 +1,1033 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EzspBuffalo = void 0;
7
+ /* istanbul ignore file */
8
+ const buffalo_1 = __importDefault(require("../../../buffalo/buffalo"));
9
+ const consts_1 = require("../consts");
10
+ const enums_1 = require("../enums");
11
+ const math_1 = require("../utils/math");
12
+ const consts_2 = require("./consts");
13
+ class EzspBuffalo extends buffalo_1.default {
14
+ getBufferLength() {
15
+ return this.buffer.length;
16
+ }
17
+ /** Set the position of the internal position tracker. */
18
+ setPosition(position) {
19
+ this.position = position;
20
+ }
21
+ /**
22
+ * Set the byte at given position without affecting the internal position tracker.
23
+ * @param position
24
+ * @param value
25
+ */
26
+ setCommandByte(position, value) {
27
+ this.buffer.writeUInt8(value, position);
28
+ }
29
+ /**
30
+ * Get the byte at given position without affecting the internal position tracker.
31
+ * @param position
32
+ * @returns
33
+ */
34
+ getCommandByte(position) {
35
+ return this.buffer.readUInt8(position);
36
+ }
37
+ /**
38
+ * Get the byte at given position without affecting the internal position tracker.
39
+ * @param position
40
+ * @returns
41
+ */
42
+ getResponseByte(position) {
43
+ return this.buffer.readUInt8(position);
44
+ }
45
+ getExtFrameControl() {
46
+ return (this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) << 8 | this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_CONTROL_LB_INDEX));
47
+ }
48
+ getExtFrameId() {
49
+ return (this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_ID_HB_INDEX) << 8 | this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_ID_LB_INDEX));
50
+ }
51
+ getFrameId() {
52
+ if ((this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) & consts_2.EZSP_EXTENDED_FRAME_FORMAT_VERSION_MASK)
53
+ === consts_2.EZSP_EXTENDED_FRAME_FORMAT_VERSION) {
54
+ return this.getExtFrameId();
55
+ }
56
+ else {
57
+ return this.getResponseByte(consts_2.EZSP_FRAME_ID_INDEX);
58
+ }
59
+ }
60
+ /**
61
+ * Get the frame control, ID and params index according to format version.
62
+ * Throws if frame control is unsupported (using reserved).
63
+ * @returns Anything but SUCCESS should stop further processing.
64
+ */
65
+ getResponseMetadata() {
66
+ let status = enums_1.EzspStatus.SUCCESS;
67
+ let frameControl;
68
+ let frameId;
69
+ let parametersIndex;
70
+ if ((this.getResponseByte(consts_2.EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) & consts_2.EZSP_EXTENDED_FRAME_FORMAT_VERSION_MASK)
71
+ === consts_2.EZSP_EXTENDED_FRAME_FORMAT_VERSION) {
72
+ // use extended ezsp frame format
73
+ frameControl = this.getExtFrameControl();
74
+ frameId = this.getExtFrameId();
75
+ parametersIndex = consts_2.EZSP_EXTENDED_PARAMETERS_INDEX;
76
+ if ((0, math_1.highByte)(frameControl) & consts_2.EZSP_EXTENDED_FRAME_CONTROL_RESERVED_MASK) {
77
+ // reject if unsupported frame
78
+ status = enums_1.EzspStatus.ERROR_UNSUPPORTED_CONTROL;
79
+ }
80
+ }
81
+ else {
82
+ // use legacy ezsp frame format
83
+ frameControl = this.getResponseByte(consts_2.EZSP_FRAME_CONTROL_INDEX);
84
+ frameId = this.getResponseByte(consts_2.EZSP_FRAME_ID_INDEX);
85
+ parametersIndex = consts_2.EZSP_PARAMETERS_INDEX;
86
+ }
87
+ return [status, frameControl, frameId, parametersIndex];
88
+ }
89
+ /**
90
+ * Get a copy of the rest of the buffer (from current position to end).
91
+ * WARNING: Make sure the length is appropriate, if alloc'ed longer, it will return everything until the end.
92
+ * @returns
93
+ */
94
+ readRest() {
95
+ return Buffer.from(this.buffer.subarray(this.position));
96
+ }
97
+ /**
98
+ * This is mostly used for payload/encryption stuff.
99
+ * Copies the buffer to avoid memory referencing issues since Ezsp has a single buffer allocated.
100
+ * @param length
101
+ * @returns
102
+ */
103
+ readBufferCopy(length) {
104
+ return Buffer.from(this.readBuffer(length));
105
+ }
106
+ /**
107
+ * Write a uint8_t for payload length, followed by payload buffer (copied at post-length position).
108
+ *
109
+ * WARNING: `payload` must have a valid length (as in, not a Buffer allocated to longer length).
110
+ * Should be passed with getWritten() in most cases.
111
+ * @param payload
112
+ */
113
+ writePayload(payload) {
114
+ this.writeUInt8(payload.length);
115
+ this.position += payload.copy(this.buffer, this.position);
116
+ }
117
+ /**
118
+ * Read a uint8_t for payload length, followed by payload buffer (using post-length position).
119
+ * @returns
120
+ */
121
+ readPayload() {
122
+ const messageLength = this.readUInt8();
123
+ return this.readBufferCopy(messageLength);
124
+ }
125
+ writeEmberNetworkParameters(value) {
126
+ this.writeListUInt8(value.extendedPanId);
127
+ this.writeUInt16(value.panId);
128
+ this.writeUInt8(value.radioTxPower);
129
+ this.writeUInt8(value.radioChannel);
130
+ this.writeUInt8(value.joinMethod);
131
+ this.writeUInt16(value.nwkManagerId);
132
+ this.writeUInt8(value.nwkUpdateId);
133
+ this.writeUInt32(value.channels);
134
+ }
135
+ readEmberNetworkParameters() {
136
+ const extendedPanId = this.readListUInt8({ length: consts_2.EXTENDED_PAN_ID_SIZE });
137
+ const panId = this.readUInt16();
138
+ const radioTxPower = this.readUInt8();
139
+ const radioChannel = this.readUInt8();
140
+ const joinMethod = this.readUInt8();
141
+ const nwkManagerId = this.readUInt16();
142
+ const nwkUpdateId = this.readUInt8();
143
+ const channels = this.readUInt32();
144
+ return {
145
+ extendedPanId,
146
+ panId,
147
+ radioTxPower,
148
+ radioChannel,
149
+ joinMethod,
150
+ nwkManagerId,
151
+ nwkUpdateId,
152
+ channels,
153
+ };
154
+ }
155
+ writeEmberMultiPhyRadioParameters(value) {
156
+ this.writeUInt8(value.radioTxPower);
157
+ this.writeUInt8(value.radioPage);
158
+ this.writeUInt8(value.radioChannel);
159
+ }
160
+ readEmberMultiPhyRadioParameters() {
161
+ const radioTxPower = this.readUInt8();
162
+ const radioPage = this.readUInt8();
163
+ const radioChannel = this.readUInt8();
164
+ return { radioTxPower, radioPage, radioChannel };
165
+ }
166
+ writeEmberApsFrame(value) {
167
+ this.writeUInt16(value.profileId);
168
+ this.writeUInt16(value.clusterId);
169
+ this.writeUInt8(value.sourceEndpoint);
170
+ this.writeUInt8(value.destinationEndpoint);
171
+ this.writeUInt16(value.options);
172
+ this.writeUInt16(value.groupId);
173
+ this.writeUInt8(value.sequence);
174
+ // this.writeUInt8(value.radius);// XXX: not in gecko_sdk, appended with separate param
175
+ }
176
+ readEmberApsFrame() {
177
+ const profileId = this.readUInt16();
178
+ const clusterId = this.readUInt16();
179
+ const sourceEndpoint = this.readUInt8();
180
+ const destinationEndpoint = this.readUInt8();
181
+ const options = this.readUInt16();
182
+ const groupId = this.readUInt16();
183
+ const sequence = this.readUInt8();
184
+ // const radius = this.readUInt8();// XXX: not in gecko_sdk, appended with separate param
185
+ return {
186
+ profileId,
187
+ clusterId,
188
+ sourceEndpoint,
189
+ destinationEndpoint,
190
+ options,
191
+ groupId,
192
+ sequence,
193
+ // radius,
194
+ };
195
+ }
196
+ writeEmberBindingTableEntry(value) {
197
+ this.writeUInt8(value.type);
198
+ this.writeUInt8(value.local);
199
+ this.writeUInt16(value.clusterId);
200
+ this.writeUInt8(value.remote);
201
+ this.writeIeeeAddr(value.identifier);
202
+ this.writeUInt8(value.networkIndex);
203
+ }
204
+ readEmberBindingTableEntry() {
205
+ const type = this.readUInt8();
206
+ const local = this.readUInt8();
207
+ const clusterId = this.readUInt16();
208
+ const remote = this.readUInt8();
209
+ const identifier = this.readIeeeAddr();
210
+ const networkIndex = this.readUInt8();
211
+ return {
212
+ type,
213
+ local,
214
+ clusterId,
215
+ remote,
216
+ identifier,
217
+ networkIndex,
218
+ };
219
+ }
220
+ writeEmberMulticastTableEntry(value) {
221
+ this.writeUInt16(value.multicastId);
222
+ this.writeUInt8(value.endpoint);
223
+ this.writeUInt8(value.networkIndex);
224
+ }
225
+ readEmberMulticastTableEntry() {
226
+ const multicastId = this.readUInt16();
227
+ const endpoint = this.readUInt8();
228
+ // XXX: not in gecko_sdk? as workaround check length for now since used at end in just one place
229
+ const networkIndex = this.isMore() ? this.readUInt8() : 0x00;
230
+ return { multicastId, endpoint, networkIndex };
231
+ }
232
+ writeEmberBeaconClassificationParams(value) {
233
+ this.writeUInt8(value.minRssiForReceivingPkts);
234
+ this.writeUInt16(value.beaconClassificationMask);
235
+ }
236
+ readEmberBeaconClassificationParams() {
237
+ const minRssiForReceivingPkts = this.readUInt8(); // Int8...
238
+ const beaconClassificationMask = this.readUInt16();
239
+ return { minRssiForReceivingPkts, beaconClassificationMask };
240
+ }
241
+ writeEmberNeighborTableEntry(value) {
242
+ this.writeUInt16(value.shortId);
243
+ this.writeUInt8(value.averageLqi);
244
+ this.writeUInt8(value.inCost);
245
+ this.writeUInt8(value.outCost);
246
+ this.writeUInt8(value.age);
247
+ this.writeIeeeAddr(value.longId);
248
+ }
249
+ readEmberNeighborTableEntry() {
250
+ const shortId = this.readUInt16();
251
+ const averageLqi = this.readUInt8();
252
+ const inCost = this.readUInt8();
253
+ const outCost = this.readUInt8();
254
+ const age = this.readUInt8();
255
+ const longId = this.readIeeeAddr();
256
+ return {
257
+ shortId,
258
+ averageLqi,
259
+ inCost,
260
+ outCost,
261
+ age,
262
+ longId,
263
+ };
264
+ }
265
+ writeEmberRouteTableEntry(value) {
266
+ this.writeUInt16(value.destination);
267
+ this.writeUInt16(value.nextHop);
268
+ this.writeUInt8(value.status);
269
+ this.writeUInt8(value.age);
270
+ this.writeUInt8(value.concentratorType);
271
+ this.writeUInt8(value.routeRecordState);
272
+ }
273
+ readEmberRouteTableEntry() {
274
+ const destination = this.readUInt16();
275
+ const nextHop = this.readUInt16();
276
+ const status = this.readUInt8();
277
+ const age = this.readUInt8();
278
+ const concentratorType = this.readUInt8();
279
+ const routeRecordState = this.readUInt8();
280
+ return {
281
+ destination,
282
+ nextHop,
283
+ status,
284
+ age,
285
+ concentratorType,
286
+ routeRecordState,
287
+ };
288
+ }
289
+ writeEmberKeyData(value) {
290
+ this.writeBuffer(value.contents, consts_2.EMBER_ENCRYPTION_KEY_SIZE);
291
+ }
292
+ readEmberKeyData() {
293
+ const contents = this.readBufferCopy(consts_2.EMBER_ENCRYPTION_KEY_SIZE);
294
+ return { contents };
295
+ }
296
+ writeSecManKey(value) {
297
+ this.writeEmberKeyData(value);
298
+ }
299
+ readSecManKey() {
300
+ return this.readEmberKeyData();
301
+ }
302
+ writeSecManContext(value) {
303
+ this.writeUInt8(value.coreKeyType);
304
+ this.writeUInt8(value.keyIndex);
305
+ this.writeUInt16(value.derivedType);
306
+ this.writeIeeeAddr(value.eui64);
307
+ this.writeUInt8(value.multiNetworkIndex);
308
+ this.writeUInt8(value.flags);
309
+ this.writeUInt32(value.psaKeyAlgPermission);
310
+ }
311
+ readSecManContext() {
312
+ const core_key_type = this.readUInt8();
313
+ const key_index = this.readUInt8();
314
+ const derived_type = this.readUInt16();
315
+ const eui64 = this.readIeeeAddr();
316
+ const multi_network_index = this.readUInt8();
317
+ const flags = this.readUInt8();
318
+ const psa_key_alg_permission = this.readUInt32();
319
+ return {
320
+ coreKeyType: core_key_type,
321
+ keyIndex: key_index,
322
+ derivedType: derived_type,
323
+ eui64,
324
+ multiNetworkIndex: multi_network_index,
325
+ flags,
326
+ psaKeyAlgPermission: psa_key_alg_permission,
327
+ };
328
+ }
329
+ writeSecManNetworkKeyInfo(value) {
330
+ this.writeUInt8(value.networkKeySet ? 1 : 0);
331
+ this.writeUInt8(value.alternateNetworkKeySet ? 1 : 0);
332
+ this.writeUInt8(value.networkKeySequenceNumber);
333
+ this.writeUInt8(value.altNetworkKeySequenceNumber);
334
+ this.writeUInt32(value.networkKeyFrameCounter);
335
+ }
336
+ readSecManNetworkKeyInfo() {
337
+ const networkKeySet = this.readUInt8() === 1 ? true : false;
338
+ const alternateNetworkKeySet = this.readUInt8() === 1 ? true : false;
339
+ const networkKeySequenceNumber = this.readUInt8();
340
+ const altNetworkKeySequenceNumber = this.readUInt8();
341
+ const networkKeyFrameCounter = this.readUInt32();
342
+ return {
343
+ networkKeySet: networkKeySet,
344
+ alternateNetworkKeySet: alternateNetworkKeySet,
345
+ networkKeySequenceNumber: networkKeySequenceNumber,
346
+ altNetworkKeySequenceNumber: altNetworkKeySequenceNumber,
347
+ networkKeyFrameCounter: networkKeyFrameCounter,
348
+ };
349
+ }
350
+ writeSecManAPSKeyMetadata(value) {
351
+ this.writeUInt16(value.bitmask);
352
+ this.writeUInt32(value.outgoingFrameCounter);
353
+ this.writeUInt32(value.incomingFrameCounter);
354
+ this.writeUInt16(value.ttlInSeconds);
355
+ }
356
+ readSecManAPSKeyMetadata() {
357
+ const bitmask = this.readUInt16();
358
+ const outgoing_frame_counter = this.readUInt32();
359
+ const incoming_frame_counter = this.readUInt32();
360
+ const ttl_in_seconds = this.readUInt16();
361
+ return {
362
+ bitmask,
363
+ outgoingFrameCounter: outgoing_frame_counter,
364
+ incomingFrameCounter: incoming_frame_counter,
365
+ ttlInSeconds: ttl_in_seconds,
366
+ };
367
+ }
368
+ writeEmberTransientKeyData(value) {
369
+ this.writeIeeeAddr(value.eui64);
370
+ this.writeEmberKeyData(value.keyData);
371
+ this.writeUInt32(value.incomingFrameCounter);
372
+ this.writeUInt16(value.bitmask);
373
+ this.writeUInt16(value.remainingTimeSeconds);
374
+ this.writeUInt8(value.networkIndex);
375
+ }
376
+ readEmberTransientKeyData() {
377
+ const eui64 = this.readIeeeAddr();
378
+ const keyData = this.readEmberKeyData();
379
+ const incomingFrameCounter = this.readUInt32();
380
+ const bitmask = this.readUInt16();
381
+ const remainingTimeSeconds = this.readUInt16();
382
+ const networkIndex = this.readUInt8();
383
+ return {
384
+ eui64,
385
+ keyData,
386
+ incomingFrameCounter,
387
+ bitmask,
388
+ remainingTimeSeconds,
389
+ networkIndex,
390
+ };
391
+ }
392
+ writeEmberInitialSecurityState(value) {
393
+ this.writeUInt16(value.bitmask);
394
+ this.writeEmberKeyData(value.preconfiguredKey);
395
+ this.writeEmberKeyData(value.networkKey);
396
+ this.writeUInt8(value.networkKeySequenceNumber);
397
+ this.writeIeeeAddr(value.preconfiguredTrustCenterEui64);
398
+ }
399
+ readEmberInitialSecurityState() {
400
+ const bitmask = this.readUInt16();
401
+ const preconfiguredKey = this.readEmberKeyData();
402
+ const networkKey = this.readEmberKeyData();
403
+ const networkKeySequenceNumber = this.readUInt8();
404
+ const preconfiguredTrustCenterEui64 = this.readIeeeAddr();
405
+ return {
406
+ bitmask,
407
+ preconfiguredKey,
408
+ networkKey,
409
+ networkKeySequenceNumber,
410
+ preconfiguredTrustCenterEui64,
411
+ };
412
+ }
413
+ writeEmberCurrentSecurityState(value) {
414
+ this.writeUInt16(value.bitmask);
415
+ this.writeIeeeAddr(value.trustCenterLongAddress);
416
+ }
417
+ readEmberCurrentSecurityState() {
418
+ const bitmask = this.readUInt16();
419
+ const trustCenterLongAddress = this.readIeeeAddr();
420
+ return { bitmask, trustCenterLongAddress };
421
+ }
422
+ writeEmberChildData(value) {
423
+ this.writeIeeeAddr(value.eui64);
424
+ this.writeUInt8(value.type);
425
+ this.writeUInt16(value.id);
426
+ this.writeUInt8(value.phy);
427
+ this.writeUInt8(value.power);
428
+ this.writeUInt8(value.timeout);
429
+ this.writeUInt32(value.remainingTimeout);
430
+ }
431
+ readEmberChildData() {
432
+ const eui64 = this.readIeeeAddr();
433
+ const type = this.readUInt8();
434
+ const id = this.readUInt16();
435
+ const phy = this.readUInt8();
436
+ const power = this.readUInt8();
437
+ const timeout = this.readUInt8();
438
+ const remainingTimeout = this.readUInt32();
439
+ return {
440
+ eui64,
441
+ type,
442
+ id,
443
+ phy,
444
+ power,
445
+ timeout,
446
+ remainingTimeout,
447
+ };
448
+ }
449
+ readEmberZigbeeNetwork() {
450
+ const channel = this.readUInt8();
451
+ const panId = this.readUInt16();
452
+ const extendedPanId = this.readListUInt8({ length: consts_2.EXTENDED_PAN_ID_SIZE });
453
+ const allowingJoin = this.readUInt8();
454
+ const stackProfile = this.readUInt8();
455
+ const nwkUpdateId = this.readUInt8();
456
+ return {
457
+ channel,
458
+ panId,
459
+ extendedPanId,
460
+ allowingJoin,
461
+ stackProfile,
462
+ nwkUpdateId,
463
+ };
464
+ }
465
+ writeEmberZigbeeNetwork(value) {
466
+ this.writeUInt8(value.channel);
467
+ this.writeUInt16(value.panId);
468
+ this.writeListUInt8(value.extendedPanId);
469
+ this.writeUInt8(value.allowingJoin);
470
+ this.writeUInt8(value.stackProfile);
471
+ this.writeUInt8(value.nwkUpdateId);
472
+ }
473
+ writeEmberCertificateData(value) {
474
+ this.writeBuffer(value.contents, consts_2.EMBER_CERTIFICATE_SIZE);
475
+ }
476
+ readEmberCertificateData() {
477
+ const contents = this.readBufferCopy(consts_2.EMBER_CERTIFICATE_SIZE);
478
+ return { contents };
479
+ }
480
+ writeEmberPublicKeyData(value) {
481
+ this.writeBuffer(value.contents, consts_2.EMBER_PUBLIC_KEY_SIZE);
482
+ }
483
+ readEmberPublicKeyData() {
484
+ const contents = this.readBufferCopy(consts_2.EMBER_PUBLIC_KEY_SIZE);
485
+ return { contents };
486
+ }
487
+ writeEmberPrivateKeyData(value) {
488
+ this.writeBuffer(value.contents, consts_2.EMBER_PRIVATE_KEY_SIZE);
489
+ }
490
+ readEmberPrivateKeyData() {
491
+ const contents = this.readBufferCopy(consts_2.EMBER_PRIVATE_KEY_SIZE);
492
+ return { contents };
493
+ }
494
+ writeEmberSmacData(value) {
495
+ this.writeBuffer(value.contents, consts_2.EMBER_SMAC_SIZE);
496
+ }
497
+ readEmberSmacData() {
498
+ const contents = this.readBufferCopy(consts_2.EMBER_SMAC_SIZE);
499
+ return { contents };
500
+ }
501
+ writeEmberSignatureData(value) {
502
+ this.writeBuffer(value.contents, consts_2.EMBER_SIGNATURE_SIZE);
503
+ }
504
+ readEmberSignatureData() {
505
+ const contents = this.readBufferCopy(consts_2.EMBER_SIGNATURE_SIZE);
506
+ return { contents };
507
+ }
508
+ writeEmberCertificate283k1Data(value) {
509
+ this.writeBuffer(value.contents, consts_2.EMBER_CERTIFICATE_283K1_SIZE);
510
+ }
511
+ readEmberCertificate283k1Data() {
512
+ const contents = this.readBufferCopy(consts_2.EMBER_CERTIFICATE_283K1_SIZE);
513
+ return { contents };
514
+ }
515
+ writeEmberPublicKey283k1Data(value) {
516
+ this.writeBuffer(value.contents, consts_2.EMBER_PUBLIC_KEY_283K1_SIZE);
517
+ }
518
+ readEmberPublicKey283k1Data() {
519
+ const contents = this.readBufferCopy(consts_2.EMBER_PUBLIC_KEY_283K1_SIZE);
520
+ return { contents };
521
+ }
522
+ writeEmberPrivateKey283k1Data(value) {
523
+ this.writeBuffer(value.contents, consts_2.EMBER_PRIVATE_KEY_283K1_SIZE);
524
+ }
525
+ readEmberPrivateKey283k1Data() {
526
+ const contents = this.readBufferCopy(consts_2.EMBER_PRIVATE_KEY_283K1_SIZE);
527
+ return { contents };
528
+ }
529
+ writeEmberSignature283k1Data(value) {
530
+ this.writeBuffer(value.contents, consts_2.EMBER_SIGNATURE_283K1_SIZE);
531
+ }
532
+ readEmberSignature283k1Data() {
533
+ const contents = this.readBufferCopy(consts_2.EMBER_SIGNATURE_283K1_SIZE);
534
+ return { contents };
535
+ }
536
+ writeEmberAesMmoHashContext(context) {
537
+ this.writeBuffer(context.result, consts_2.EMBER_AES_HASH_BLOCK_SIZE);
538
+ this.writeUInt32(context.length);
539
+ }
540
+ readEmberAesMmoHashContext() {
541
+ const result = this.readBufferCopy(consts_2.EMBER_AES_HASH_BLOCK_SIZE);
542
+ const length = this.readUInt32();
543
+ return { result, length };
544
+ }
545
+ writeEmberMessageDigest(value) {
546
+ this.writeBuffer(value.contents, consts_2.EMBER_AES_HASH_BLOCK_SIZE);
547
+ }
548
+ readEmberMessageDigest() {
549
+ const contents = this.readBufferCopy(consts_2.EMBER_AES_HASH_BLOCK_SIZE);
550
+ return { contents };
551
+ }
552
+ writeEmberNetworkInitStruct(networkInitStruct) {
553
+ this.writeUInt16(networkInitStruct.bitmask);
554
+ }
555
+ readEmberNetworkInitStruct() {
556
+ const bitmask = this.readUInt16();
557
+ return { bitmask };
558
+ }
559
+ writeEmberZllNetwork(network) {
560
+ this.writeEmberZigbeeNetwork(network.zigbeeNetwork);
561
+ this.writeEmberZllSecurityAlgorithmData(network.securityAlgorithm);
562
+ this.writeIeeeAddr(network.eui64);
563
+ this.writeUInt16(network.nodeId);
564
+ this.writeUInt16(network.state);
565
+ this.writeUInt8(network.nodeType);
566
+ this.writeUInt8(network.numberSubDevices);
567
+ this.writeUInt8(network.totalGroupIdentifiers);
568
+ this.writeUInt8(network.rssiCorrection);
569
+ }
570
+ readEmberZllNetwork() {
571
+ const zigbeeNetwork = this.readEmberZigbeeNetwork();
572
+ const securityAlgorithm = this.readEmberZllSecurityAlgorithmData();
573
+ const eui64 = this.readIeeeAddr();
574
+ const nodeId = this.readUInt16();
575
+ const state = this.readUInt16();
576
+ const nodeType = this.readUInt8();
577
+ const numberSubDevices = this.readUInt8();
578
+ const totalGroupIdentifiers = this.readUInt8();
579
+ const rssiCorrection = this.readUInt8();
580
+ return {
581
+ zigbeeNetwork,
582
+ securityAlgorithm,
583
+ eui64,
584
+ nodeId,
585
+ state,
586
+ nodeType,
587
+ numberSubDevices,
588
+ totalGroupIdentifiers,
589
+ rssiCorrection,
590
+ };
591
+ }
592
+ writeEmberZllSecurityAlgorithmData(data) {
593
+ this.writeUInt32(data.transactionId);
594
+ this.writeUInt32(data.responseId);
595
+ this.writeUInt16(data.bitmask);
596
+ }
597
+ readEmberZllSecurityAlgorithmData() {
598
+ const transactionId = this.readUInt32();
599
+ const responseId = this.readUInt32();
600
+ const bitmask = this.readUInt16();
601
+ return { transactionId, responseId, bitmask };
602
+ }
603
+ writeEmberZllInitialSecurityState(state) {
604
+ this.writeUInt32(state.bitmask);
605
+ this.writeUInt8(state.keyIndex);
606
+ this.writeEmberKeyData(state.encryptionKey);
607
+ this.writeEmberKeyData(state.preconfiguredKey);
608
+ }
609
+ writeEmberTokTypeStackZllData(data) {
610
+ this.writeUInt32(data.bitmask);
611
+ this.writeUInt16(data.freeNodeIdMin);
612
+ this.writeUInt16(data.freeNodeIdMax);
613
+ this.writeUInt16(data.myGroupIdMin);
614
+ this.writeUInt16(data.freeGroupIdMin);
615
+ this.writeUInt16(data.freeGroupIdMax);
616
+ this.writeUInt8(data.rssiCorrection);
617
+ }
618
+ readEmberTokTypeStackZllData() {
619
+ const bitmask = this.readUInt32();
620
+ const freeNodeIdMin = this.readUInt16();
621
+ const freeNodeIdMax = this.readUInt16();
622
+ const myGroupIdMin = this.readUInt16();
623
+ const freeGroupIdMin = this.readUInt16();
624
+ const freeGroupIdMax = this.readUInt16();
625
+ const rssiCorrection = this.readUInt8();
626
+ return {
627
+ bitmask,
628
+ freeNodeIdMin,
629
+ freeNodeIdMax,
630
+ myGroupIdMin,
631
+ freeGroupIdMin,
632
+ freeGroupIdMax,
633
+ rssiCorrection,
634
+ };
635
+ }
636
+ writeEmberTokTypeStackZllSecurity(security) {
637
+ this.writeUInt32(security.bitmask);
638
+ this.writeUInt8(security.keyIndex);
639
+ this.writeBuffer(security.encryptionKey, consts_2.EMBER_ENCRYPTION_KEY_SIZE);
640
+ this.writeBuffer(security.preconfiguredKey, consts_2.EMBER_ENCRYPTION_KEY_SIZE);
641
+ }
642
+ readEmberTokTypeStackZllSecurity() {
643
+ const bitmask = this.readUInt32();
644
+ const keyIndex = this.readUInt8();
645
+ const encryptionKey = this.readBufferCopy(consts_2.EMBER_ENCRYPTION_KEY_SIZE);
646
+ const preconfiguredKey = this.readBufferCopy(consts_2.EMBER_ENCRYPTION_KEY_SIZE);
647
+ return {
648
+ bitmask,
649
+ keyIndex,
650
+ encryptionKey,
651
+ preconfiguredKey,
652
+ };
653
+ }
654
+ writeEmberGpAddress(value) {
655
+ this.writeUInt8(value.applicationId);
656
+ if (value.applicationId === enums_1.EmberGpApplicationId.SOURCE_ID) {
657
+ this.writeUInt32(value.sourceId);
658
+ this.writeUInt32(value.sourceId); // filler
659
+ }
660
+ else if (value.applicationId === enums_1.EmberGpApplicationId.IEEE_ADDRESS) {
661
+ this.writeIeeeAddr(value.gpdIeeeAddress);
662
+ }
663
+ this.writeUInt8(value.endpoint);
664
+ }
665
+ readEmberGpAddress() {
666
+ const applicationId = this.readUInt8();
667
+ if (applicationId === enums_1.EmberGpApplicationId.SOURCE_ID) {
668
+ const sourceId = this.readUInt32();
669
+ this.readUInt32(); // filler
670
+ const endpoint = this.readUInt8();
671
+ return { applicationId, sourceId, endpoint };
672
+ }
673
+ else if (applicationId === enums_1.EmberGpApplicationId.IEEE_ADDRESS) {
674
+ const gpdIeeeAddress = this.readIeeeAddr();
675
+ const endpoint = this.readUInt8();
676
+ return { applicationId, gpdIeeeAddress, endpoint };
677
+ }
678
+ return null;
679
+ }
680
+ readEmberGpSinkList() {
681
+ const list = [];
682
+ for (let i = 0; i < consts_1.GP_SINK_LIST_ENTRIES; i++) {
683
+ const type = this.readUInt8();
684
+ switch (type) {
685
+ case enums_1.EmberGpSinkType.FULL_UNICAST:
686
+ case enums_1.EmberGpSinkType.LW_UNICAST:
687
+ case enums_1.EmberGpSinkType.UNUSED:
688
+ default:
689
+ const sinkNodeId = this.readUInt16();
690
+ const sinkEUI = this.readIeeeAddr();
691
+ list.push({
692
+ type,
693
+ unicast: {
694
+ sinkNodeId,
695
+ sinkEUI,
696
+ }
697
+ });
698
+ break;
699
+ case enums_1.EmberGpSinkType.D_GROUPCAST:
700
+ case enums_1.EmberGpSinkType.GROUPCAST:
701
+ const alias = this.readUInt16();
702
+ const groupID = this.readUInt16();
703
+ // fillers
704
+ this.readUInt16();
705
+ this.readUInt16();
706
+ this.readUInt16();
707
+ list.push({
708
+ type,
709
+ groupcast: {
710
+ alias,
711
+ groupID,
712
+ }
713
+ });
714
+ break;
715
+ }
716
+ }
717
+ return list;
718
+ }
719
+ writeEmberGpSinkList(value) {
720
+ for (let i = 0; i < consts_1.GP_SINK_LIST_ENTRIES; i++) {
721
+ this.writeUInt8(value[i].type);
722
+ switch (value[i].type) {
723
+ case enums_1.EmberGpSinkType.FULL_UNICAST:
724
+ case enums_1.EmberGpSinkType.LW_UNICAST:
725
+ case enums_1.EmberGpSinkType.UNUSED:
726
+ default:
727
+ this.writeUInt16(value[i].unicast.sinkNodeId);
728
+ this.writeIeeeAddr(value[i].unicast.sinkEUI); // changed 8 to const var
729
+ break;
730
+ case enums_1.EmberGpSinkType.D_GROUPCAST:
731
+ case enums_1.EmberGpSinkType.GROUPCAST:
732
+ this.writeUInt16(value[i].groupcast.alias);
733
+ this.writeUInt16(value[i].groupcast.groupID);
734
+ //fillers
735
+ this.writeUInt16(value[i].groupcast.alias);
736
+ this.writeUInt16(value[i].groupcast.groupID);
737
+ this.writeUInt16(value[i].groupcast.alias);
738
+ break;
739
+ }
740
+ }
741
+ }
742
+ readEmberGpProxyTableEntry() {
743
+ const status = this.readUInt8();
744
+ const options = this.readUInt32();
745
+ const gpd = this.readEmberGpAddress();
746
+ const assignedAlias = this.readUInt16();
747
+ const securityOptions = this.readUInt8();
748
+ const gpdSecurityFrameCounter = this.readUInt32();
749
+ const gpdKey = this.readEmberKeyData();
750
+ const sinkList = this.readEmberGpSinkList();
751
+ const groupcastRadius = this.readUInt8();
752
+ const searchCounter = this.readUInt8();
753
+ return {
754
+ status,
755
+ options,
756
+ gpd,
757
+ assignedAlias,
758
+ securityOptions,
759
+ gpdSecurityFrameCounter,
760
+ gpdKey,
761
+ sinkList,
762
+ groupcastRadius,
763
+ searchCounter,
764
+ };
765
+ }
766
+ writeEmberGpProxyTableEntry(value) {
767
+ this.writeUInt8(value.status);
768
+ this.writeUInt32(value.options);
769
+ this.writeEmberGpAddress(value.gpd);
770
+ this.writeUInt16(value.assignedAlias);
771
+ this.writeUInt8(value.securityOptions);
772
+ this.writeUInt32(value.gpdSecurityFrameCounter);
773
+ this.writeEmberKeyData(value.gpdKey);
774
+ this.writeEmberGpSinkList(value.sinkList);
775
+ this.writeUInt8(value.groupcastRadius);
776
+ this.writeUInt8(value.searchCounter);
777
+ }
778
+ readEmberGpSinkTableEntry() {
779
+ const status = this.readUInt8();
780
+ const options = this.readUInt16();
781
+ const gpd = this.readEmberGpAddress();
782
+ const deviceId = this.readUInt8();
783
+ const sinkList = this.readEmberGpSinkList();
784
+ const assignedAlias = this.readUInt16();
785
+ const groupcastRadius = this.readUInt8();
786
+ const securityOptions = this.readUInt8();
787
+ const gpdSecurityFrameCounter = this.readUInt32();
788
+ const gpdKey = this.readEmberKeyData();
789
+ return {
790
+ status,
791
+ options,
792
+ gpd,
793
+ deviceId,
794
+ sinkList,
795
+ assignedAlias,
796
+ groupcastRadius,
797
+ securityOptions,
798
+ gpdSecurityFrameCounter,
799
+ gpdKey,
800
+ };
801
+ }
802
+ writeEmberGpSinkTableEntry(value) {
803
+ this.writeUInt8(value.status);
804
+ this.writeUInt16(value.options);
805
+ this.writeEmberGpAddress(value.gpd);
806
+ this.writeUInt8(value.deviceId);
807
+ this.writeEmberGpSinkList(value.sinkList);
808
+ this.writeUInt16(value.assignedAlias);
809
+ this.writeUInt8(value.groupcastRadius);
810
+ this.writeUInt8(value.securityOptions);
811
+ this.writeUInt32(value.gpdSecurityFrameCounter);
812
+ this.writeEmberKeyData(value.gpdKey);
813
+ }
814
+ writeEmberDutyCycleLimits(limits) {
815
+ this.writeUInt16(limits.limitThresh);
816
+ this.writeUInt16(limits.critThresh);
817
+ this.writeUInt16(limits.suspLimit);
818
+ }
819
+ readEmberDutyCycleLimits() {
820
+ const limitThresh = this.readUInt16();
821
+ const critThresh = this.readUInt16();
822
+ const suspLimit = this.readUInt16();
823
+ return {
824
+ limitThresh,
825
+ critThresh,
826
+ suspLimit,
827
+ };
828
+ }
829
+ writeEmberPerDeviceDutyCycle(maxDevices, arrayOfDeviceDutyCycles) {
830
+ this.writeUInt16(maxDevices);
831
+ for (let i = 0; i < maxDevices; i++) {
832
+ this.writeUInt16(arrayOfDeviceDutyCycles[i].nodeId);
833
+ this.writeUInt16(arrayOfDeviceDutyCycles[i].dutyCycleConsumed);
834
+ }
835
+ }
836
+ readEmberPerDeviceDutyCycle() {
837
+ const maxDevices = this.readUInt8();
838
+ const arrayOfDeviceDutyCycles = [];
839
+ for (let i = 0; i < maxDevices; i++) {
840
+ const nodeId = this.readUInt16();
841
+ const dutyCycleConsumed = this.readUInt16();
842
+ arrayOfDeviceDutyCycles.push({ nodeId, dutyCycleConsumed });
843
+ }
844
+ return arrayOfDeviceDutyCycles;
845
+ }
846
+ readEmberZllDeviceInfoRecord() {
847
+ const ieeeAddress = this.readIeeeAddr();
848
+ const endpointId = this.readUInt8();
849
+ const profileId = this.readUInt16();
850
+ const deviceId = this.readUInt16();
851
+ const version = this.readUInt8();
852
+ const groupIdCount = this.readUInt8();
853
+ return {
854
+ ieeeAddress,
855
+ endpointId,
856
+ profileId,
857
+ deviceId,
858
+ version,
859
+ groupIdCount,
860
+ };
861
+ }
862
+ readEmberZllInitialSecurityState() {
863
+ const bitmask = this.readUInt32();
864
+ const keyIndex = this.readUInt8();
865
+ const encryptionKey = this.readEmberKeyData();
866
+ const preconfiguredKey = this.readEmberKeyData();
867
+ return {
868
+ bitmask,
869
+ keyIndex,
870
+ encryptionKey,
871
+ preconfiguredKey,
872
+ };
873
+ }
874
+ readEmberZllAddressAssignment() {
875
+ const nodeId = this.readUInt16();
876
+ const freeNodeIdMin = this.readUInt16();
877
+ const freeNodeIdMax = this.readUInt16();
878
+ const groupIdMin = this.readUInt16();
879
+ const groupIdMax = this.readUInt16();
880
+ const freeGroupIdMin = this.readUInt16();
881
+ const freeGroupIdMax = this.readUInt16();
882
+ return {
883
+ nodeId,
884
+ freeNodeIdMin,
885
+ freeNodeIdMax,
886
+ groupIdMin,
887
+ groupIdMax,
888
+ freeGroupIdMin,
889
+ freeGroupIdMax,
890
+ };
891
+ }
892
+ writeEmberBeaconIterator(value) {
893
+ this.writeUInt8(value.beacon.channel);
894
+ this.writeUInt8(value.beacon.lqi);
895
+ this.writeUInt8(value.beacon.rssi);
896
+ this.writeUInt8(value.beacon.depth);
897
+ this.writeUInt8(value.beacon.nwkUpdateId);
898
+ this.writeUInt8(value.beacon.power);
899
+ this.writeUInt8(value.beacon.parentPriority);
900
+ this.writeUInt8(value.beacon.enhanced ? 1 : 0);
901
+ this.writeUInt8(value.beacon.permitJoin ? 1 : 0);
902
+ this.writeUInt8(value.beacon.hasCapacity ? 1 : 0);
903
+ this.writeUInt16(value.beacon.panId);
904
+ this.writeUInt16(value.beacon.sender);
905
+ this.writeListUInt8(value.beacon.extendedPanId);
906
+ this.writeUInt8(value.index);
907
+ }
908
+ readEmberBeaconIterator() {
909
+ const channel = this.readUInt8();
910
+ const lqi = this.readUInt8();
911
+ const rssi = this.readUInt8();
912
+ const depth = this.readUInt8();
913
+ const nwkUpdateId = this.readUInt8();
914
+ const power = this.readUInt8();
915
+ const parentPriority = this.readUInt8();
916
+ const enhanced = this.readUInt8() === 1 ? true : false;
917
+ const permitJoin = this.readUInt8() === 1 ? true : false;
918
+ const hasCapacity = this.readUInt8() === 1 ? true : false;
919
+ const panId = this.readUInt16();
920
+ const sender = this.readUInt16();
921
+ const extendedPanId = this.readListUInt8({ length: consts_2.EXTENDED_PAN_ID_SIZE });
922
+ const index = this.readUInt8();
923
+ return {
924
+ beacon: {
925
+ channel,
926
+ lqi,
927
+ rssi,
928
+ depth,
929
+ nwkUpdateId,
930
+ power,
931
+ parentPriority,
932
+ enhanced,
933
+ permitJoin,
934
+ hasCapacity,
935
+ panId,
936
+ sender,
937
+ extendedPanId,
938
+ supportedKeyNegotiationMethods: 0,
939
+ extended_beacon: false,
940
+ tcConnectivity: true,
941
+ longUptime: true,
942
+ preferParent: true,
943
+ macDataPollKeepalive: true,
944
+ endDeviceKeepalive: true
945
+ },
946
+ index,
947
+ };
948
+ }
949
+ writeEmberBeaconData(value) {
950
+ this.writeUInt8(value.channel);
951
+ this.writeUInt8(value.lqi);
952
+ this.writeUInt8(value.rssi);
953
+ this.writeUInt8(value.depth);
954
+ this.writeUInt8(value.nwkUpdateId);
955
+ this.writeUInt8(value.power);
956
+ this.writeUInt8(value.parentPriority);
957
+ this.writeUInt8(value.enhanced ? 1 : 0);
958
+ this.writeUInt8(value.permitJoin ? 1 : 0);
959
+ this.writeUInt8(value.hasCapacity ? 1 : 0);
960
+ this.writeUInt16(value.panId);
961
+ this.writeUInt16(value.sender);
962
+ this.writeListUInt8(value.extendedPanId);
963
+ }
964
+ readEmberBeaconData() {
965
+ const channel = this.readUInt8();
966
+ const lqi = this.readUInt8();
967
+ const rssi = this.readUInt8();
968
+ const depth = this.readUInt8();
969
+ const nwkUpdateId = this.readUInt8();
970
+ const power = this.readUInt8();
971
+ const parentPriority = this.readUInt8();
972
+ const enhanced = this.readUInt8() === 1 ? true : false;
973
+ const permitJoin = this.readUInt8() === 1 ? true : false;
974
+ const hasCapacity = this.readUInt8() === 1 ? true : false;
975
+ const panId = this.readUInt16();
976
+ const sender = this.readUInt16();
977
+ const extendedPanId = this.readListUInt8({ length: consts_2.EXTENDED_PAN_ID_SIZE });
978
+ return {
979
+ channel,
980
+ lqi,
981
+ rssi,
982
+ depth,
983
+ nwkUpdateId,
984
+ power,
985
+ parentPriority,
986
+ enhanced,
987
+ permitJoin,
988
+ hasCapacity,
989
+ panId,
990
+ sender,
991
+ extendedPanId,
992
+ supportedKeyNegotiationMethods: 0,
993
+ extended_beacon: false,
994
+ tcConnectivity: true,
995
+ longUptime: true,
996
+ preferParent: true,
997
+ macDataPollKeepalive: true,
998
+ endDeviceKeepalive: true
999
+ };
1000
+ }
1001
+ writeEmberTokenData(tokenData) {
1002
+ this.writeUInt32(tokenData.size);
1003
+ this.writeBuffer(tokenData.data, tokenData.size);
1004
+ }
1005
+ readEmberTokenData() {
1006
+ const size = this.readUInt32();
1007
+ const data = this.readBufferCopy(size);
1008
+ return { size, data };
1009
+ }
1010
+ readEmberTokenInfo() {
1011
+ const nvm3Key = this.readUInt32();
1012
+ const isCnt = this.readUInt8() === 1 ? true : false;
1013
+ const isIdx = this.readUInt8() === 1 ? true : false;
1014
+ const size = this.readUInt8();
1015
+ const arraySize = this.readUInt8();
1016
+ return {
1017
+ nvm3Key,
1018
+ isCnt,
1019
+ isIdx,
1020
+ size,
1021
+ arraySize,
1022
+ };
1023
+ }
1024
+ writeEmberTokenInfo(tokenInfo) {
1025
+ this.writeUInt32(tokenInfo.nvm3Key);
1026
+ this.writeUInt8(tokenInfo.isCnt ? 1 : 0);
1027
+ this.writeUInt8(tokenInfo.isIdx ? 1 : 0);
1028
+ this.writeUInt8(tokenInfo.size);
1029
+ this.writeUInt8(tokenInfo.arraySize);
1030
+ }
1031
+ }
1032
+ exports.EzspBuffalo = EzspBuffalo;
1033
+ //# sourceMappingURL=buffalo.js.map