zigbee-herdsman 6.0.2 → 6.0.3
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/CHANGELOG.md +7 -0
- package/package.json +12 -3
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/dependabot.yml +0 -22
- package/.github/workflows/ci.yml +0 -69
- package/.github/workflows/release-please.yml +0 -18
- package/.github/workflows/stale.yml +0 -20
- package/.github/workflows/typedoc.yaml +0 -47
- package/.release-please-manifest.json +0 -3
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -11
- package/biome.json +0 -98
- package/examples/join-and-log.js +0 -24
- package/release-please-config.json +0 -9
- package/src/adapter/adapter.ts +0 -189
- package/src/adapter/adapterDiscovery.ts +0 -666
- package/src/adapter/const.ts +0 -12
- package/src/adapter/deconz/adapter/deconzAdapter.ts +0 -877
- package/src/adapter/deconz/driver/constants.ts +0 -246
- package/src/adapter/deconz/driver/driver.ts +0 -1540
- package/src/adapter/deconz/driver/frame.ts +0 -11
- package/src/adapter/deconz/driver/frameParser.ts +0 -753
- package/src/adapter/deconz/driver/parser.ts +0 -45
- package/src/adapter/deconz/driver/writer.ts +0 -22
- package/src/adapter/deconz/types.d.ts +0 -13
- package/src/adapter/ember/adapter/emberAdapter.ts +0 -2265
- package/src/adapter/ember/adapter/endpoints.ts +0 -86
- package/src/adapter/ember/adapter/oneWaitress.ts +0 -324
- package/src/adapter/ember/adapter/tokensManager.ts +0 -782
- package/src/adapter/ember/consts.ts +0 -178
- package/src/adapter/ember/enums.ts +0 -1746
- package/src/adapter/ember/ezsp/buffalo.ts +0 -1392
- package/src/adapter/ember/ezsp/consts.ts +0 -148
- package/src/adapter/ember/ezsp/enums.ts +0 -1114
- package/src/adapter/ember/ezsp/ezsp.ts +0 -9061
- package/src/adapter/ember/ezspError.ts +0 -10
- package/src/adapter/ember/types.ts +0 -866
- package/src/adapter/ember/uart/ash.ts +0 -1960
- package/src/adapter/ember/uart/consts.ts +0 -109
- package/src/adapter/ember/uart/enums.ts +0 -192
- package/src/adapter/ember/uart/parser.ts +0 -48
- package/src/adapter/ember/uart/queues.ts +0 -247
- package/src/adapter/ember/uart/writer.ts +0 -53
- package/src/adapter/ember/utils/initters.ts +0 -58
- package/src/adapter/ember/utils/math.ts +0 -73
- package/src/adapter/events.ts +0 -21
- package/src/adapter/ezsp/adapter/backup.ts +0 -109
- package/src/adapter/ezsp/adapter/ezspAdapter.ts +0 -614
- package/src/adapter/ezsp/driver/commands.ts +0 -2497
- package/src/adapter/ezsp/driver/consts.ts +0 -11
- package/src/adapter/ezsp/driver/driver.ts +0 -1002
- package/src/adapter/ezsp/driver/ezsp.ts +0 -802
- package/src/adapter/ezsp/driver/frame.ts +0 -101
- package/src/adapter/ezsp/driver/index.ts +0 -4
- package/src/adapter/ezsp/driver/multicast.ts +0 -78
- package/src/adapter/ezsp/driver/parser.ts +0 -81
- package/src/adapter/ezsp/driver/types/basic.ts +0 -201
- package/src/adapter/ezsp/driver/types/index.ts +0 -239
- package/src/adapter/ezsp/driver/types/named.ts +0 -2330
- package/src/adapter/ezsp/driver/types/struct.ts +0 -844
- package/src/adapter/ezsp/driver/uart.ts +0 -460
- package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +0 -44
- package/src/adapter/ezsp/driver/utils/index.ts +0 -32
- package/src/adapter/ezsp/driver/writer.ts +0 -64
- package/src/adapter/index.ts +0 -3
- package/src/adapter/serialPort.ts +0 -58
- package/src/adapter/socketPortUtils.ts +0 -16
- package/src/adapter/tstype.ts +0 -78
- package/src/adapter/z-stack/adapter/adapter-backup.ts +0 -519
- package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +0 -457
- package/src/adapter/z-stack/adapter/endpoints.ts +0 -57
- package/src/adapter/z-stack/adapter/manager.ts +0 -543
- package/src/adapter/z-stack/adapter/tstype.ts +0 -6
- package/src/adapter/z-stack/adapter/zStackAdapter.ts +0 -1190
- package/src/adapter/z-stack/constants/af.ts +0 -27
- package/src/adapter/z-stack/constants/common.ts +0 -285
- package/src/adapter/z-stack/constants/dbg.ts +0 -23
- package/src/adapter/z-stack/constants/index.ts +0 -11
- package/src/adapter/z-stack/constants/mac.ts +0 -128
- package/src/adapter/z-stack/constants/sapi.ts +0 -25
- package/src/adapter/z-stack/constants/sys.ts +0 -72
- package/src/adapter/z-stack/constants/util.ts +0 -82
- package/src/adapter/z-stack/constants/utils.ts +0 -14
- package/src/adapter/z-stack/constants/zdo.ts +0 -103
- package/src/adapter/z-stack/models/startup-options.ts +0 -13
- package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +0 -44
- package/src/adapter/z-stack/structs/entries/address-manager-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +0 -12
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/channel-list.ts +0 -8
- package/src/adapter/z-stack/structs/entries/has-configured.ts +0 -16
- package/src/adapter/z-stack/structs/entries/index.ts +0 -16
- package/src/adapter/z-stack/structs/entries/nib.ts +0 -66
- package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +0 -15
- package/src/adapter/z-stack/structs/entries/nwk-key.ts +0 -13
- package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +0 -8
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +0 -20
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +0 -33
- package/src/adapter/z-stack/structs/entries/security-manager-table.ts +0 -22
- package/src/adapter/z-stack/structs/index.ts +0 -4
- package/src/adapter/z-stack/structs/serializable-memory-object.ts +0 -14
- package/src/adapter/z-stack/structs/struct.ts +0 -367
- package/src/adapter/z-stack/structs/table.ts +0 -198
- package/src/adapter/z-stack/unpi/constants.ts +0 -33
- package/src/adapter/z-stack/unpi/frame.ts +0 -62
- package/src/adapter/z-stack/unpi/index.ts +0 -4
- package/src/adapter/z-stack/unpi/parser.ts +0 -56
- package/src/adapter/z-stack/unpi/writer.ts +0 -21
- package/src/adapter/z-stack/utils/channel-list.ts +0 -40
- package/src/adapter/z-stack/utils/index.ts +0 -2
- package/src/adapter/z-stack/utils/network-options.ts +0 -26
- package/src/adapter/z-stack/znp/buffaloZnp.ts +0 -175
- package/src/adapter/z-stack/znp/definition.ts +0 -2713
- package/src/adapter/z-stack/znp/index.ts +0 -2
- package/src/adapter/z-stack/znp/parameterType.ts +0 -22
- package/src/adapter/z-stack/znp/tstype.ts +0 -44
- package/src/adapter/z-stack/znp/utils.ts +0 -10
- package/src/adapter/z-stack/znp/znp.ts +0 -342
- package/src/adapter/z-stack/znp/zpiObject.ts +0 -148
- package/src/adapter/zboss/adapter/zbossAdapter.ts +0 -526
- package/src/adapter/zboss/commands.ts +0 -1184
- package/src/adapter/zboss/consts.ts +0 -9
- package/src/adapter/zboss/driver.ts +0 -422
- package/src/adapter/zboss/enums.ts +0 -360
- package/src/adapter/zboss/frame.ts +0 -227
- package/src/adapter/zboss/reader.ts +0 -65
- package/src/adapter/zboss/types.ts +0 -0
- package/src/adapter/zboss/uart.ts +0 -428
- package/src/adapter/zboss/utils.ts +0 -58
- package/src/adapter/zboss/writer.ts +0 -49
- package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +0 -27
- package/src/adapter/zigate/adapter/zigateAdapter.ts +0 -618
- package/src/adapter/zigate/driver/LICENSE +0 -17
- package/src/adapter/zigate/driver/buffaloZiGate.ts +0 -212
- package/src/adapter/zigate/driver/commandType.ts +0 -418
- package/src/adapter/zigate/driver/constants.ts +0 -150
- package/src/adapter/zigate/driver/frame.ts +0 -197
- package/src/adapter/zigate/driver/messageType.ts +0 -287
- package/src/adapter/zigate/driver/parameterType.ts +0 -32
- package/src/adapter/zigate/driver/ziGateObject.ts +0 -146
- package/src/adapter/zigate/driver/zigate.ts +0 -423
- package/src/adapter/zoh/adapter/utils.ts +0 -27
- package/src/adapter/zoh/adapter/zohAdapter.ts +0 -838
- package/src/buffalo/buffalo.ts +0 -342
- package/src/buffalo/index.ts +0 -1
- package/src/controller/controller.ts +0 -1022
- package/src/controller/database.ts +0 -124
- package/src/controller/events.ts +0 -52
- package/src/controller/greenPower.ts +0 -603
- package/src/controller/helpers/index.ts +0 -1
- package/src/controller/helpers/installCodes.ts +0 -107
- package/src/controller/helpers/request.ts +0 -96
- package/src/controller/helpers/requestQueue.ts +0 -125
- package/src/controller/helpers/zclFrameConverter.ts +0 -47
- package/src/controller/helpers/zclTransactionSequenceNumber.ts +0 -19
- package/src/controller/index.ts +0 -6
- package/src/controller/model/device.ts +0 -1249
- package/src/controller/model/endpoint.ts +0 -1105
- package/src/controller/model/entity.ts +0 -23
- package/src/controller/model/group.ts +0 -424
- package/src/controller/model/index.ts +0 -5
- package/src/controller/model/zigbeeEntity.ts +0 -30
- package/src/controller/touchlink.ts +0 -189
- package/src/controller/tstype.ts +0 -274
- package/src/index.ts +0 -12
- package/src/models/backup-storage-legacy.ts +0 -48
- package/src/models/backup-storage-unified.ts +0 -47
- package/src/models/backup.ts +0 -37
- package/src/models/index.ts +0 -5
- package/src/models/network-options.ts +0 -11
- package/src/utils/backup.ts +0 -152
- package/src/utils/index.ts +0 -5
- package/src/utils/logger.ts +0 -20
- package/src/utils/patchBigIntSerialization.ts +0 -8
- package/src/utils/queue.ts +0 -76
- package/src/utils/types.d.ts +0 -3
- package/src/utils/utils.ts +0 -19
- package/src/utils/wait.ts +0 -5
- package/src/utils/waitress.ts +0 -96
- package/src/zspec/consts.ts +0 -84
- package/src/zspec/enums.ts +0 -22
- package/src/zspec/index.ts +0 -3
- package/src/zspec/tstypes.ts +0 -18
- package/src/zspec/utils.ts +0 -247
- package/src/zspec/zcl/buffaloZcl.ts +0 -1220
- package/src/zspec/zcl/definition/cluster.ts +0 -5915
- package/src/zspec/zcl/definition/clusters-typegen.ts +0 -588
- package/src/zspec/zcl/definition/clusters-types.ts +0 -7331
- package/src/zspec/zcl/definition/consts.ts +0 -24
- package/src/zspec/zcl/definition/enums.ts +0 -203
- package/src/zspec/zcl/definition/foundation.ts +0 -329
- package/src/zspec/zcl/definition/manufacturerCode.ts +0 -729
- package/src/zspec/zcl/definition/status.ts +0 -69
- package/src/zspec/zcl/definition/tstype.ts +0 -377
- package/src/zspec/zcl/index.ts +0 -11
- package/src/zspec/zcl/utils.ts +0 -321
- package/src/zspec/zcl/zclFrame.ts +0 -356
- package/src/zspec/zcl/zclHeader.ts +0 -102
- package/src/zspec/zcl/zclStatusError.ts +0 -10
- package/src/zspec/zdo/buffaloZdo.ts +0 -2336
- package/src/zspec/zdo/definition/clusters.ts +0 -722
- package/src/zspec/zdo/definition/consts.ts +0 -16
- package/src/zspec/zdo/definition/enums.ts +0 -99
- package/src/zspec/zdo/definition/status.ts +0 -105
- package/src/zspec/zdo/definition/tstypes.ts +0 -1062
- package/src/zspec/zdo/index.ts +0 -7
- package/src/zspec/zdo/utils.ts +0 -76
- package/src/zspec/zdo/zdoStatusError.ts +0 -10
- package/test/adapter/adapter.test.ts +0 -1062
- package/test/adapter/ember/ash.test.ts +0 -337
- package/test/adapter/ember/consts.ts +0 -131
- package/test/adapter/ember/emberAdapter.test.ts +0 -3449
- package/test/adapter/ember/ezsp.test.ts +0 -385
- package/test/adapter/ember/ezspBuffalo.test.ts +0 -93
- package/test/adapter/ember/ezspError.test.ts +0 -12
- package/test/adapter/ember/math.test.ts +0 -206
- package/test/adapter/ezsp/frame.test.ts +0 -30
- package/test/adapter/ezsp/uart.test.ts +0 -181
- package/test/adapter/z-stack/adapter.test.ts +0 -3984
- package/test/adapter/z-stack/constants.test.ts +0 -33
- package/test/adapter/z-stack/structs.test.ts +0 -115
- package/test/adapter/z-stack/unpi.test.ts +0 -213
- package/test/adapter/z-stack/znp.test.ts +0 -1284
- package/test/adapter/zboss/fixZdoResponse.test.ts +0 -179
- package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +0 -81
- package/test/adapter/zigate/zdo.test.ts +0 -187
- package/test/adapter/zoh/utils.test.ts +0 -36
- package/test/adapter/zoh/zohAdapter.test.ts +0 -1307
- package/test/benchOptions.ts +0 -14
- package/test/buffalo.test.ts +0 -431
- package/test/controller.bench.ts +0 -214
- package/test/controller.test.ts +0 -8702
- package/test/greenpower.test.ts +0 -1408
- package/test/mockAdapters.ts +0 -65
- package/test/mockDevices.ts +0 -598
- package/test/requests.bench.ts +0 -229
- package/test/testUtils.ts +0 -20
- package/test/tsconfig.json +0 -9
- package/test/utils/math.ts +0 -19
- package/test/utils.test.ts +0 -279
- package/test/vitest.config.mts +0 -26
- package/test/zcl.test.ts +0 -2831
- package/test/zspec/utils.test.ts +0 -68
- package/test/zspec/zcl/buffalo.test.ts +0 -1374
- package/test/zspec/zcl/frame.test.ts +0 -960
- package/test/zspec/zcl/utils.test.ts +0 -273
- package/test/zspec/zdo/buffalo.test.ts +0 -1850
- package/test/zspec/zdo/utils.test.ts +0 -241
- package/tsconfig.json +0 -24
|
@@ -1,960 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it} from "vitest";
|
|
2
|
-
import * as Zcl from "../../../src/zspec/zcl";
|
|
3
|
-
import {BuffaloZcl} from "../../../src/zspec/zcl/buffaloZcl";
|
|
4
|
-
import {uint16To8Array, uint32To8Array, uint56To8Array} from "../../utils/math";
|
|
5
|
-
|
|
6
|
-
/** Header with Global frame type */
|
|
7
|
-
const GLOBAL_HEADER = new Zcl.Header(
|
|
8
|
-
{
|
|
9
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
10
|
-
manufacturerSpecific: false,
|
|
11
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
12
|
-
disableDefaultResponse: false,
|
|
13
|
-
reservedBits: 0,
|
|
14
|
-
},
|
|
15
|
-
undefined,
|
|
16
|
-
123,
|
|
17
|
-
Zcl.Foundation.read.ID,
|
|
18
|
-
);
|
|
19
|
-
const GLOBAL_HEADER_BUFFER = Buffer.from([0, 123, Zcl.Foundation.read.ID]);
|
|
20
|
-
|
|
21
|
-
/** Header with Global frame type and server to client direction */
|
|
22
|
-
const GLOBAL_RSP_HEADER = new Zcl.Header(
|
|
23
|
-
{
|
|
24
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
25
|
-
manufacturerSpecific: false,
|
|
26
|
-
direction: Zcl.Direction.SERVER_TO_CLIENT,
|
|
27
|
-
disableDefaultResponse: false,
|
|
28
|
-
reservedBits: 0,
|
|
29
|
-
},
|
|
30
|
-
undefined,
|
|
31
|
-
78,
|
|
32
|
-
Zcl.Foundation.readRsp.ID,
|
|
33
|
-
);
|
|
34
|
-
const GLOBAL_RSP_HEADER_BUFFER = Buffer.from([8, 78, Zcl.Foundation.readRsp.ID]);
|
|
35
|
-
|
|
36
|
-
/** Header with Global frame type with command report */
|
|
37
|
-
const GLOBAL_HEADER_REPORT = new Zcl.Header(
|
|
38
|
-
{
|
|
39
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
40
|
-
manufacturerSpecific: false,
|
|
41
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
42
|
-
disableDefaultResponse: false,
|
|
43
|
-
reservedBits: 0,
|
|
44
|
-
},
|
|
45
|
-
undefined,
|
|
46
|
-
123,
|
|
47
|
-
Zcl.Foundation.report.ID,
|
|
48
|
-
);
|
|
49
|
-
const GLOBAL_HEADER_REPORT_BUFFER = Buffer.from([0, 123, Zcl.Foundation.report.ID]);
|
|
50
|
-
|
|
51
|
-
/** Header with Global frame type and server to client direction including condition-based parameters */
|
|
52
|
-
const GLOBAL_CONDITION_HEADER = new Zcl.Header(
|
|
53
|
-
{
|
|
54
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
55
|
-
manufacturerSpecific: false,
|
|
56
|
-
direction: Zcl.Direction.SERVER_TO_CLIENT,
|
|
57
|
-
disableDefaultResponse: false,
|
|
58
|
-
reservedBits: 0,
|
|
59
|
-
},
|
|
60
|
-
undefined,
|
|
61
|
-
78,
|
|
62
|
-
Zcl.Foundation.configReport.ID,
|
|
63
|
-
);
|
|
64
|
-
const GLOBAL_CONDITION_HEADER_BUFFER = Buffer.from([8, 78, Zcl.Foundation.configReport.ID]);
|
|
65
|
-
|
|
66
|
-
/** Header with Specific frame type */
|
|
67
|
-
const SPECIFIC_HEADER = new Zcl.Header(
|
|
68
|
-
{
|
|
69
|
-
frameType: Zcl.FrameType.SPECIFIC,
|
|
70
|
-
manufacturerSpecific: false,
|
|
71
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
72
|
-
disableDefaultResponse: false,
|
|
73
|
-
reservedBits: 0,
|
|
74
|
-
},
|
|
75
|
-
undefined,
|
|
76
|
-
44,
|
|
77
|
-
Zcl.Clusters.genAlarms.commands.getAlarm.ID,
|
|
78
|
-
);
|
|
79
|
-
const SPECIFIC_HEADER_BUFFER = Buffer.from([1, 44, Zcl.Clusters.genAlarms.commands.getAlarm.ID]);
|
|
80
|
-
|
|
81
|
-
/** Header with Specific frame type including condition-based parameters */
|
|
82
|
-
const SPECIFIC_CONDITION_HEADER = new Zcl.Header(
|
|
83
|
-
{
|
|
84
|
-
frameType: Zcl.FrameType.SPECIFIC,
|
|
85
|
-
manufacturerSpecific: false,
|
|
86
|
-
direction: Zcl.Direction.SERVER_TO_CLIENT,
|
|
87
|
-
disableDefaultResponse: false,
|
|
88
|
-
reservedBits: 0,
|
|
89
|
-
},
|
|
90
|
-
undefined,
|
|
91
|
-
45,
|
|
92
|
-
Zcl.Clusters.genOta.commandsResponse.queryNextImageResponse.ID,
|
|
93
|
-
);
|
|
94
|
-
const SPECIFIC_CONDITION_HEADER_BUFFER = Buffer.from([9, 45, Zcl.Clusters.genOta.commandsResponse.queryNextImageResponse.ID]);
|
|
95
|
-
|
|
96
|
-
/** Header with Specific frame type and server to client direction */
|
|
97
|
-
const SPECIFIC_RSP_HEADER = new Zcl.Header(
|
|
98
|
-
{
|
|
99
|
-
frameType: Zcl.FrameType.SPECIFIC,
|
|
100
|
-
manufacturerSpecific: false,
|
|
101
|
-
direction: Zcl.Direction.SERVER_TO_CLIENT,
|
|
102
|
-
disableDefaultResponse: false,
|
|
103
|
-
reservedBits: 0,
|
|
104
|
-
},
|
|
105
|
-
undefined,
|
|
106
|
-
53,
|
|
107
|
-
Zcl.Clusters.genAlarms.commandsResponse.alarm.ID,
|
|
108
|
-
);
|
|
109
|
-
const SPECIFIC_RSP_HEADER_BUFFER = Buffer.from([9, 53, Zcl.Clusters.genAlarms.commandsResponse.alarm.ID]);
|
|
110
|
-
|
|
111
|
-
/** Header with manufacturer-specific */
|
|
112
|
-
const MANUF_SPE_HEADER = new Zcl.Header(
|
|
113
|
-
{
|
|
114
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
115
|
-
manufacturerSpecific: true,
|
|
116
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
117
|
-
disableDefaultResponse: false,
|
|
118
|
-
reservedBits: 0,
|
|
119
|
-
},
|
|
120
|
-
Zcl.ManufacturerCode.AAC_TECHNOLOGIES_HOLDING,
|
|
121
|
-
234,
|
|
122
|
-
Zcl.Foundation.read.ID,
|
|
123
|
-
);
|
|
124
|
-
const MANUF_SPE_HEADER_BUFFER = Buffer.from([4, ...uint16To8Array(Zcl.ManufacturerCode.AAC_TECHNOLOGIES_HOLDING), 234, Zcl.Foundation.read.ID]);
|
|
125
|
-
|
|
126
|
-
/** Frame of Global type */
|
|
127
|
-
const GLOBAL_FRAME = Zcl.Frame.create(
|
|
128
|
-
GLOBAL_HEADER.frameControl.frameType,
|
|
129
|
-
GLOBAL_HEADER.frameControl.direction,
|
|
130
|
-
GLOBAL_HEADER.frameControl.disableDefaultResponse,
|
|
131
|
-
GLOBAL_HEADER.manufacturerCode,
|
|
132
|
-
GLOBAL_HEADER.transactionSequenceNumber,
|
|
133
|
-
GLOBAL_HEADER.commandIdentifier,
|
|
134
|
-
Zcl.Clusters.genBasic.ID,
|
|
135
|
-
[{attrId: 256}] /*payload*/,
|
|
136
|
-
{} /*custom clusters*/,
|
|
137
|
-
GLOBAL_HEADER.frameControl.reservedBits,
|
|
138
|
-
);
|
|
139
|
-
const GLOBAL_FRAME_BUFFER = Buffer.concat([GLOBAL_HEADER_BUFFER, Buffer.from(uint16To8Array(256))]);
|
|
140
|
-
const GLOBAL_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":123,"commandIdentifier":0},"payload":[{"attrId":256}],"command":{"ID":0,"name":"read","parameters":[{"name":"attrId","type":33}],"response":1}}`;
|
|
141
|
-
|
|
142
|
-
/** Frame of Global type with BigInt */
|
|
143
|
-
const GLOBAL_FRAME_BIG_INT = Zcl.Frame.create(
|
|
144
|
-
GLOBAL_HEADER_REPORT.frameControl.frameType,
|
|
145
|
-
GLOBAL_HEADER_REPORT.frameControl.direction,
|
|
146
|
-
GLOBAL_HEADER_REPORT.frameControl.disableDefaultResponse,
|
|
147
|
-
GLOBAL_HEADER_REPORT.manufacturerCode,
|
|
148
|
-
GLOBAL_HEADER_REPORT.transactionSequenceNumber,
|
|
149
|
-
GLOBAL_HEADER_REPORT.commandIdentifier,
|
|
150
|
-
Zcl.Clusters.haApplianceIdentification.ID,
|
|
151
|
-
[{attrId: 0, dataType: Zcl.DataType.UINT56, attrData: 200n}] /*payload*/,
|
|
152
|
-
{} /*custom clusters*/,
|
|
153
|
-
GLOBAL_HEADER_REPORT.frameControl.reservedBits,
|
|
154
|
-
);
|
|
155
|
-
const GLOBAL_FRAME_BIG_INT_BUFFER = Buffer.concat([
|
|
156
|
-
GLOBAL_HEADER_REPORT_BUFFER,
|
|
157
|
-
Buffer.from(uint16To8Array(0)),
|
|
158
|
-
Buffer.from([Zcl.DataType.UINT56]),
|
|
159
|
-
Buffer.from(uint56To8Array(200n)),
|
|
160
|
-
]);
|
|
161
|
-
const GLOBAL_FRAME_BIG_INT_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":123,"commandIdentifier":10},"payload":[{"attrId":0,"dataType":38,"attrData":"200"}],"command":{"ID":10,"name":"report","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}]}}`;
|
|
162
|
-
|
|
163
|
-
/** Frame of Global type and response command */
|
|
164
|
-
const GLOBAL_RSP_FRAME = Zcl.Frame.create(
|
|
165
|
-
GLOBAL_RSP_HEADER.frameControl.frameType,
|
|
166
|
-
GLOBAL_RSP_HEADER.frameControl.direction,
|
|
167
|
-
GLOBAL_RSP_HEADER.frameControl.disableDefaultResponse,
|
|
168
|
-
GLOBAL_RSP_HEADER.manufacturerCode,
|
|
169
|
-
GLOBAL_RSP_HEADER.transactionSequenceNumber,
|
|
170
|
-
GLOBAL_RSP_HEADER.commandIdentifier,
|
|
171
|
-
Zcl.Clusters.genPowerCfg.ID,
|
|
172
|
-
[{attrId: 256, status: Zcl.Status.SUCCESS, dataType: Zcl.DataType.ENUM8, attrData: 127}] /*payload*/,
|
|
173
|
-
{} /*custom clusters*/,
|
|
174
|
-
GLOBAL_RSP_HEADER.frameControl.reservedBits,
|
|
175
|
-
);
|
|
176
|
-
const GLOBAL_RSP_FRAME_BUFFER = Buffer.concat([
|
|
177
|
-
GLOBAL_RSP_HEADER_BUFFER,
|
|
178
|
-
Buffer.from([...uint16To8Array(256), Zcl.Status.SUCCESS, Zcl.DataType.ENUM8, 127]),
|
|
179
|
-
]);
|
|
180
|
-
const GLOBAL_RSP_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":1,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":78,"commandIdentifier":1},"payload":[{"attrId":256,"status":0,"dataType":48,"attrData":127}],"command":{"ID":1,"name":"readRsp","parameters":[{"name":"attrId","type":33},{"name":"status","type":32},{"name":"dataType","type":32,"conditions":[{"type":"fieldEquals","field":"status","value":0}]},{"name":"attrData","type":1000,"conditions":[{"type":"fieldEquals","field":"status","value":0}]}]}}`;
|
|
181
|
-
|
|
182
|
-
/** Frame of Global type with no payload */
|
|
183
|
-
const GLOBAL_FRAME_NO_PAYLOAD = Zcl.Frame.create(
|
|
184
|
-
GLOBAL_HEADER.frameControl.frameType,
|
|
185
|
-
GLOBAL_HEADER.frameControl.direction,
|
|
186
|
-
GLOBAL_HEADER.frameControl.disableDefaultResponse,
|
|
187
|
-
GLOBAL_HEADER.manufacturerCode,
|
|
188
|
-
GLOBAL_HEADER.transactionSequenceNumber,
|
|
189
|
-
GLOBAL_HEADER.commandIdentifier,
|
|
190
|
-
Zcl.Clusters.genBasic.ID,
|
|
191
|
-
[] /*payload*/,
|
|
192
|
-
{} /*custom clusters*/,
|
|
193
|
-
GLOBAL_HEADER.frameControl.reservedBits,
|
|
194
|
-
);
|
|
195
|
-
const GLOBAL_FRAME_NO_PAYLOAD_BUFFER = Buffer.concat([GLOBAL_HEADER_BUFFER]);
|
|
196
|
-
const GLOBAL_FRAME_NO_PAYLOAD_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":123,"commandIdentifier":0},"payload":[],"command":{"ID":0,"name":"read","parameters":[{"name":"attrId","type":33}],"response":1}}`;
|
|
197
|
-
|
|
198
|
-
/** Frame of Global type with condition-based parameters */
|
|
199
|
-
const GLOBAL_CONDITION_FRAME = Zcl.Frame.create(
|
|
200
|
-
GLOBAL_CONDITION_HEADER.frameControl.frameType,
|
|
201
|
-
GLOBAL_CONDITION_HEADER.frameControl.direction,
|
|
202
|
-
GLOBAL_CONDITION_HEADER.frameControl.disableDefaultResponse,
|
|
203
|
-
GLOBAL_CONDITION_HEADER.manufacturerCode,
|
|
204
|
-
GLOBAL_CONDITION_HEADER.transactionSequenceNumber,
|
|
205
|
-
GLOBAL_CONDITION_HEADER.commandIdentifier,
|
|
206
|
-
Zcl.Clusters.genOnOff.ID,
|
|
207
|
-
[{direction: Zcl.Direction.SERVER_TO_CLIENT, attrId: 256, timeout: 10000}] /*payload*/,
|
|
208
|
-
{} /*custom clusters*/,
|
|
209
|
-
GLOBAL_CONDITION_HEADER.frameControl.reservedBits,
|
|
210
|
-
);
|
|
211
|
-
const GLOBAL_CONDITION_FRAME_BUFFER = Buffer.concat([
|
|
212
|
-
GLOBAL_CONDITION_HEADER_BUFFER,
|
|
213
|
-
Buffer.from([Zcl.Direction.SERVER_TO_CLIENT, ...uint16To8Array(256), ...uint16To8Array(10000)]),
|
|
214
|
-
]);
|
|
215
|
-
const GLOBAL_CONDITION_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":1,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":78,"commandIdentifier":6},"payload":[{"direction":1,"attrId":256,"timeout":10000}],"command":{"ID":6,"name":"configReport","parameters":[{"name":"direction","type":32},{"name":"attrId","type":33},{"name":"dataType","type":32,"conditions":[{"type":"fieldEquals","field":"direction","value":0}]},{"name":"minRepIntval","type":33,"conditions":[{"type":"fieldEquals","field":"direction","value":0}]},{"name":"maxRepIntval","type":33,"conditions":[{"type":"fieldEquals","field":"direction","value":0}]},{"name":"repChange","type":1000,"conditions":[{"type":"fieldEquals","field":"direction","value":0},{"type":"dataTypeValueTypeEquals","value":"ANALOG"}]},{"name":"timeout","type":33,"conditions":[{"type":"fieldEquals","field":"direction","value":1}]}],"response":7}}`;
|
|
216
|
-
|
|
217
|
-
/** Frame of Specific type */
|
|
218
|
-
const SPECIFIC_FRAME = Zcl.Frame.create(
|
|
219
|
-
SPECIFIC_HEADER.frameControl.frameType,
|
|
220
|
-
SPECIFIC_HEADER.frameControl.direction,
|
|
221
|
-
SPECIFIC_HEADER.frameControl.disableDefaultResponse,
|
|
222
|
-
SPECIFIC_HEADER.manufacturerCode,
|
|
223
|
-
SPECIFIC_HEADER.transactionSequenceNumber,
|
|
224
|
-
SPECIFIC_HEADER.commandIdentifier,
|
|
225
|
-
Zcl.Clusters.genAlarms.ID,
|
|
226
|
-
{} /*payload*/,
|
|
227
|
-
{} /*custom clusters*/,
|
|
228
|
-
SPECIFIC_HEADER.frameControl.reservedBits,
|
|
229
|
-
);
|
|
230
|
-
const SPECIFIC_FRAME_BUFFER = Buffer.concat([SPECIFIC_HEADER_BUFFER]);
|
|
231
|
-
const SPECIFIC_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":1,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":44,"commandIdentifier":2},"payload":{},"command":{"ID":2,"parameters":[],"name":"getAlarm"}}`;
|
|
232
|
-
|
|
233
|
-
/** Frame of Specific type and response command */
|
|
234
|
-
const SPECIFIC_RSP_FRAME = Zcl.Frame.create(
|
|
235
|
-
SPECIFIC_RSP_HEADER.frameControl.frameType,
|
|
236
|
-
SPECIFIC_RSP_HEADER.frameControl.direction,
|
|
237
|
-
SPECIFIC_RSP_HEADER.frameControl.disableDefaultResponse,
|
|
238
|
-
SPECIFIC_RSP_HEADER.manufacturerCode,
|
|
239
|
-
SPECIFIC_RSP_HEADER.transactionSequenceNumber,
|
|
240
|
-
SPECIFIC_RSP_HEADER.commandIdentifier,
|
|
241
|
-
Zcl.Clusters.genAlarms.ID,
|
|
242
|
-
{alarmcode: 246, clusterid: 3456} /*payload*/,
|
|
243
|
-
{} /*custom clusters*/,
|
|
244
|
-
SPECIFIC_RSP_HEADER.frameControl.reservedBits,
|
|
245
|
-
);
|
|
246
|
-
const SPECIFIC_RSP_FRAME_BUFFER = Buffer.concat([SPECIFIC_RSP_HEADER_BUFFER, Buffer.from([246, ...uint16To8Array(3456)])]);
|
|
247
|
-
const SPECIFIC_RSP_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":1,"direction":1,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":53,"commandIdentifier":0},"payload":{"alarmcode":246,"clusterid":3456},"command":{"ID":0,"parameters":[{"name":"alarmcode","type":32},{"name":"clusterid","type":33}],"name":"alarm"}}`;
|
|
248
|
-
|
|
249
|
-
/** Frame of Specific type with condition-based parameters */
|
|
250
|
-
const SPECIFIC_CONDITION_FRAME = Zcl.Frame.create(
|
|
251
|
-
SPECIFIC_CONDITION_HEADER.frameControl.frameType,
|
|
252
|
-
SPECIFIC_CONDITION_HEADER.frameControl.direction,
|
|
253
|
-
SPECIFIC_CONDITION_HEADER.frameControl.disableDefaultResponse,
|
|
254
|
-
SPECIFIC_CONDITION_HEADER.manufacturerCode,
|
|
255
|
-
SPECIFIC_CONDITION_HEADER.transactionSequenceNumber,
|
|
256
|
-
SPECIFIC_CONDITION_HEADER.commandIdentifier,
|
|
257
|
-
Zcl.Clusters.genOta.ID,
|
|
258
|
-
{status: Zcl.Status.ABORT} /*payload*/,
|
|
259
|
-
{} /*custom clusters*/,
|
|
260
|
-
SPECIFIC_CONDITION_HEADER.frameControl.reservedBits,
|
|
261
|
-
);
|
|
262
|
-
const SPECIFIC_CONDITION_FRAME_BUFFER = Buffer.concat([SPECIFIC_CONDITION_HEADER_BUFFER, Buffer.from([149])]);
|
|
263
|
-
const SPECIFIC_CONDITION_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":1,"direction":1,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":45,"commandIdentifier":2},"payload":{"status":149},"command":{"ID":2,"parameters":[{"name":"status","type":32},{"name":"manufacturerCode","type":33,"conditions":[{"type":"fieldEquals","field":"status","value":0}]},{"name":"imageType","type":33,"conditions":[{"type":"fieldEquals","field":"status","value":0}]},{"name":"fileVersion","type":35,"conditions":[{"type":"fieldEquals","field":"status","value":0}]},{"name":"imageSize","type":35,"conditions":[{"type":"fieldEquals","field":"status","value":0}]}],"name":"queryNextImageResponse"}}`;
|
|
264
|
-
|
|
265
|
-
/** Frame manufacturer-specific */
|
|
266
|
-
const MANUF_SPE_FRAME = Zcl.Frame.create(
|
|
267
|
-
MANUF_SPE_HEADER.frameControl.frameType,
|
|
268
|
-
MANUF_SPE_HEADER.frameControl.direction,
|
|
269
|
-
MANUF_SPE_HEADER.frameControl.disableDefaultResponse,
|
|
270
|
-
MANUF_SPE_HEADER.manufacturerCode,
|
|
271
|
-
MANUF_SPE_HEADER.transactionSequenceNumber,
|
|
272
|
-
MANUF_SPE_HEADER.commandIdentifier,
|
|
273
|
-
Zcl.Foundation.read.ID,
|
|
274
|
-
[{attrId: 256}] /*payload*/,
|
|
275
|
-
{} /*custom clusters*/,
|
|
276
|
-
MANUF_SPE_HEADER.frameControl.reservedBits,
|
|
277
|
-
);
|
|
278
|
-
const MANUF_SPE_FRAME_BUFFER = Buffer.concat([MANUF_SPE_HEADER_BUFFER, Buffer.from(uint16To8Array(256))]);
|
|
279
|
-
const MANUF_SPE_FRAME_STRING = `{"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":true},"manufacturerCode":4344,"transactionSequenceNumber":234,"commandIdentifier":0},"payload":[{"attrId":256}],"command":{"ID":0,"name":"read","parameters":[{"name":"attrId","type":33}],"response":1}}`;
|
|
280
|
-
|
|
281
|
-
describe("ZCL Frame", () => {
|
|
282
|
-
describe("Validates Parameter Condition", () => {
|
|
283
|
-
it("MINIMUM_REMAINING_BUFFER_BYTES", () => {
|
|
284
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.configReportRsp.parameters[1], {status: 1}, 3)).toBeTruthy();
|
|
285
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.configReportRsp.parameters[1], {status: 1}, 2)).toBeFalsy();
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("BITMASK_SET", () => {
|
|
289
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[8], {options: 0x4000}, undefined)).toBeTruthy();
|
|
290
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[8], {options: 0x4150}, undefined)).toBeTruthy();
|
|
291
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[8], {options: 0x0400}, undefined)).toBeFalsy();
|
|
292
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[8], {options: 0x1400}, undefined)).toBeFalsy();
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("BITFIELD_ENUM", () => {
|
|
296
|
-
// {param:'options', offset: 0, size: 3, value: 0b000}
|
|
297
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b000}, undefined)).toBeTruthy();
|
|
298
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b1000}, undefined)).toBeTruthy();
|
|
299
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b001}, undefined)).toBeFalsy();
|
|
300
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b011}, undefined)).toBeFalsy();
|
|
301
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b100}, undefined)).toBeFalsy();
|
|
302
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Clusters.greenPower.commands.notification.parameters[1], {options: 0b1010}, undefined)).toBeFalsy();
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("multiple including DATA_TYPE_CLASS_EQUAL", () => {
|
|
306
|
-
expect(
|
|
307
|
-
Zcl.Frame.conditionsValid(
|
|
308
|
-
Zcl.Foundation.configReport.parameters[5],
|
|
309
|
-
{direction: Zcl.Direction.CLIENT_TO_SERVER, dataType: Zcl.DataType.UINT8},
|
|
310
|
-
undefined,
|
|
311
|
-
),
|
|
312
|
-
).toBeTruthy();
|
|
313
|
-
expect(
|
|
314
|
-
Zcl.Frame.conditionsValid(
|
|
315
|
-
Zcl.Foundation.configReport.parameters[5],
|
|
316
|
-
{direction: Zcl.Direction.CLIENT_TO_SERVER, dataType: Zcl.DataType.DATA8},
|
|
317
|
-
undefined,
|
|
318
|
-
),
|
|
319
|
-
).toBeFalsy();
|
|
320
|
-
expect(
|
|
321
|
-
Zcl.Frame.conditionsValid(
|
|
322
|
-
Zcl.Foundation.configReport.parameters[5],
|
|
323
|
-
{direction: Zcl.Direction.SERVER_TO_CLIENT, dataType: Zcl.DataType.UINT8},
|
|
324
|
-
undefined,
|
|
325
|
-
),
|
|
326
|
-
).toBeFalsy();
|
|
327
|
-
expect(
|
|
328
|
-
Zcl.Frame.conditionsValid(
|
|
329
|
-
Zcl.Foundation.configReport.parameters[5],
|
|
330
|
-
{direction: Zcl.Direction.SERVER_TO_CLIENT, dataType: Zcl.DataType.DATA8},
|
|
331
|
-
undefined,
|
|
332
|
-
),
|
|
333
|
-
).toBeFalsy();
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it("FIELD_EQUAL", () => {
|
|
337
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.readRsp.parameters[2], {status: 0}, undefined)).toBeTruthy();
|
|
338
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.readRsp.parameters[2], {status: 1}, undefined)).toBeFalsy();
|
|
339
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.writeRsp.parameters[1], {status: 1}, undefined)).toBeTruthy();
|
|
340
|
-
expect(Zcl.Frame.conditionsValid(Zcl.Foundation.writeRsp.parameters[1], {status: 0}, undefined)).toBeFalsy();
|
|
341
|
-
expect(
|
|
342
|
-
Zcl.Frame.conditionsValid(Zcl.Foundation.configReport.parameters[2], {direction: Zcl.Direction.CLIENT_TO_SERVER}, undefined),
|
|
343
|
-
).toBeTruthy();
|
|
344
|
-
expect(
|
|
345
|
-
Zcl.Frame.conditionsValid(Zcl.Foundation.configReport.parameters[2], {direction: Zcl.Direction.SERVER_TO_CLIENT}, undefined),
|
|
346
|
-
).toBeFalsy();
|
|
347
|
-
expect(
|
|
348
|
-
Zcl.Frame.conditionsValid(Zcl.Foundation.configReport.parameters[6], {direction: Zcl.Direction.SERVER_TO_CLIENT}, undefined),
|
|
349
|
-
).toBeTruthy();
|
|
350
|
-
expect(
|
|
351
|
-
Zcl.Frame.conditionsValid(Zcl.Foundation.configReport.parameters[6], {direction: Zcl.Direction.CLIENT_TO_SERVER}, undefined),
|
|
352
|
-
).toBeFalsy();
|
|
353
|
-
expect(
|
|
354
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.touchlink.commandsResponse.scanResponse.parameters[13], {numberOfSubDevices: 1}, undefined),
|
|
355
|
-
).toBeTruthy();
|
|
356
|
-
expect(
|
|
357
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.touchlink.commandsResponse.scanResponse.parameters[13], {numberOfSubDevices: 0}, undefined),
|
|
358
|
-
).toBeFalsy();
|
|
359
|
-
expect(
|
|
360
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.touchlink.commandsResponse.scanResponse.parameters[13], {numberOfSubDevices: 3}, undefined),
|
|
361
|
-
).toBeFalsy();
|
|
362
|
-
expect(
|
|
363
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[2], {payloadType: 0}, undefined),
|
|
364
|
-
).toBeFalsy();
|
|
365
|
-
expect(
|
|
366
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[2], {payloadType: 1}, undefined),
|
|
367
|
-
).toBeTruthy();
|
|
368
|
-
expect(
|
|
369
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[3], {payloadType: 1}, undefined),
|
|
370
|
-
).toBeFalsy();
|
|
371
|
-
expect(
|
|
372
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[3], {payloadType: 2}, undefined),
|
|
373
|
-
).toBeTruthy();
|
|
374
|
-
expect(
|
|
375
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[4], {payloadType: 2}, undefined),
|
|
376
|
-
).toBeFalsy();
|
|
377
|
-
expect(
|
|
378
|
-
Zcl.Frame.conditionsValid(Zcl.Clusters.genOta.commandsResponse.imageNotify.parameters[4], {payloadType: 3}, undefined),
|
|
379
|
-
).toBeTruthy();
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
describe("Header", () => {
|
|
384
|
-
it.each([
|
|
385
|
-
[
|
|
386
|
-
"global",
|
|
387
|
-
{
|
|
388
|
-
frameControl: GLOBAL_HEADER.frameControl,
|
|
389
|
-
manufacturerCode: GLOBAL_HEADER.manufacturerCode,
|
|
390
|
-
transactionSequenceNumber: GLOBAL_HEADER.transactionSequenceNumber,
|
|
391
|
-
commandId: GLOBAL_HEADER.commandIdentifier,
|
|
392
|
-
},
|
|
393
|
-
{written: GLOBAL_HEADER_BUFFER},
|
|
394
|
-
],
|
|
395
|
-
[
|
|
396
|
-
"global response",
|
|
397
|
-
{
|
|
398
|
-
frameControl: GLOBAL_RSP_HEADER.frameControl,
|
|
399
|
-
manufacturerCode: GLOBAL_RSP_HEADER.manufacturerCode,
|
|
400
|
-
transactionSequenceNumber: GLOBAL_RSP_HEADER.transactionSequenceNumber,
|
|
401
|
-
commandId: GLOBAL_RSP_HEADER.commandIdentifier,
|
|
402
|
-
},
|
|
403
|
-
{written: GLOBAL_RSP_HEADER_BUFFER},
|
|
404
|
-
],
|
|
405
|
-
[
|
|
406
|
-
"specific",
|
|
407
|
-
{
|
|
408
|
-
frameControl: SPECIFIC_HEADER.frameControl,
|
|
409
|
-
manufacturerCode: SPECIFIC_HEADER.manufacturerCode,
|
|
410
|
-
transactionSequenceNumber: SPECIFIC_HEADER.transactionSequenceNumber,
|
|
411
|
-
commandId: SPECIFIC_HEADER.commandIdentifier,
|
|
412
|
-
},
|
|
413
|
-
{written: SPECIFIC_HEADER_BUFFER},
|
|
414
|
-
],
|
|
415
|
-
[
|
|
416
|
-
"manufacturer-specific",
|
|
417
|
-
{
|
|
418
|
-
frameControl: MANUF_SPE_HEADER.frameControl,
|
|
419
|
-
manufacturerCode: MANUF_SPE_HEADER.manufacturerCode,
|
|
420
|
-
transactionSequenceNumber: MANUF_SPE_HEADER.transactionSequenceNumber,
|
|
421
|
-
commandId: MANUF_SPE_HEADER.commandIdentifier,
|
|
422
|
-
},
|
|
423
|
-
{written: MANUF_SPE_HEADER_BUFFER},
|
|
424
|
-
],
|
|
425
|
-
[
|
|
426
|
-
"disable default response",
|
|
427
|
-
{
|
|
428
|
-
frameControl: {
|
|
429
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
430
|
-
manufacturerSpecific: false,
|
|
431
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
432
|
-
disableDefaultResponse: true,
|
|
433
|
-
reservedBits: 0,
|
|
434
|
-
},
|
|
435
|
-
manufacturerCode: undefined,
|
|
436
|
-
transactionSequenceNumber: 234,
|
|
437
|
-
commandId: 1,
|
|
438
|
-
},
|
|
439
|
-
{written: Buffer.from([16, 234, 1])},
|
|
440
|
-
],
|
|
441
|
-
[
|
|
442
|
-
"reserved bits - non-compliant use",
|
|
443
|
-
{
|
|
444
|
-
frameControl: {
|
|
445
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
446
|
-
manufacturerSpecific: false,
|
|
447
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
448
|
-
disableDefaultResponse: false,
|
|
449
|
-
reservedBits: 7,
|
|
450
|
-
},
|
|
451
|
-
manufacturerCode: undefined,
|
|
452
|
-
transactionSequenceNumber: 234,
|
|
453
|
-
commandId: 1,
|
|
454
|
-
},
|
|
455
|
-
{written: Buffer.from([224, 234, 1])},
|
|
456
|
-
],
|
|
457
|
-
[
|
|
458
|
-
"specific manufacturer-specific",
|
|
459
|
-
{
|
|
460
|
-
frameControl: {
|
|
461
|
-
frameType: Zcl.FrameType.SPECIFIC,
|
|
462
|
-
manufacturerSpecific: true,
|
|
463
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
464
|
-
disableDefaultResponse: false,
|
|
465
|
-
reservedBits: 0,
|
|
466
|
-
},
|
|
467
|
-
manufacturerCode: Zcl.ManufacturerCode.S3C,
|
|
468
|
-
transactionSequenceNumber: 234,
|
|
469
|
-
commandId: 1,
|
|
470
|
-
},
|
|
471
|
-
{written: Buffer.from([5, ...uint16To8Array(Zcl.ManufacturerCode.S3C), 234, 1])},
|
|
472
|
-
],
|
|
473
|
-
[
|
|
474
|
-
"all non-zero - non-compliant use of reservedBits",
|
|
475
|
-
{
|
|
476
|
-
frameControl: {
|
|
477
|
-
frameType: Zcl.FrameType.SPECIFIC,
|
|
478
|
-
manufacturerSpecific: true,
|
|
479
|
-
direction: Zcl.Direction.SERVER_TO_CLIENT,
|
|
480
|
-
disableDefaultResponse: true,
|
|
481
|
-
reservedBits: 3,
|
|
482
|
-
},
|
|
483
|
-
manufacturerCode: Zcl.ManufacturerCode.BOSCH_SECURITY_SYSTEMS_INC,
|
|
484
|
-
transactionSequenceNumber: 234,
|
|
485
|
-
commandId: 1,
|
|
486
|
-
},
|
|
487
|
-
{written: Buffer.from([125, ...uint16To8Array(Zcl.ManufacturerCode.BOSCH_SECURITY_SYSTEMS_INC), 234, 1])},
|
|
488
|
-
],
|
|
489
|
-
])("Reads & Writes %s", (_name, payload, expected) => {
|
|
490
|
-
// write
|
|
491
|
-
{
|
|
492
|
-
const header = new Zcl.Header(payload.frameControl, payload.manufacturerCode, payload.transactionSequenceNumber, payload.commandId);
|
|
493
|
-
const buffer = Buffer.alloc(10);
|
|
494
|
-
const buffalo = new BuffaloZcl(buffer);
|
|
495
|
-
header.write(buffalo);
|
|
496
|
-
|
|
497
|
-
expect(buffer.subarray(0, header.length)).toStrictEqual(expected.written);
|
|
498
|
-
expect(header.length).toStrictEqual(expected.written.length);
|
|
499
|
-
expect(header.isGlobal).toStrictEqual(payload.frameControl.frameType === Zcl.FrameType.GLOBAL);
|
|
500
|
-
expect(header.isSpecific).toStrictEqual(payload.frameControl.frameType === Zcl.FrameType.SPECIFIC);
|
|
501
|
-
}
|
|
502
|
-
// read
|
|
503
|
-
{
|
|
504
|
-
const header = Zcl.Header.fromBuffer(expected.written)!;
|
|
505
|
-
|
|
506
|
-
expect(header).toBeInstanceOf(Zcl.Header);
|
|
507
|
-
expect(header.length).toStrictEqual(expected.written.length);
|
|
508
|
-
expect(header.isGlobal).toStrictEqual(payload.frameControl.frameType === Zcl.FrameType.GLOBAL);
|
|
509
|
-
expect(header.isSpecific).toStrictEqual(payload.frameControl.frameType === Zcl.FrameType.SPECIFIC);
|
|
510
|
-
expect(header.frameControl).toStrictEqual(payload.frameControl);
|
|
511
|
-
expect(header.manufacturerCode).toStrictEqual(payload.manufacturerCode);
|
|
512
|
-
expect(header.transactionSequenceNumber).toStrictEqual(payload.transactionSequenceNumber);
|
|
513
|
-
expect(header.commandIdentifier).toStrictEqual(payload.commandId);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
it.each([
|
|
518
|
-
["basic", {value: [0, 234]}],
|
|
519
|
-
["manufacturer specific", {value: [4, ...uint16To8Array(1234), 234]}],
|
|
520
|
-
])("Reads non-compliant header as undefined %s", (_name, payload) => {
|
|
521
|
-
expect(Zcl.Header.fromBuffer(Buffer.from(payload.value))).toStrictEqual(undefined);
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
it.each([
|
|
526
|
-
["global", GLOBAL_FRAME, {string: GLOBAL_FRAME_STRING, header: GLOBAL_HEADER, written: GLOBAL_FRAME_BUFFER}],
|
|
527
|
-
[
|
|
528
|
-
"global BigInt",
|
|
529
|
-
GLOBAL_FRAME_BIG_INT,
|
|
530
|
-
{string: GLOBAL_FRAME_BIG_INT_STRING, header: GLOBAL_HEADER_REPORT, written: GLOBAL_FRAME_BIG_INT_BUFFER},
|
|
531
|
-
],
|
|
532
|
-
["global response", GLOBAL_RSP_FRAME, {string: GLOBAL_RSP_FRAME_STRING, header: GLOBAL_RSP_HEADER, written: GLOBAL_RSP_FRAME_BUFFER}],
|
|
533
|
-
[
|
|
534
|
-
"global no payload",
|
|
535
|
-
GLOBAL_FRAME_NO_PAYLOAD,
|
|
536
|
-
{string: GLOBAL_FRAME_NO_PAYLOAD_STRING, header: GLOBAL_HEADER, written: GLOBAL_FRAME_NO_PAYLOAD_BUFFER},
|
|
537
|
-
],
|
|
538
|
-
[
|
|
539
|
-
"global with condition-based parameters",
|
|
540
|
-
GLOBAL_CONDITION_FRAME,
|
|
541
|
-
{string: GLOBAL_CONDITION_FRAME_STRING, header: GLOBAL_CONDITION_HEADER, written: GLOBAL_CONDITION_FRAME_BUFFER},
|
|
542
|
-
],
|
|
543
|
-
["specific", SPECIFIC_FRAME, {string: SPECIFIC_FRAME_STRING, header: SPECIFIC_HEADER, written: SPECIFIC_FRAME_BUFFER}],
|
|
544
|
-
[
|
|
545
|
-
"specific response",
|
|
546
|
-
SPECIFIC_RSP_FRAME,
|
|
547
|
-
{string: SPECIFIC_RSP_FRAME_STRING, header: SPECIFIC_RSP_HEADER, written: SPECIFIC_RSP_FRAME_BUFFER},
|
|
548
|
-
],
|
|
549
|
-
[
|
|
550
|
-
"specific with condition-based parameters",
|
|
551
|
-
SPECIFIC_CONDITION_FRAME,
|
|
552
|
-
{string: SPECIFIC_CONDITION_FRAME_STRING, header: SPECIFIC_CONDITION_HEADER, written: SPECIFIC_CONDITION_FRAME_BUFFER},
|
|
553
|
-
],
|
|
554
|
-
["manufacturer-specific", MANUF_SPE_FRAME, {string: MANUF_SPE_FRAME_STRING, header: MANUF_SPE_HEADER, written: MANUF_SPE_FRAME_BUFFER}],
|
|
555
|
-
])("Writes & Reads frame %s", (_name, frame, expected) => {
|
|
556
|
-
expect(frame).toBeDefined();
|
|
557
|
-
expect(frame.toString()).toStrictEqual(expected.string);
|
|
558
|
-
expect(frame.header).toStrictEqual(expected.header);
|
|
559
|
-
|
|
560
|
-
expect(frame.toBuffer()).toStrictEqual(expected.written);
|
|
561
|
-
expect(Zcl.Frame.fromBuffer(frame.cluster.ID, frame.header, expected.written, {}).toString()).toStrictEqual(expected.string);
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it("Writes & Reads repetitive strategy", () => {
|
|
565
|
-
const expected = [{attrId: 256}, {attrId: 127}];
|
|
566
|
-
const header = new Zcl.Header(
|
|
567
|
-
{
|
|
568
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
569
|
-
manufacturerSpecific: false,
|
|
570
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
571
|
-
disableDefaultResponse: false,
|
|
572
|
-
reservedBits: 0,
|
|
573
|
-
},
|
|
574
|
-
undefined,
|
|
575
|
-
123,
|
|
576
|
-
Zcl.Foundation.read.ID,
|
|
577
|
-
);
|
|
578
|
-
const frame = Zcl.Frame.create(
|
|
579
|
-
header.frameControl.frameType,
|
|
580
|
-
header.frameControl.direction,
|
|
581
|
-
header.frameControl.disableDefaultResponse,
|
|
582
|
-
header.manufacturerCode,
|
|
583
|
-
header.transactionSequenceNumber,
|
|
584
|
-
header.commandIdentifier,
|
|
585
|
-
Zcl.Foundation.read.ID,
|
|
586
|
-
expected /*payload*/,
|
|
587
|
-
{} /*custom clusters*/,
|
|
588
|
-
header.frameControl.reservedBits,
|
|
589
|
-
);
|
|
590
|
-
|
|
591
|
-
expect(frame.payload).toStrictEqual(expected);
|
|
592
|
-
|
|
593
|
-
const buffer = frame.toBuffer();
|
|
594
|
-
const readHeader = Zcl.Header.fromBuffer(buffer)!;
|
|
595
|
-
const readFrame = Zcl.Frame.fromBuffer(0 /*Foundation*/, readHeader, buffer, {} /*custom clusters*/);
|
|
596
|
-
|
|
597
|
-
expect(readFrame.payload).toStrictEqual(expected);
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
it("Writes & Reads flat strategy", () => {
|
|
601
|
-
const expected = {cmdId: 253, statusCode: 127};
|
|
602
|
-
const header = new Zcl.Header(
|
|
603
|
-
{
|
|
604
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
605
|
-
manufacturerSpecific: false,
|
|
606
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
607
|
-
disableDefaultResponse: false,
|
|
608
|
-
reservedBits: 0,
|
|
609
|
-
},
|
|
610
|
-
undefined,
|
|
611
|
-
123,
|
|
612
|
-
Zcl.Foundation.defaultRsp.ID,
|
|
613
|
-
);
|
|
614
|
-
const frame = Zcl.Frame.create(
|
|
615
|
-
header.frameControl.frameType,
|
|
616
|
-
header.frameControl.direction,
|
|
617
|
-
header.frameControl.disableDefaultResponse,
|
|
618
|
-
header.manufacturerCode,
|
|
619
|
-
header.transactionSequenceNumber,
|
|
620
|
-
header.commandIdentifier,
|
|
621
|
-
Zcl.Foundation.defaultRsp.ID,
|
|
622
|
-
expected /*payload*/,
|
|
623
|
-
{} /*custom clusters*/,
|
|
624
|
-
header.frameControl.reservedBits,
|
|
625
|
-
);
|
|
626
|
-
|
|
627
|
-
expect(frame.payload).toStrictEqual(expected);
|
|
628
|
-
|
|
629
|
-
const buffer = frame.toBuffer();
|
|
630
|
-
const readHeader = Zcl.Header.fromBuffer(buffer)!;
|
|
631
|
-
const readFrame = Zcl.Frame.fromBuffer(0 /*Foundation*/, readHeader, buffer, {} /*custom clusters*/);
|
|
632
|
-
|
|
633
|
-
expect(readFrame.payload).toStrictEqual(expected);
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
it("Writes & Reads oneof strategy", () => {
|
|
637
|
-
const expected = {
|
|
638
|
-
discComplete: 123,
|
|
639
|
-
attrInfos: [
|
|
640
|
-
{attrId: 32, dataType: Zcl.DataType.UINT16},
|
|
641
|
-
{attrId: 67, dataType: Zcl.DataType.ARRAY},
|
|
642
|
-
],
|
|
643
|
-
};
|
|
644
|
-
const header = new Zcl.Header(
|
|
645
|
-
{
|
|
646
|
-
frameType: Zcl.FrameType.GLOBAL,
|
|
647
|
-
manufacturerSpecific: false,
|
|
648
|
-
direction: Zcl.Direction.CLIENT_TO_SERVER,
|
|
649
|
-
disableDefaultResponse: false,
|
|
650
|
-
reservedBits: 0,
|
|
651
|
-
},
|
|
652
|
-
undefined,
|
|
653
|
-
123,
|
|
654
|
-
Zcl.Foundation.discoverRsp.ID,
|
|
655
|
-
);
|
|
656
|
-
const frame = Zcl.Frame.create(
|
|
657
|
-
header.frameControl.frameType,
|
|
658
|
-
header.frameControl.direction,
|
|
659
|
-
header.frameControl.disableDefaultResponse,
|
|
660
|
-
header.manufacturerCode,
|
|
661
|
-
header.transactionSequenceNumber,
|
|
662
|
-
header.commandIdentifier,
|
|
663
|
-
Zcl.Foundation.discoverRsp.ID,
|
|
664
|
-
expected /*payload*/,
|
|
665
|
-
{} /*custom clusters*/,
|
|
666
|
-
header.frameControl.reservedBits,
|
|
667
|
-
);
|
|
668
|
-
|
|
669
|
-
expect(frame.payload).toStrictEqual(expected);
|
|
670
|
-
|
|
671
|
-
const buffer = frame.toBuffer();
|
|
672
|
-
const readHeader = Zcl.Header.fromBuffer(buffer)!;
|
|
673
|
-
const readFrame = Zcl.Frame.fromBuffer(0 /*Foundation*/, readHeader, buffer, {} /*custom clusters*/);
|
|
674
|
-
|
|
675
|
-
expect(readFrame.payload).toStrictEqual(expected);
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
it("Throws when writting invalid frame type", () => {
|
|
679
|
-
expect(() => {
|
|
680
|
-
const frame = Zcl.Frame.create(
|
|
681
|
-
// @ts-expect-error invalid on purpose
|
|
682
|
-
3,
|
|
683
|
-
Zcl.Direction.CLIENT_TO_SERVER,
|
|
684
|
-
false,
|
|
685
|
-
null,
|
|
686
|
-
123,
|
|
687
|
-
Zcl.Clusters.genAlarms.commands.reset.ID,
|
|
688
|
-
Zcl.Clusters.genAlarms.ID,
|
|
689
|
-
{} /*payload*/,
|
|
690
|
-
{} /*custom clusters*/,
|
|
691
|
-
0 /*reserved bits*/,
|
|
692
|
-
);
|
|
693
|
-
|
|
694
|
-
frame.toBuffer();
|
|
695
|
-
}).toThrow(`Frametype '3' not valid`);
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
it("Throws when reading invalid frame type", () => {
|
|
699
|
-
expect(() => {
|
|
700
|
-
Zcl.Frame.fromBuffer(
|
|
701
|
-
Zcl.Clusters.genBasic.ID,
|
|
702
|
-
Zcl.Header.fromBuffer(Buffer.from([2, 123, 0]))!,
|
|
703
|
-
Buffer.from([]) /*payload*/,
|
|
704
|
-
{} /*custom clusters*/,
|
|
705
|
-
);
|
|
706
|
-
}).toThrow(`Unsupported frameType '2'`);
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
it("Throws when reading frame without header", () => {
|
|
710
|
-
expect(() => {
|
|
711
|
-
Zcl.Frame.fromBuffer(
|
|
712
|
-
Zcl.Clusters.genBasic.ID,
|
|
713
|
-
// @ts-expect-error invalid of purpose
|
|
714
|
-
null,
|
|
715
|
-
Buffer.from([]) /*payload*/,
|
|
716
|
-
{} /*custom clusters*/,
|
|
717
|
-
);
|
|
718
|
-
}).toThrow("Invalid ZclHeader.");
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
it("Throws when writting missing payload", () => {
|
|
722
|
-
expect(() => {
|
|
723
|
-
const frame = Zcl.Frame.create(
|
|
724
|
-
SPECIFIC_RSP_HEADER.frameControl.frameType,
|
|
725
|
-
SPECIFIC_RSP_HEADER.frameControl.direction,
|
|
726
|
-
SPECIFIC_RSP_HEADER.frameControl.disableDefaultResponse,
|
|
727
|
-
SPECIFIC_RSP_HEADER.manufacturerCode,
|
|
728
|
-
SPECIFIC_RSP_HEADER.transactionSequenceNumber,
|
|
729
|
-
SPECIFIC_RSP_HEADER.commandIdentifier,
|
|
730
|
-
Zcl.Clusters.genAlarms.ID,
|
|
731
|
-
{alarmcode: 246 /*clusterid: 3456*/} /*payload*/,
|
|
732
|
-
{} /*custom clusters*/,
|
|
733
|
-
SPECIFIC_RSP_HEADER.frameControl.reservedBits,
|
|
734
|
-
);
|
|
735
|
-
|
|
736
|
-
frame.toBuffer();
|
|
737
|
-
}).toThrow(`Parameter 'clusterid' is missing`);
|
|
738
|
-
});
|
|
739
|
-
|
|
740
|
-
it("Checks cluster match by name", () => {
|
|
741
|
-
expect(GLOBAL_FRAME.isCluster("genBasic")).toBeTruthy();
|
|
742
|
-
expect(GLOBAL_FRAME.isCluster("discoverCommands")).toBeFalsy();
|
|
743
|
-
// @ts-expect-error invalid on purpose
|
|
744
|
-
expect(GLOBAL_FRAME.isCluster("notacluster")).toBeFalsy();
|
|
745
|
-
expect(SPECIFIC_FRAME.isCluster("genAlarms")).toBeTruthy();
|
|
746
|
-
expect(SPECIFIC_FRAME.isCluster("genAnalogInput")).toBeFalsy();
|
|
747
|
-
// @ts-expect-error invalid on purpose
|
|
748
|
-
expect(SPECIFIC_FRAME.isCluster("notacluster")).toBeFalsy();
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
it("Checks command match by name", () => {
|
|
752
|
-
expect(GLOBAL_FRAME.isCommand("read")).toBeTruthy();
|
|
753
|
-
expect(GLOBAL_FRAME.isCommand("discoverCommands")).toBeFalsy();
|
|
754
|
-
// @ts-expect-error invalid on purpose
|
|
755
|
-
expect(GLOBAL_FRAME.isCommand("notacommand")).toBeFalsy();
|
|
756
|
-
expect(SPECIFIC_FRAME.isCommand("getAlarm")).toBeTruthy();
|
|
757
|
-
expect(SPECIFIC_FRAME.isCommand("enrollReq")).toBeFalsy();
|
|
758
|
-
// @ts-expect-error invalid on purpose
|
|
759
|
-
expect(SPECIFIC_FRAME.isCommand("notacommand")).toBeFalsy();
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
it("[workaround] Reads Foundation char str as Mi struct for Xiaomi attridId=65281", () => {
|
|
763
|
-
const expected = [
|
|
764
|
-
{attrId: 5, dataType: Zcl.DataType.CHAR_STR, attrData: "lumi.sensor_wleak.aq1"},
|
|
765
|
-
{attrId: 65281, dataType: Zcl.DataType.CHAR_STR, attrData: {1: 3285, 3: 33, 4: 5032, 5: 43, 6: 327680, 8: 516, 10: 0, 100: 0}},
|
|
766
|
-
];
|
|
767
|
-
const buffer = Buffer.from([
|
|
768
|
-
28,
|
|
769
|
-
...uint16To8Array(Zcl.ManufacturerCode.LUMI_UNITED_TECHOLOGY_LTD_SHENZHEN),
|
|
770
|
-
3,
|
|
771
|
-
10 /*header*/,
|
|
772
|
-
// regular attr parsing
|
|
773
|
-
5,
|
|
774
|
-
0,
|
|
775
|
-
Zcl.DataType.CHAR_STR,
|
|
776
|
-
21,
|
|
777
|
-
108,
|
|
778
|
-
117,
|
|
779
|
-
109,
|
|
780
|
-
105,
|
|
781
|
-
46,
|
|
782
|
-
115,
|
|
783
|
-
101,
|
|
784
|
-
110,
|
|
785
|
-
115,
|
|
786
|
-
111,
|
|
787
|
-
114,
|
|
788
|
-
95,
|
|
789
|
-
119,
|
|
790
|
-
108,
|
|
791
|
-
101,
|
|
792
|
-
97,
|
|
793
|
-
107,
|
|
794
|
-
46,
|
|
795
|
-
97,
|
|
796
|
-
113,
|
|
797
|
-
49,
|
|
798
|
-
// workaround parsing
|
|
799
|
-
1,
|
|
800
|
-
255,
|
|
801
|
-
Zcl.DataType.CHAR_STR,
|
|
802
|
-
34,
|
|
803
|
-
1,
|
|
804
|
-
Zcl.DataType.UINT16,
|
|
805
|
-
...uint16To8Array(3285),
|
|
806
|
-
3,
|
|
807
|
-
Zcl.DataType.INT8,
|
|
808
|
-
33,
|
|
809
|
-
4,
|
|
810
|
-
Zcl.DataType.UINT16,
|
|
811
|
-
...uint16To8Array(5032),
|
|
812
|
-
5,
|
|
813
|
-
Zcl.DataType.UINT16,
|
|
814
|
-
...uint16To8Array(43),
|
|
815
|
-
6,
|
|
816
|
-
Zcl.DataType.UINT40,
|
|
817
|
-
...uint32To8Array(327680),
|
|
818
|
-
0,
|
|
819
|
-
8,
|
|
820
|
-
Zcl.DataType.UINT16,
|
|
821
|
-
...uint16To8Array(516),
|
|
822
|
-
10,
|
|
823
|
-
Zcl.DataType.UINT16,
|
|
824
|
-
...uint16To8Array(0),
|
|
825
|
-
100,
|
|
826
|
-
Zcl.DataType.BOOLEAN,
|
|
827
|
-
0,
|
|
828
|
-
]);
|
|
829
|
-
const header = Zcl.Header.fromBuffer(buffer)!;
|
|
830
|
-
const frame = Zcl.Frame.fromBuffer(0 /*Foundation*/, header, buffer, {});
|
|
831
|
-
|
|
832
|
-
expect(frame.payload).toStrictEqual(expected);
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
it("[workaround] Reads Foundation struct with extra payload to match zcl-packet", () => {
|
|
836
|
-
const expected = [
|
|
837
|
-
{
|
|
838
|
-
attrId: 65282,
|
|
839
|
-
dataType: Zcl.DataType.STRUCT,
|
|
840
|
-
numElms: 6,
|
|
841
|
-
structElms: [
|
|
842
|
-
{elmType: Zcl.DataType.BOOLEAN, elmVal: 1},
|
|
843
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 3022},
|
|
844
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 17320},
|
|
845
|
-
{elmType: Zcl.DataType.UINT40, elmVal: 1},
|
|
846
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 560},
|
|
847
|
-
{elmType: Zcl.DataType.UINT8, elmVal: 86},
|
|
848
|
-
],
|
|
849
|
-
attrData: [
|
|
850
|
-
{elmType: Zcl.DataType.BOOLEAN, elmVal: 1},
|
|
851
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 3022},
|
|
852
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 17320},
|
|
853
|
-
{elmType: Zcl.DataType.UINT40, elmVal: 1},
|
|
854
|
-
{elmType: Zcl.DataType.UINT16, elmVal: 560},
|
|
855
|
-
{elmType: Zcl.DataType.UINT8, elmVal: 86},
|
|
856
|
-
],
|
|
857
|
-
},
|
|
858
|
-
];
|
|
859
|
-
const buffer = Buffer.from([
|
|
860
|
-
28,
|
|
861
|
-
...uint16To8Array(Zcl.ManufacturerCode.DSR_CORPORATION),
|
|
862
|
-
194,
|
|
863
|
-
10 /*header*/,
|
|
864
|
-
...uint16To8Array(65282),
|
|
865
|
-
Zcl.DataType.STRUCT,
|
|
866
|
-
6,
|
|
867
|
-
0,
|
|
868
|
-
Zcl.DataType.BOOLEAN,
|
|
869
|
-
1,
|
|
870
|
-
Zcl.DataType.UINT16,
|
|
871
|
-
...uint16To8Array(3022),
|
|
872
|
-
Zcl.DataType.UINT16,
|
|
873
|
-
...uint16To8Array(17320),
|
|
874
|
-
Zcl.DataType.UINT40,
|
|
875
|
-
...uint32To8Array(1),
|
|
876
|
-
0,
|
|
877
|
-
Zcl.DataType.UINT16,
|
|
878
|
-
...uint16To8Array(560),
|
|
879
|
-
Zcl.DataType.UINT8,
|
|
880
|
-
86,
|
|
881
|
-
]);
|
|
882
|
-
const header = Zcl.Header.fromBuffer(buffer)!;
|
|
883
|
-
const frame = Zcl.Frame.fromBuffer(0 /*Foundation*/, header, buffer, {});
|
|
884
|
-
|
|
885
|
-
expect(frame.payload).toStrictEqual(expected);
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
it("Reads/writes Touchlink Scan Response with different size payloads", () => {
|
|
889
|
-
const full = Buffer.from([
|
|
890
|
-
0x19, 0x0, 0x1, 0xe0, 0xde, 0x5e, 0x2f, 0xa, 0x5, 0x0, 0x12, 0x0, 0x3d, 0x30, 0x1d, 0x4a, 0x8f, 0xb7, 0xdc, 0x1c, 0x0, 0x4b, 0x12, 0x0,
|
|
891
|
-
0x0, 0xf, 0x62, 0x1a, 0xb3, 0xaa, 0x1, 0x0, 0xb, 0x5e, 0xc0, 0x10, 0x2, 0x2, 0x0,
|
|
892
|
-
]);
|
|
893
|
-
const short = Buffer.from([
|
|
894
|
-
0x19, 0x0, 0x1, 0xe0, 0xde, 0x5e, 0x2f, 0xa, 0x5, 0x0, 0x12, 0x0, 0x3d, 0x30, 0x1d, 0x4a, 0x8f, 0xb7, 0xdc, 0x1c, 0x0, 0x4b, 0x12, 0x0,
|
|
895
|
-
0x0, 0xf, 0x62, 0x1a, 0xb3, 0xaa, 0x0, 0x0,
|
|
896
|
-
]);
|
|
897
|
-
const short2 = Buffer.from([
|
|
898
|
-
0x19, 0x0, 0x1, 0xe0, 0xde, 0x5e, 0x2f, 0xa, 0x5, 0x0, 0x12, 0x0, 0x3d, 0x30, 0x1d, 0x4a, 0x8f, 0xb7, 0xdc, 0x1c, 0x0, 0x4b, 0x12, 0x0,
|
|
899
|
-
0x0, 0xf, 0x62, 0x1a, 0xb3, 0xaa, 0x3, 0x0,
|
|
900
|
-
]);
|
|
901
|
-
|
|
902
|
-
const fullZcl = Zcl.Frame.fromBuffer(0x1000, Zcl.Header.fromBuffer(full), full, {});
|
|
903
|
-
expect(fullZcl.payload.numberOfSubDevices).toStrictEqual(1);
|
|
904
|
-
expect(fullZcl.payload.endpointID).toStrictEqual(11);
|
|
905
|
-
expect(fullZcl.payload.profileID).toStrictEqual(0xc05e);
|
|
906
|
-
expect(fullZcl.payload.deviceID).toStrictEqual(0x0210);
|
|
907
|
-
expect(fullZcl.payload.version).toStrictEqual(0x02);
|
|
908
|
-
expect(fullZcl.payload.groupIDCount).toStrictEqual(0);
|
|
909
|
-
|
|
910
|
-
const shortZcl = Zcl.Frame.fromBuffer(0x1000, Zcl.Header.fromBuffer(short), short, {});
|
|
911
|
-
expect(shortZcl.payload.numberOfSubDevices).toStrictEqual(0);
|
|
912
|
-
expect(shortZcl.payload.endpointID).toStrictEqual(undefined);
|
|
913
|
-
expect(shortZcl.payload.profileID).toStrictEqual(undefined);
|
|
914
|
-
expect(shortZcl.payload.deviceID).toStrictEqual(undefined);
|
|
915
|
-
expect(shortZcl.payload.version).toStrictEqual(undefined);
|
|
916
|
-
expect(shortZcl.payload.groupIDCount).toStrictEqual(undefined);
|
|
917
|
-
|
|
918
|
-
const short2Zcl = Zcl.Frame.fromBuffer(0x1000, Zcl.Header.fromBuffer(short2), short2, {});
|
|
919
|
-
expect(short2Zcl.payload.numberOfSubDevices).toStrictEqual(3);
|
|
920
|
-
expect(short2Zcl.payload.endpointID).toStrictEqual(undefined);
|
|
921
|
-
expect(short2Zcl.payload.profileID).toStrictEqual(undefined);
|
|
922
|
-
expect(short2Zcl.payload.deviceID).toStrictEqual(undefined);
|
|
923
|
-
expect(short2Zcl.payload.version).toStrictEqual(undefined);
|
|
924
|
-
expect(short2Zcl.payload.groupIDCount).toStrictEqual(undefined);
|
|
925
|
-
|
|
926
|
-
const fullNew = fullZcl.toBuffer();
|
|
927
|
-
expect(fullNew).toStrictEqual(full);
|
|
928
|
-
|
|
929
|
-
const shortNew = shortZcl.toBuffer();
|
|
930
|
-
expect(shortNew).toStrictEqual(short);
|
|
931
|
-
|
|
932
|
-
const short2New = short2Zcl.toBuffer();
|
|
933
|
-
expect(short2New).toStrictEqual(short2);
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
it("throws when payload too short to continue reading", () => {
|
|
937
|
-
const b = Buffer.from([1, 3, 3, 0, 33, 16, 18, 0, 255, 69, 81, 0, 62, 0, 0, 0]);
|
|
938
|
-
|
|
939
|
-
expect(() => {
|
|
940
|
-
Zcl.Frame.fromBuffer(Zcl.Clusters.genOta.ID, Zcl.Header.fromBuffer(b), b, {});
|
|
941
|
-
}).toThrow(
|
|
942
|
-
`Cannot parse 'imageBlockRequest:maximumDataSize' (The value of "offset" is out of range. It must be >= 0 and <= 15. Received 16)`,
|
|
943
|
-
);
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
// https://github.com/Koenkk/zigbee2mqtt/issues/28217
|
|
947
|
-
it("[workaround] Reads genOta imageBlockRequest even if minimumBlockPeriod is missing", () => {
|
|
948
|
-
const b = Buffer.from([1, 3, 3, 2, 33, 16, 18, 0, 255, 69, 81, 0, 62, 0, 0, 0, 8]);
|
|
949
|
-
const frame = Zcl.Frame.fromBuffer(Zcl.Clusters.genOta.ID, Zcl.Header.fromBuffer(b), b, {});
|
|
950
|
-
|
|
951
|
-
expect(frame.payload).toStrictEqual({
|
|
952
|
-
fieldControl: 2,
|
|
953
|
-
manufacturerCode: 4129,
|
|
954
|
-
imageType: 18,
|
|
955
|
-
fileVersion: 5326335,
|
|
956
|
-
fileOffset: 62,
|
|
957
|
-
maximumDataSize: 8,
|
|
958
|
-
});
|
|
959
|
-
});
|
|
960
|
-
});
|