zigbee-herdsman 6.0.1 → 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 +16 -0
- package/dist/adapter/ezsp/driver/uart.js +1 -1
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +4 -4
- package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.js +4 -4
- package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +1 -0
- package/dist/controller/model/device.js.map +1 -1
- package/package.json +14 -6
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/dependabot.yml +0 -22
- package/.github/workflows/ci.yml +0 -64
- 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 -1248
- 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/buffalo.test.ts +0 -431
- package/test/controller.bench.ts +0 -193
- 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 -206
- 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 -27
- 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
package/src/zspec/zcl/utils.ts
DELETED
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import {Clusters} from "./definition/cluster";
|
|
2
|
-
import {DataType, DataTypeClass} from "./definition/enums";
|
|
3
|
-
import {Foundation, type FoundationCommandName, type FoundationDefinition} from "./definition/foundation";
|
|
4
|
-
import type {Attribute, Cluster, ClusterDefinition, ClusterName, Command, CustomClusters} from "./definition/tstype";
|
|
5
|
-
|
|
6
|
-
const DATA_TYPE_CLASS_DISCRETE = [
|
|
7
|
-
DataType.DATA8,
|
|
8
|
-
DataType.DATA16,
|
|
9
|
-
DataType.DATA24,
|
|
10
|
-
DataType.DATA32,
|
|
11
|
-
DataType.DATA40,
|
|
12
|
-
DataType.DATA48,
|
|
13
|
-
DataType.DATA56,
|
|
14
|
-
DataType.DATA64,
|
|
15
|
-
DataType.BOOLEAN,
|
|
16
|
-
DataType.BITMAP8,
|
|
17
|
-
DataType.BITMAP16,
|
|
18
|
-
DataType.BITMAP24,
|
|
19
|
-
DataType.BITMAP32,
|
|
20
|
-
DataType.BITMAP40,
|
|
21
|
-
DataType.BITMAP48,
|
|
22
|
-
DataType.BITMAP56,
|
|
23
|
-
DataType.BITMAP64,
|
|
24
|
-
DataType.ENUM8,
|
|
25
|
-
DataType.ENUM16,
|
|
26
|
-
DataType.OCTET_STR,
|
|
27
|
-
DataType.CHAR_STR,
|
|
28
|
-
DataType.LONG_OCTET_STR,
|
|
29
|
-
DataType.LONG_CHAR_STR,
|
|
30
|
-
DataType.ARRAY,
|
|
31
|
-
DataType.STRUCT,
|
|
32
|
-
DataType.SET,
|
|
33
|
-
DataType.BAG,
|
|
34
|
-
DataType.CLUSTER_ID,
|
|
35
|
-
DataType.ATTR_ID,
|
|
36
|
-
DataType.BAC_OID,
|
|
37
|
-
DataType.IEEE_ADDR,
|
|
38
|
-
DataType.SEC_KEY,
|
|
39
|
-
];
|
|
40
|
-
const DATA_TYPE_CLASS_ANALOG = [
|
|
41
|
-
DataType.UINT8,
|
|
42
|
-
DataType.UINT16,
|
|
43
|
-
DataType.UINT24,
|
|
44
|
-
DataType.UINT32,
|
|
45
|
-
DataType.UINT40,
|
|
46
|
-
DataType.UINT48,
|
|
47
|
-
DataType.UINT56,
|
|
48
|
-
DataType.INT8,
|
|
49
|
-
DataType.INT16,
|
|
50
|
-
DataType.INT24,
|
|
51
|
-
DataType.INT32,
|
|
52
|
-
DataType.INT40,
|
|
53
|
-
DataType.INT48,
|
|
54
|
-
DataType.INT56,
|
|
55
|
-
DataType.SEMI_PREC,
|
|
56
|
-
DataType.SINGLE_PREC,
|
|
57
|
-
DataType.DOUBLE_PREC,
|
|
58
|
-
DataType.TOD,
|
|
59
|
-
DataType.DATE,
|
|
60
|
-
DataType.UTC,
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
const FOUNDATION_DISCOVER_RSP_IDS = [
|
|
64
|
-
Foundation.discoverRsp.ID,
|
|
65
|
-
Foundation.discoverCommandsRsp.ID,
|
|
66
|
-
Foundation.discoverCommandsGenRsp.ID,
|
|
67
|
-
Foundation.discoverExtRsp.ID,
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
export function getDataTypeClass(dataType: DataType): DataTypeClass {
|
|
71
|
-
if (DATA_TYPE_CLASS_DISCRETE.includes(dataType)) {
|
|
72
|
-
return DataTypeClass.DISCRETE;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (DATA_TYPE_CLASS_ANALOG.includes(dataType)) {
|
|
76
|
-
return DataTypeClass.ANALOG;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
throw new Error(`Don't know value type for '${DataType[dataType]}'`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function hasCustomClusters(customClusters: CustomClusters): boolean {
|
|
83
|
-
// XXX: was there a good reason to not set the parameter `customClusters` optional? it would allow simple undefined check
|
|
84
|
-
// below is twice faster than checking `Object.keys(customClusters).length`
|
|
85
|
-
for (const _k in customClusters) return true;
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function findClusterNameByID(
|
|
90
|
-
id: number,
|
|
91
|
-
manufacturerCode: number | undefined,
|
|
92
|
-
clusters: CustomClusters,
|
|
93
|
-
): [name: string | undefined, partialMatch: boolean] {
|
|
94
|
-
let name: string | undefined;
|
|
95
|
-
// if manufacturer code is given, consider partial match if didn't match against manufacturer code
|
|
96
|
-
let partialMatch = Boolean(manufacturerCode);
|
|
97
|
-
|
|
98
|
-
for (const clusterName in clusters) {
|
|
99
|
-
const cluster = clusters[clusterName as ClusterName];
|
|
100
|
-
|
|
101
|
-
if (cluster.ID === id) {
|
|
102
|
-
// priority on first match when matching only ID
|
|
103
|
-
if (name === undefined) {
|
|
104
|
-
name = clusterName;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (manufacturerCode && cluster.manufacturerCode === manufacturerCode) {
|
|
108
|
-
name = clusterName;
|
|
109
|
-
partialMatch = false;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!cluster.manufacturerCode) {
|
|
114
|
-
name = clusterName;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return [name, partialMatch];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function getClusterDefinition(
|
|
124
|
-
key: string | number,
|
|
125
|
-
manufacturerCode: number | undefined,
|
|
126
|
-
customClusters: CustomClusters,
|
|
127
|
-
): {name: string; cluster: ClusterDefinition} {
|
|
128
|
-
let name: string | undefined;
|
|
129
|
-
|
|
130
|
-
if (typeof key === "number") {
|
|
131
|
-
let partialMatch: boolean;
|
|
132
|
-
|
|
133
|
-
// custom clusters have priority over Zcl clusters, except in case of better match (see below)
|
|
134
|
-
[name, partialMatch] = findClusterNameByID(key, manufacturerCode, customClusters);
|
|
135
|
-
|
|
136
|
-
if (!name) {
|
|
137
|
-
[name, partialMatch] = findClusterNameByID(key, manufacturerCode, Clusters);
|
|
138
|
-
} else if (partialMatch) {
|
|
139
|
-
let zclName: string | undefined;
|
|
140
|
-
[zclName, partialMatch] = findClusterNameByID(key, manufacturerCode, Clusters);
|
|
141
|
-
|
|
142
|
-
// Zcl clusters contain a better match, use that one
|
|
143
|
-
if (zclName !== undefined && !partialMatch) {
|
|
144
|
-
name = zclName;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
name = key;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let cluster =
|
|
152
|
-
name !== undefined && hasCustomClusters(customClusters)
|
|
153
|
-
? {
|
|
154
|
-
...Clusters[name as ClusterName],
|
|
155
|
-
...customClusters[name], // should override Zcl clusters
|
|
156
|
-
}
|
|
157
|
-
: Clusters[name as ClusterName];
|
|
158
|
-
|
|
159
|
-
if (!cluster || cluster.ID === undefined) {
|
|
160
|
-
if (typeof key === "number") {
|
|
161
|
-
name = key.toString();
|
|
162
|
-
cluster = {attributes: {}, commands: {}, commandsResponse: {}, manufacturerCode: undefined, ID: key};
|
|
163
|
-
} else {
|
|
164
|
-
name = undefined;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (!name) {
|
|
169
|
-
throw new Error(`Cluster with name '${key}' does not exist`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {name, cluster};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function cloneClusterEntriesWithName<T extends Record<string, unknown>>(entries: Record<string, T>): Record<string, {name: string} & T> {
|
|
176
|
-
const clone: Record<string, {name: string} & T> = {};
|
|
177
|
-
|
|
178
|
-
for (const key in entries) {
|
|
179
|
-
clone[key] = {...entries[key], name: key};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return clone;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function createCluster(name: string, cluster: ClusterDefinition, manufacturerCode?: number): Cluster {
|
|
186
|
-
const attributes: Record<string, Attribute> = cloneClusterEntriesWithName(cluster.attributes);
|
|
187
|
-
const commands: Record<string, Command> = cloneClusterEntriesWithName(cluster.commands);
|
|
188
|
-
const commandsResponse: Record<string, Command> = cloneClusterEntriesWithName(cluster.commandsResponse);
|
|
189
|
-
|
|
190
|
-
const getAttribute = (key: number | string): Attribute | undefined => {
|
|
191
|
-
if (typeof key === "number") {
|
|
192
|
-
let partialMatchAttr: Attribute | undefined;
|
|
193
|
-
|
|
194
|
-
for (const attrKey in attributes) {
|
|
195
|
-
const attr = attributes[attrKey];
|
|
196
|
-
|
|
197
|
-
if (attr.ID === key) {
|
|
198
|
-
if (manufacturerCode && attr.manufacturerCode === manufacturerCode) {
|
|
199
|
-
return attr;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (attr.manufacturerCode === undefined) {
|
|
203
|
-
partialMatchAttr = attr;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return partialMatchAttr;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return attributes[key];
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const getCommand = (key: number | string): Command => {
|
|
215
|
-
if (typeof key === "number") {
|
|
216
|
-
for (const cmdKey in commands) {
|
|
217
|
-
const cmd = commands[cmdKey];
|
|
218
|
-
|
|
219
|
-
if (cmd.ID === key) {
|
|
220
|
-
return cmd;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
const cmd = commands[key];
|
|
225
|
-
|
|
226
|
-
if (cmd) {
|
|
227
|
-
return cmd;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
throw new Error(`Cluster '${name}' has no command '${key}'`);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const getCommandResponse = (key: number | string): Command => {
|
|
235
|
-
if (typeof key === "number") {
|
|
236
|
-
for (const cmdKey in commandsResponse) {
|
|
237
|
-
const cmd = commandsResponse[cmdKey];
|
|
238
|
-
|
|
239
|
-
if (cmd.ID === key) {
|
|
240
|
-
return cmd;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} else {
|
|
244
|
-
const cmd = commandsResponse[key];
|
|
245
|
-
|
|
246
|
-
if (cmd) {
|
|
247
|
-
return cmd;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
throw new Error(`Cluster '${name}' has no command response '${key}'`);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
return {
|
|
255
|
-
ID: cluster.ID,
|
|
256
|
-
attributes,
|
|
257
|
-
manufacturerCode: cluster.manufacturerCode,
|
|
258
|
-
name,
|
|
259
|
-
commands,
|
|
260
|
-
commandsResponse,
|
|
261
|
-
getAttribute,
|
|
262
|
-
getCommand,
|
|
263
|
-
getCommandResponse,
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export function getCluster(key: string | number, manufacturerCode: number | undefined = undefined, customClusters: CustomClusters = {}): Cluster {
|
|
268
|
-
const {name, cluster} = getClusterDefinition(key, manufacturerCode, customClusters);
|
|
269
|
-
return createCluster(name, cluster, manufacturerCode);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function getGlobalCommandNameById(id: number): FoundationCommandName {
|
|
273
|
-
for (const commandName in Foundation) {
|
|
274
|
-
if (Foundation[commandName as FoundationCommandName].ID === id) {
|
|
275
|
-
return commandName as FoundationCommandName;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
throw new Error(`Global command with id '${id}' does not exist.`);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function getGlobalCommand(key: number | string): Command {
|
|
283
|
-
const name = typeof key === "number" ? getGlobalCommandNameById(key) : (key as FoundationCommandName);
|
|
284
|
-
const command = Foundation[name];
|
|
285
|
-
|
|
286
|
-
if (!command) {
|
|
287
|
-
throw new Error(`Global command with key '${key}' does not exist`);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const result: Command = {
|
|
291
|
-
ID: command.ID,
|
|
292
|
-
name,
|
|
293
|
-
parameters: command.parameters,
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
if (command.response !== undefined) {
|
|
297
|
-
result.response = command.response;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return result;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export function isClusterName(name: string): name is ClusterName {
|
|
304
|
-
return name in Clusters;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function getFoundationCommand(id: number): FoundationDefinition {
|
|
308
|
-
for (const commandName in Foundation) {
|
|
309
|
-
const command = Foundation[commandName as FoundationCommandName];
|
|
310
|
-
|
|
311
|
-
if (command.ID === id) {
|
|
312
|
-
return command;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
throw new Error(`Foundation command '${id}' does not exist.`);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export function isFoundationDiscoverRsp(id: number): boolean {
|
|
320
|
-
return FOUNDATION_DISCOVER_RSP_IDS.includes(id);
|
|
321
|
-
}
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import "../../utils/patchBigIntSerialization";
|
|
2
|
-
|
|
3
|
-
import {BuffaloZcl} from "./buffaloZcl";
|
|
4
|
-
import {BuffaloZclDataType, DataType, Direction, FrameType, ParameterCondition} from "./definition/enums";
|
|
5
|
-
import type {FoundationCommandName} from "./definition/foundation";
|
|
6
|
-
import type {BuffaloZclOptions, Cluster, ClusterName, Command, CustomClusters, ParameterDefinition} from "./definition/tstype";
|
|
7
|
-
import * as Utils from "./utils";
|
|
8
|
-
import {ZclHeader} from "./zclHeader";
|
|
9
|
-
|
|
10
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
11
|
-
type ZclPayload = any;
|
|
12
|
-
|
|
13
|
-
const ListTypes: number[] = [
|
|
14
|
-
BuffaloZclDataType.LIST_UINT8,
|
|
15
|
-
BuffaloZclDataType.LIST_UINT16,
|
|
16
|
-
BuffaloZclDataType.LIST_UINT24,
|
|
17
|
-
BuffaloZclDataType.LIST_UINT32,
|
|
18
|
-
BuffaloZclDataType.LIST_ZONEINFO,
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
export class ZclFrame {
|
|
22
|
-
public readonly header: ZclHeader;
|
|
23
|
-
public readonly payload: ZclPayload;
|
|
24
|
-
public readonly cluster: Cluster;
|
|
25
|
-
public readonly command: Command;
|
|
26
|
-
|
|
27
|
-
private constructor(header: ZclHeader, payload: ZclPayload, cluster: Cluster, command: Command) {
|
|
28
|
-
this.header = header;
|
|
29
|
-
this.payload = payload;
|
|
30
|
-
this.cluster = cluster;
|
|
31
|
-
this.command = command;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public toString(): string {
|
|
35
|
-
return JSON.stringify({header: this.header, payload: this.payload, command: this.command});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creating
|
|
40
|
-
*/
|
|
41
|
-
public static create(
|
|
42
|
-
frameType: FrameType,
|
|
43
|
-
direction: Direction,
|
|
44
|
-
disableDefaultResponse: boolean,
|
|
45
|
-
manufacturerCode: number | undefined,
|
|
46
|
-
transactionSequenceNumber: number,
|
|
47
|
-
commandKey: number | string | Command,
|
|
48
|
-
clusterKey: number | string | Cluster,
|
|
49
|
-
payload: ZclPayload,
|
|
50
|
-
customClusters: CustomClusters,
|
|
51
|
-
reservedBits = 0,
|
|
52
|
-
): ZclFrame {
|
|
53
|
-
const cluster = typeof clusterKey === "object" ? clusterKey : Utils.getCluster(clusterKey, manufacturerCode, customClusters);
|
|
54
|
-
const command: Command =
|
|
55
|
-
typeof commandKey === "object"
|
|
56
|
-
? commandKey
|
|
57
|
-
: frameType === FrameType.GLOBAL
|
|
58
|
-
? Utils.getGlobalCommand(commandKey)
|
|
59
|
-
: direction === Direction.CLIENT_TO_SERVER
|
|
60
|
-
? cluster.getCommand(commandKey)
|
|
61
|
-
: cluster.getCommandResponse(commandKey);
|
|
62
|
-
|
|
63
|
-
const header = new ZclHeader(
|
|
64
|
-
{reservedBits, frameType, direction, disableDefaultResponse, manufacturerSpecific: manufacturerCode != null},
|
|
65
|
-
manufacturerCode,
|
|
66
|
-
transactionSequenceNumber,
|
|
67
|
-
command.ID,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return new ZclFrame(header, payload, cluster, command);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public toBuffer(): Buffer {
|
|
74
|
-
const buffalo = new BuffaloZcl(Buffer.alloc(250));
|
|
75
|
-
this.header.write(buffalo);
|
|
76
|
-
|
|
77
|
-
if (this.header.isGlobal) {
|
|
78
|
-
this.writePayloadGlobal(buffalo);
|
|
79
|
-
} else if (this.header.isSpecific) {
|
|
80
|
-
this.writePayloadCluster(buffalo);
|
|
81
|
-
} else {
|
|
82
|
-
throw new Error(`Frametype '${this.header.frameControl.frameType}' not valid`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return buffalo.getWritten();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private writePayloadGlobal(buffalo: BuffaloZcl): void {
|
|
89
|
-
const command = Utils.getFoundationCommand(this.command.ID);
|
|
90
|
-
|
|
91
|
-
if (command.parseStrategy === "repetitive") {
|
|
92
|
-
for (const entry of this.payload) {
|
|
93
|
-
for (const parameter of command.parameters) {
|
|
94
|
-
const options: BuffaloZclOptions = {};
|
|
95
|
-
|
|
96
|
-
if (!ZclFrame.conditionsValid(parameter, entry, undefined)) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (parameter.type === BuffaloZclDataType.USE_DATA_TYPE && typeof entry.dataType === "number") {
|
|
101
|
-
// We need to grab the dataType to parse useDataType
|
|
102
|
-
options.dataType = entry.dataType;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
buffalo.write(parameter.type, entry[parameter.name], options);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} else if (command.parseStrategy === "flat") {
|
|
109
|
-
for (const parameter of command.parameters) {
|
|
110
|
-
buffalo.write(parameter.type, this.payload[parameter.name], {});
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
if (command.parseStrategy === "oneof") {
|
|
114
|
-
if (Utils.isFoundationDiscoverRsp(command.ID)) {
|
|
115
|
-
buffalo.writeUInt8(this.payload.discComplete);
|
|
116
|
-
|
|
117
|
-
for (const entry of this.payload.attrInfos) {
|
|
118
|
-
for (const parameter of command.parameters) {
|
|
119
|
-
buffalo.write(parameter.type, entry[parameter.name], {});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private writePayloadCluster(buffalo: BuffaloZcl): void {
|
|
128
|
-
for (const parameter of this.command.parameters) {
|
|
129
|
-
if (!ZclFrame.conditionsValid(parameter, this.payload, undefined)) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// TODO: biome migration - safer
|
|
134
|
-
if (this.payload[parameter.name] == null) {
|
|
135
|
-
throw new Error(`Parameter '${parameter.name}' is missing`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
buffalo.write(parameter.type, this.payload[parameter.name], {});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Parsing
|
|
144
|
-
*/
|
|
145
|
-
public static fromBuffer(clusterID: number, header: ZclHeader | undefined, buffer: Buffer, customClusters: CustomClusters): ZclFrame {
|
|
146
|
-
if (!header) {
|
|
147
|
-
throw new Error("Invalid ZclHeader.");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const buffalo = new BuffaloZcl(buffer, header.length);
|
|
151
|
-
const cluster = Utils.getCluster(clusterID, header.manufacturerCode, customClusters);
|
|
152
|
-
const command: Command = header.isGlobal
|
|
153
|
-
? Utils.getGlobalCommand(header.commandIdentifier)
|
|
154
|
-
: header.frameControl.direction === Direction.CLIENT_TO_SERVER
|
|
155
|
-
? cluster.getCommand(header.commandIdentifier)
|
|
156
|
-
: cluster.getCommandResponse(header.commandIdentifier);
|
|
157
|
-
const payload = ZclFrame.parsePayload(header, cluster, buffalo);
|
|
158
|
-
|
|
159
|
-
return new ZclFrame(header, payload, cluster, command);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private static parsePayload(header: ZclHeader, cluster: Cluster, buffalo: BuffaloZcl): ZclPayload {
|
|
163
|
-
if (header.isGlobal) {
|
|
164
|
-
return ZclFrame.parsePayloadGlobal(header, buffalo);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (header.isSpecific) {
|
|
168
|
-
return ZclFrame.parsePayloadCluster(header, cluster, buffalo);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
throw new Error(`Unsupported frameType '${header.frameControl.frameType}'`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private static parsePayloadCluster(header: ZclHeader, cluster: Cluster, buffalo: BuffaloZcl): ZclPayload {
|
|
175
|
-
const command =
|
|
176
|
-
header.frameControl.direction === Direction.CLIENT_TO_SERVER
|
|
177
|
-
? cluster.getCommand(header.commandIdentifier)
|
|
178
|
-
: cluster.getCommandResponse(header.commandIdentifier);
|
|
179
|
-
const payload: ZclPayload = {};
|
|
180
|
-
|
|
181
|
-
for (const parameter of command.parameters) {
|
|
182
|
-
const options: BuffaloZclOptions = {payload};
|
|
183
|
-
|
|
184
|
-
if (!ZclFrame.conditionsValid(parameter, payload, buffalo.getBuffer().length - buffalo.getPosition())) {
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (ListTypes.includes(parameter.type)) {
|
|
189
|
-
const lengthParameter = command.parameters[command.parameters.indexOf(parameter) - 1];
|
|
190
|
-
const length = payload[lengthParameter.name];
|
|
191
|
-
|
|
192
|
-
if (typeof length === "number") {
|
|
193
|
-
options.length = length;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
try {
|
|
198
|
-
payload[parameter.name] = buffalo.read(parameter.type, options);
|
|
199
|
-
} catch (error) {
|
|
200
|
-
throw new Error(`Cannot parse '${command.name}:${parameter.name}' (${(error as Error).message})`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return payload;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private static parsePayloadGlobal(header: ZclHeader, buffalo: BuffaloZcl): ZclPayload {
|
|
208
|
-
const command = Utils.getFoundationCommand(header.commandIdentifier);
|
|
209
|
-
|
|
210
|
-
if (command.parseStrategy === "repetitive") {
|
|
211
|
-
const payload = [];
|
|
212
|
-
|
|
213
|
-
while (buffalo.isMore()) {
|
|
214
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
215
|
-
const entry: {[s: string]: any} = {};
|
|
216
|
-
|
|
217
|
-
for (const parameter of command.parameters) {
|
|
218
|
-
const options: BuffaloZclOptions = {};
|
|
219
|
-
|
|
220
|
-
if (!ZclFrame.conditionsValid(parameter, entry, buffalo.getBuffer().length - buffalo.getPosition())) {
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (parameter.type === BuffaloZclDataType.USE_DATA_TYPE && typeof entry.dataType === "number") {
|
|
225
|
-
// We need to grab the dataType to parse useDataType
|
|
226
|
-
options.dataType = entry.dataType;
|
|
227
|
-
|
|
228
|
-
if (entry.dataType === DataType.CHAR_STR && entry.attrId === 65281) {
|
|
229
|
-
// [workaround] parse char str as Xiaomi struct
|
|
230
|
-
options.dataType = BuffaloZclDataType.MI_STRUCT;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
entry[parameter.name] = buffalo.read(parameter.type, options);
|
|
235
|
-
|
|
236
|
-
// TODO: not needed, but temp workaroudn to make payload equal to that of zcl-packet
|
|
237
|
-
// XXX: is this still needed?
|
|
238
|
-
if (parameter.type === BuffaloZclDataType.USE_DATA_TYPE && entry.dataType === DataType.STRUCT) {
|
|
239
|
-
entry.structElms = entry.attrData;
|
|
240
|
-
entry.numElms = entry.attrData.length;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
payload.push(entry);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return payload;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (command.parseStrategy === "flat") {
|
|
251
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
252
|
-
const payload: {[s: string]: any} = {};
|
|
253
|
-
|
|
254
|
-
for (const parameter of command.parameters) {
|
|
255
|
-
payload[parameter.name] = buffalo.read(parameter.type, {});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return payload;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (command.parseStrategy === "oneof") {
|
|
262
|
-
if (Utils.isFoundationDiscoverRsp(command.ID)) {
|
|
263
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
264
|
-
const payload: {discComplete: number; attrInfos: {[k: string]: any}[]} = {
|
|
265
|
-
discComplete: buffalo.readUInt8(),
|
|
266
|
-
attrInfos: [],
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
while (buffalo.isMore()) {
|
|
270
|
-
const entry: (typeof payload.attrInfos)[number] = {};
|
|
271
|
-
|
|
272
|
-
for (const parameter of command.parameters) {
|
|
273
|
-
entry[parameter.name] = buffalo.read(parameter.type, {});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
payload.attrInfos.push(entry);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return payload;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Utils
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
public static conditionsValid(parameter: ParameterDefinition, entry: ZclPayload, remainingBufferBytes: number | undefined): boolean {
|
|
289
|
-
if (parameter.conditions) {
|
|
290
|
-
for (const condition of parameter.conditions) {
|
|
291
|
-
switch (condition.type) {
|
|
292
|
-
case ParameterCondition.FIELD_EQUAL: {
|
|
293
|
-
if (condition.reversed) {
|
|
294
|
-
if (entry[condition.field] === condition.value) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
} else if (entry[condition.field] !== condition.value) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
case ParameterCondition.BITMASK_SET: {
|
|
303
|
-
if (condition.reversed) {
|
|
304
|
-
if ((entry[condition.param] & condition.mask) === condition.mask) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
} else if ((entry[condition.param] & condition.mask) !== condition.mask) {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
case ParameterCondition.BITFIELD_ENUM: {
|
|
313
|
-
if (((entry[condition.param] >> condition.offset) & ((1 << condition.size) - 1)) !== condition.value) {
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case ParameterCondition.MINIMUM_REMAINING_BUFFER_BYTES: {
|
|
319
|
-
if (remainingBufferBytes !== undefined && remainingBufferBytes < condition.value) {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
case ParameterCondition.DATA_TYPE_CLASS_EQUAL: {
|
|
325
|
-
if (Utils.getDataTypeClass(entry.dataType) !== condition.value) {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
case ParameterCondition.FIELD_GT: {
|
|
331
|
-
/*if (condition.reversed) {
|
|
332
|
-
if (entry[condition.field] >= condition.value) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
} else */
|
|
336
|
-
if (entry[condition.field] <= condition.value) {
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
public isCluster(clusterName: FoundationCommandName | ClusterName): boolean {
|
|
349
|
-
return this.cluster.name === clusterName;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// List of commands is not completed, feel free to add more.
|
|
353
|
-
public isCommand(commandName: FoundationCommandName | "remove" | "add" | "write" | "enrollReq" | "checkin" | "getAlarm" | "arm"): boolean {
|
|
354
|
-
return this.command.name === commandName;
|
|
355
|
-
}
|
|
356
|
-
}
|