zigbee-herdsman 6.0.2 → 6.0.4
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 +14 -0
- package/package.json +9 -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,360 +0,0 @@
|
|
|
1
|
-
export enum StatusCategory {
|
|
2
|
-
GENERIC = 0,
|
|
3
|
-
MAC = 2,
|
|
4
|
-
NWK = 3,
|
|
5
|
-
APS = 4,
|
|
6
|
-
ZDO = 5,
|
|
7
|
-
CBKE = 6,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export enum StatusCodeGeneric {
|
|
11
|
-
OK = 0,
|
|
12
|
-
ERROR = 1,
|
|
13
|
-
BLOCKED = 2,
|
|
14
|
-
EXIT = 3,
|
|
15
|
-
BUSY = 4,
|
|
16
|
-
EOF = 5,
|
|
17
|
-
OUT_OF_RANGE = 6,
|
|
18
|
-
EMPTY = 7,
|
|
19
|
-
CANCELLED = 8,
|
|
20
|
-
INVALID_PARAMETER_1 = 10,
|
|
21
|
-
INVALID_PARAMETER_2 = 11,
|
|
22
|
-
INVALID_PARAMETER_3 = 12,
|
|
23
|
-
INVALID_PARAMETER_4 = 13,
|
|
24
|
-
INVALID_PARAMETER_5 = 14,
|
|
25
|
-
INVALID_PARAMETER_6 = 15,
|
|
26
|
-
INVALID_PARAMETER_7 = 16,
|
|
27
|
-
INVALID_PARAMETER_8 = 17,
|
|
28
|
-
INVALID_PARAMETER_9 = 18,
|
|
29
|
-
INVALID_PARAMETER_10 = 19,
|
|
30
|
-
INVALID_PARAMETER_11_OR_MORE = 20,
|
|
31
|
-
PENDING = 21,
|
|
32
|
-
NO_MEMORY = 22,
|
|
33
|
-
INVALID_PARAMETER = 23,
|
|
34
|
-
OPERATION_FAILED = 24,
|
|
35
|
-
BUFFER_TOO_SMALL = 25,
|
|
36
|
-
END_OF_LIST = 26,
|
|
37
|
-
ALREADY_EXISTS = 27,
|
|
38
|
-
NOT_FOUND = 28,
|
|
39
|
-
OVERFLOW = 29,
|
|
40
|
-
TIMEOUT = 30,
|
|
41
|
-
NOT_IMPLEMENTED = 31,
|
|
42
|
-
NO_RESOURCES = 32,
|
|
43
|
-
UNINITIALIZED = 33,
|
|
44
|
-
NO_SERVER = 34,
|
|
45
|
-
INVALID_STATE = 35,
|
|
46
|
-
CONNECTION_FAILED = 37,
|
|
47
|
-
CONNECTION_LOST = 38,
|
|
48
|
-
UNAUTHORIZED = 40,
|
|
49
|
-
CONFLICT = 41,
|
|
50
|
-
INVALID_FORMAT = 42,
|
|
51
|
-
NO_MATCH = 43,
|
|
52
|
-
PROTOCOL_ERROR = 44,
|
|
53
|
-
VERSION = 45,
|
|
54
|
-
MALFORMED_ADDRESS = 46,
|
|
55
|
-
COULD_NOT_READ_FILE = 47,
|
|
56
|
-
FILE_NOT_FOUND = 48,
|
|
57
|
-
DIRECTORY_NOT_FOUND = 49,
|
|
58
|
-
CONVERSION_ERROR = 50,
|
|
59
|
-
INCOMPATIBLE_TYPES = 51,
|
|
60
|
-
FILE_CORRUPTED = 56,
|
|
61
|
-
PAGE_NOT_FOUND = 57,
|
|
62
|
-
ILLEGAL_REQUEST = 62,
|
|
63
|
-
INVALID_GROUP = 64,
|
|
64
|
-
TABLE_FULL = 65,
|
|
65
|
-
IGNORE = 69,
|
|
66
|
-
AGAIN = 70,
|
|
67
|
-
DEVICE_NOT_FOUND = 71,
|
|
68
|
-
OBSOLETE = 72,
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export enum StatusCodeAPS {
|
|
72
|
-
// A request has been executed successfully.
|
|
73
|
-
SUCCESS = 0x00,
|
|
74
|
-
// A transmit request failed since the ASDU is too large and fragmentation is not supported.
|
|
75
|
-
ASDU_TOO_LONG = 0xa0,
|
|
76
|
-
// A received fragmented frame could not be defragmented at the current time.
|
|
77
|
-
DEFRAG_DEFERRED = 0xa1,
|
|
78
|
-
// A received fragmented frame could not be defragmented since the device does not support fragmentation.
|
|
79
|
-
DEFRAG_UNSUPPORTED = 0xa2,
|
|
80
|
-
// A parameter value was out of range.
|
|
81
|
-
ILLEGAL_REQUEST = 0xa3,
|
|
82
|
-
// An APSME-UNBIND.request failed due to the requested binding link not existing in the binding table.
|
|
83
|
-
INVALID_BINDING = 0xa4,
|
|
84
|
-
// An APSME-REMOVE-GROUP.request has been issued with a group identifier that does not appear in the group table.
|
|
85
|
-
INVALID_GROUP = 0xa5,
|
|
86
|
-
// A parameter value was invalid or out of range.
|
|
87
|
-
INVALID_PARAMETER = 0xa6,
|
|
88
|
-
// An APSDE-DATA.request requesting acknowledged trans- mission failed due to no acknowledgement being received.
|
|
89
|
-
NO_ACK = 0xa7,
|
|
90
|
-
// An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to there being no devices bound to this device.
|
|
91
|
-
NO_BOUND_DEVICE = 0xa8,
|
|
92
|
-
// An APSDE-DATA.request with a destination addressing mode set to 0x03 failed due to no corresponding short address found in the address map table.
|
|
93
|
-
NO_SHORT_ADDRESS = 0xa9,
|
|
94
|
-
// An APSDE-DATA.request with a destination addressing mode set to 0x00 failed due to a binding table not being supported on the device.
|
|
95
|
-
NOT_SUPPORTED = 0xaa,
|
|
96
|
-
// An ASDU was received that was secured using a link key.
|
|
97
|
-
SECURED_LINK_KEY = 0xab,
|
|
98
|
-
// An ASDU was received that was secured using a network key.
|
|
99
|
-
SECURED_NWK_KEY = 0xac,
|
|
100
|
-
// An APSDE-DATA.request requesting security has resulted in an error during the corresponding security processing.
|
|
101
|
-
SECURITY_FAIL = 0xad,
|
|
102
|
-
// An APSME-BIND.request or APSME.ADD-GROUP.request issued when the binding or group tables, respectively, were full.
|
|
103
|
-
TABLE_FULL = 0xae,
|
|
104
|
-
// An ASDU was received without any security.
|
|
105
|
-
UNSECURED = 0xaf,
|
|
106
|
-
// An APSME-GET.request or APSME-SET.request has been issued with an unknown attribute identifier.
|
|
107
|
-
UNSUPPORTED_ATTRIBUTE = 0xb0,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export enum StatusCodeCBKE {
|
|
111
|
-
// The Issuer field within the key establishment partner's certificate is unknown to the sending device
|
|
112
|
-
UNKNOWN_ISSUER = 1,
|
|
113
|
-
// The device could not confirm that it shares the same key with the corresponding device
|
|
114
|
-
BAD_KEY_CONFIRM = 2,
|
|
115
|
-
// The device received a bad message from the corresponding device
|
|
116
|
-
BAD_MESSAGE = 3,
|
|
117
|
-
// The device does not currently have the internal resources necessary to perform key establishment
|
|
118
|
-
NO_RESOURCES = 4,
|
|
119
|
-
// The device does not support the specified key establishment suite in the partner's Initiate Key Establishment message
|
|
120
|
-
UNSUPPORTED_SUITE = 5,
|
|
121
|
-
// The received certificate specifies a type, curve, hash, or other parameter that is either unsupported by the device or invalid
|
|
122
|
-
INVALID_CERTIFICATE = 6,
|
|
123
|
-
// Non-standard ZBOSS extension: SE KE endpoint not found
|
|
124
|
-
NO_KE_EP = 7,
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Enum of the network state
|
|
129
|
-
*/
|
|
130
|
-
export enum NetworkState {
|
|
131
|
-
OFFLINE = 0x00 /*!< The network is offline */,
|
|
132
|
-
JOINING = 0x01 /*!< Joinging the network */,
|
|
133
|
-
CONNECTED = 0x02 /*!< Conneted with the network */,
|
|
134
|
-
LEAVING = 0x03 /*!< Leaving the network */,
|
|
135
|
-
CONFIRM = 0x04 /*!< Confirm the APS */,
|
|
136
|
-
INDICATION = 0x05 /*!< Indication the APS */,
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Enum of the network security mode
|
|
141
|
-
*/
|
|
142
|
-
export enum EspNCPSecur {
|
|
143
|
-
ESP_NCP_NO_SECURITY = 0x00 /*!< The network is no security mode */,
|
|
144
|
-
ESP_NCP_PRECONFIGURED_NETWORK_KEY = 0x01 /*!< Pre-configured the network key */,
|
|
145
|
-
ESP_NCP_NETWORK_KEY_FROM_TC = 0x02,
|
|
146
|
-
ESP_NCP_ONLY_TCLK = 0x03,
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export enum DeviceType {
|
|
150
|
-
COORDINATOR = 0x00,
|
|
151
|
-
ROUTER = 0x01,
|
|
152
|
-
ED = 0x02,
|
|
153
|
-
NONE = 0x03,
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export enum CommandId {
|
|
157
|
-
// NCP config
|
|
158
|
-
GET_MODULE_VERSION = 0x0001,
|
|
159
|
-
NCP_RESET = 0x0002,
|
|
160
|
-
GET_ZIGBEE_ROLE = 0x0004,
|
|
161
|
-
SET_ZIGBEE_ROLE = 0x0005,
|
|
162
|
-
GET_ZIGBEE_CHANNEL_MASK = 0x0006,
|
|
163
|
-
SET_ZIGBEE_CHANNEL_MASK = 0x0007,
|
|
164
|
-
GET_ZIGBEE_CHANNEL = 0x0008,
|
|
165
|
-
GET_PAN_ID = 0x0009,
|
|
166
|
-
SET_PAN_ID = 0x000a,
|
|
167
|
-
GET_LOCAL_IEEE_ADDR = 0x000b,
|
|
168
|
-
SET_LOCAL_IEEE_ADDR = 0x000c,
|
|
169
|
-
GET_TX_POWER = 0x0010,
|
|
170
|
-
SET_TX_POWER = 0x0011,
|
|
171
|
-
GET_RX_ON_WHEN_IDLE = 0x0012,
|
|
172
|
-
SET_RX_ON_WHEN_IDLE = 0x0013,
|
|
173
|
-
GET_JOINED = 0x0014,
|
|
174
|
-
GET_AUTHENTICATED = 0x0015,
|
|
175
|
-
GET_ED_TIMEOUT = 0x0016,
|
|
176
|
-
SET_ED_TIMEOUT = 0x0017,
|
|
177
|
-
SET_NWK_KEY = 0x001b,
|
|
178
|
-
GET_NWK_KEYS = 0x001e,
|
|
179
|
-
GET_APS_KEY_BY_IEEE = 0x001f,
|
|
180
|
-
GET_PARENT_ADDRESS = 0x0022,
|
|
181
|
-
GET_EXTENDED_PAN_ID = 0x0023,
|
|
182
|
-
GET_COORDINATOR_VERSION = 0x0024,
|
|
183
|
-
GET_SHORT_ADDRESS = 0x0025,
|
|
184
|
-
GET_TRUST_CENTER_ADDRESS = 0x0026,
|
|
185
|
-
NCP_RESET_IND = 0x002b,
|
|
186
|
-
NVRAM_WRITE = 0x002e,
|
|
187
|
-
NVRAM_READ = 0x002f,
|
|
188
|
-
NVRAM_ERASE = 0x0030,
|
|
189
|
-
NVRAM_CLEAR = 0x0031,
|
|
190
|
-
SET_TC_POLICY = 0x0032,
|
|
191
|
-
SET_EXTENDED_PAN_ID = 0x0033,
|
|
192
|
-
SET_MAX_CHILDREN = 0x0034,
|
|
193
|
-
GET_MAX_CHILDREN = 0x0035,
|
|
194
|
-
|
|
195
|
-
// Application Framework
|
|
196
|
-
AF_SET_SIMPLE_DESC = 0x0101,
|
|
197
|
-
AF_DEL_SIMPLE_DESC = 0x0102,
|
|
198
|
-
AF_SET_NODE_DESC = 0x0103,
|
|
199
|
-
AF_SET_POWER_DESC = 0x0104,
|
|
200
|
-
|
|
201
|
-
// Zigbee Device Object
|
|
202
|
-
ZDO_NWK_ADDR_REQ = 0x0201,
|
|
203
|
-
ZDO_IEEE_ADDR_REQ = 0x0202,
|
|
204
|
-
ZDO_POWER_DESC_REQ = 0x0203,
|
|
205
|
-
ZDO_NODE_DESC_REQ = 0x0204,
|
|
206
|
-
ZDO_SIMPLE_DESC_REQ = 0x0205,
|
|
207
|
-
ZDO_ACTIVE_EP_REQ = 0x0206,
|
|
208
|
-
ZDO_MATCH_DESC_REQ = 0x0207,
|
|
209
|
-
ZDO_BIND_REQ = 0x0208,
|
|
210
|
-
ZDO_UNBIND_REQ = 0x0209,
|
|
211
|
-
ZDO_MGMT_LEAVE_REQ = 0x020a,
|
|
212
|
-
ZDO_PERMIT_JOINING_REQ = 0x020b,
|
|
213
|
-
ZDO_DEV_ANNCE_IND = 0x020c,
|
|
214
|
-
ZDO_REJOIN = 0x020d,
|
|
215
|
-
ZDO_SYSTEM_SRV_DISCOVERY_REQ = 0x020e,
|
|
216
|
-
ZDO_MGMT_BIND_REQ = 0x020f,
|
|
217
|
-
ZDO_MGMT_LQI_REQ = 0x0210,
|
|
218
|
-
// ZDO_MGMT_RTG_REQ = 0x0???,
|
|
219
|
-
ZDO_MGMT_NWK_UPDATE_REQ = 0x0211,
|
|
220
|
-
ZDO_GET_STATS = 0x0213,
|
|
221
|
-
ZDO_DEV_AUTHORIZED_IND = 0x0214,
|
|
222
|
-
ZDO_DEV_UPDATE_IND = 0x0215,
|
|
223
|
-
ZDO_SET_NODE_DESC_MANUF_CODE = 0x0216,
|
|
224
|
-
|
|
225
|
-
// Application Support Sub-layer
|
|
226
|
-
APSDE_DATA_REQ = 0x0301,
|
|
227
|
-
APSME_BIND = 0x0302,
|
|
228
|
-
APSME_UNBIND = 0x0303,
|
|
229
|
-
APSME_ADD_GROUP = 0x0304,
|
|
230
|
-
APSME_RM_GROUP = 0x0305,
|
|
231
|
-
APSDE_DATA_IND = 0x0306,
|
|
232
|
-
APSME_RM_ALL_GROUPS = 0x0307,
|
|
233
|
-
APS_CHECK_BINDING = 0x0308,
|
|
234
|
-
APS_GET_GROUP_TABLE = 0x0309,
|
|
235
|
-
APSME_UNBIND_ALL = 0x030a,
|
|
236
|
-
|
|
237
|
-
// Network Layer
|
|
238
|
-
NWK_FORMATION = 0x0401,
|
|
239
|
-
NWK_DISCOVERY = 0x0402,
|
|
240
|
-
NWK_NLME_JOIN = 0x0403,
|
|
241
|
-
NWK_PERMIT_JOINING = 0x0404,
|
|
242
|
-
NWK_GET_IEEE_BY_SHORT = 0x0405,
|
|
243
|
-
NWK_GET_SHORT_BY_IEEE = 0x0406,
|
|
244
|
-
NWK_GET_NEIGHBOR_BY_IEEE = 0x0407,
|
|
245
|
-
NWK_REJOINED_IND = 0x0409,
|
|
246
|
-
NWK_REJOIN_FAILED_IND = 0x040a,
|
|
247
|
-
NWK_LEAVE_IND = 0x040b,
|
|
248
|
-
PIM_SET_FAST_POLL_INTERVAL = 0x040e,
|
|
249
|
-
PIM_SET_LONG_POLL_INTERVAL = 0x040f,
|
|
250
|
-
PIM_START_FAST_POLL = 0x0410,
|
|
251
|
-
PIM_START_LONG_POLL = 0x0411,
|
|
252
|
-
PIM_START_POLL = 0x0412,
|
|
253
|
-
PIM_STOP_FAST_POLL = 0x0414,
|
|
254
|
-
PIM_STOP_POLL = 0x0415,
|
|
255
|
-
PIM_ENABLE_TURBO_POLL = 0x0416,
|
|
256
|
-
PIM_DISABLE_TURBO_POLL = 0x0417,
|
|
257
|
-
NWK_PAN_ID_CONFLICT_RESOLVE = 0x041a,
|
|
258
|
-
NWK_PAN_ID_CONFLICT_IND = 0x041b,
|
|
259
|
-
NWK_ADDRESS_UPDATE_IND = 0x041c,
|
|
260
|
-
NWK_START_WITHOUT_FORMATION = 0x041d,
|
|
261
|
-
NWK_NLME_ROUTER_START = 0x041e,
|
|
262
|
-
PARENT_LOST_IND = 0x0420,
|
|
263
|
-
PIM_START_TURBO_POLL_PACKETS = 0x0424,
|
|
264
|
-
PIM_START_TURBO_POLL_CONTINUOUS = 0x0425,
|
|
265
|
-
PIM_TURBO_POLL_CONTINUOUS_LEAVE = 0x0426,
|
|
266
|
-
PIM_TURBO_POLL_PACKETS_LEAVE = 0x0427,
|
|
267
|
-
PIM_PERMIT_TURBO_POLL = 0x0428,
|
|
268
|
-
PIM_SET_FAST_POLL_TIMEOUT = 0x0429,
|
|
269
|
-
PIM_GET_LONG_POLL_INTERVAL = 0x042a,
|
|
270
|
-
PIM_GET_IN_FAST_POLL_FLAG = 0x042b,
|
|
271
|
-
SET_KEEPALIVE_MOVE = 0x042c,
|
|
272
|
-
START_CONCENTRATOR_MODE = 0x042d,
|
|
273
|
-
STOP_CONCENTRATOR_MODE = 0x042e,
|
|
274
|
-
NWK_ENABLE_PAN_ID_CONFLICT_RESOLUTION = 0x042f,
|
|
275
|
-
NWK_ENABLE_AUTO_PAN_ID_CONFLICT_RESOLUTION = 0x0430,
|
|
276
|
-
PIM_TURBO_POLL_CANCEL_PACKET = 0x0431,
|
|
277
|
-
|
|
278
|
-
// Security
|
|
279
|
-
SECUR_SET_LOCAL_IC = 0x0501,
|
|
280
|
-
SECUR_ADD_IC = 0x0502,
|
|
281
|
-
SECUR_DEL_IC = 0x0503,
|
|
282
|
-
SECUR_GET_LOCAL_IC = 0x050d,
|
|
283
|
-
SECUR_TCLK_IND = 0x050e,
|
|
284
|
-
SECUR_TCLK_EXCHANGE_FAILED_IND = 0x050f,
|
|
285
|
-
SECUR_NWK_INITIATE_KEY_SWITCH_PROCEDURE = 0x0517,
|
|
286
|
-
SECUR_GET_IC_LIST = 0x0518,
|
|
287
|
-
SECUR_GET_IC_BY_IDX = 0x0519,
|
|
288
|
-
SECUR_REMOVE_ALL_IC = 0x051a,
|
|
289
|
-
|
|
290
|
-
///////////////////
|
|
291
|
-
UNKNOWN_1 = 0x0a02,
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export enum ResetOptions {
|
|
295
|
-
NoOptions = 0,
|
|
296
|
-
EraseNVRAM = 1,
|
|
297
|
-
FactoryReset = 2,
|
|
298
|
-
LockReadingKeys = 3,
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export enum ResetSource {
|
|
302
|
-
RESET_SRC_POWER_ON = 0,
|
|
303
|
-
RESET_SRC_SW_RESET = 1,
|
|
304
|
-
RESET_SRC_RESET_PIN = 2,
|
|
305
|
-
RESET_SRC_BROWN_OUT = 3,
|
|
306
|
-
RESET_SRC_CLOCK_LOSS = 4,
|
|
307
|
-
RESET_SRC_OTHER = 5,
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export enum PolicyType {
|
|
311
|
-
LINK_KEY_REQUIRED = 0,
|
|
312
|
-
IC_REQUIRED = 1,
|
|
313
|
-
TC_REJOIN_ENABLED = 2,
|
|
314
|
-
IGNORE_TC_REJOIN = 3,
|
|
315
|
-
APS_INSECURE_JOIN = 4,
|
|
316
|
-
DISABLE_NWK_MGMT_CHANNEL_UPDATE = 5,
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export enum BuffaloZBOSSDataType {
|
|
320
|
-
LIST_TYPED = 3000,
|
|
321
|
-
EXTENDED_PAN_ID = 3001,
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export enum DeviceAuthorizedType {
|
|
325
|
-
LEGACY = 0,
|
|
326
|
-
R21_TCLK = 1,
|
|
327
|
-
SE_CBKE = 2,
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export enum DeviceAuthorizedLegacyStatus {
|
|
331
|
-
SUCCESS = 0,
|
|
332
|
-
FAILED = 1,
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export enum DeviceAuthorizedR21TCLKStatus {
|
|
336
|
-
SUCCESS = 0,
|
|
337
|
-
TIMEOUT = 1,
|
|
338
|
-
FAILED = 2,
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export enum DeviceAuthorizedSECBKEStatus {
|
|
342
|
-
SUCCESS = 0,
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export enum DeviceUpdateStatus {
|
|
346
|
-
SECURED_REJOIN = 0,
|
|
347
|
-
UNSECURED_JOIN = 1,
|
|
348
|
-
LEFT = 2,
|
|
349
|
-
TC_REJOIN = 3,
|
|
350
|
-
// 0x04 – 0x07 = Reserved
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
export enum DeviceUpdateTCAction {
|
|
354
|
-
/* authorize device */
|
|
355
|
-
AUTHORIZE = 0,
|
|
356
|
-
/* deby authorization - msend Remove device */
|
|
357
|
-
DENY = 1,
|
|
358
|
-
/* ignore Update Device - that meay lead to authorization deny */
|
|
359
|
-
IGNORE = 2,
|
|
360
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/* v8 ignore start */
|
|
2
|
-
|
|
3
|
-
import type {KeyValue} from "../../controller/tstype";
|
|
4
|
-
import type {DataType} from "../../zspec/zcl";
|
|
5
|
-
import {BuffaloZcl} from "../../zspec/zcl/buffaloZcl";
|
|
6
|
-
import type {BuffaloZclDataType} from "../../zspec/zcl/definition/enums";
|
|
7
|
-
import type {BuffaloZclOptions} from "../../zspec/zcl/definition/tstype";
|
|
8
|
-
import {ClusterId as ZdoClusterId} from "../../zspec/zdo";
|
|
9
|
-
import {BuffaloZdo} from "../../zspec/zdo/buffaloZdo";
|
|
10
|
-
import type {GenericZdoResponse} from "../../zspec/zdo/definition/tstypes";
|
|
11
|
-
import {FRAMES, type ParamsDesc, ZBOSS_COMMAND_ID_TO_ZDO_RSP_CLUSTER_ID} from "./commands";
|
|
12
|
-
import {BuffaloZBOSSDataType, type CommandId} from "./enums";
|
|
13
|
-
|
|
14
|
-
export class ZBOSSBuffaloZcl extends BuffaloZcl {
|
|
15
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
16
|
-
public override write(type: DataType | BuffaloZclDataType | BuffaloZBOSSDataType, value: any, options: BuffaloZclOptions): void {
|
|
17
|
-
switch (type) {
|
|
18
|
-
case BuffaloZBOSSDataType.EXTENDED_PAN_ID: {
|
|
19
|
-
this.writeBuffer(value, 8);
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
default: {
|
|
23
|
-
super.write(type as DataType | BuffaloZclDataType, value, options);
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// biome-ignore lint/suspicious/noExplicitAny: API
|
|
29
|
-
public override read(type: DataType | BuffaloZclDataType | BuffaloZBOSSDataType, options: BuffaloZclOptions): any {
|
|
30
|
-
switch (type) {
|
|
31
|
-
case BuffaloZBOSSDataType.EXTENDED_PAN_ID: {
|
|
32
|
-
return this.readBuffer(8);
|
|
33
|
-
}
|
|
34
|
-
default: {
|
|
35
|
-
return super.read(type as DataType | BuffaloZclDataType, options);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public writeByDesc(payload: KeyValue, params: ParamsDesc[]): number {
|
|
41
|
-
const start = this.getPosition();
|
|
42
|
-
for (const parameter of params) {
|
|
43
|
-
const options: BuffaloZclOptions = {};
|
|
44
|
-
|
|
45
|
-
if (parameter.condition && !parameter.condition(payload, this)) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (parameter.options) parameter.options(payload, options);
|
|
49
|
-
|
|
50
|
-
if (parameter.type === BuffaloZBOSSDataType.LIST_TYPED && parameter.typed) {
|
|
51
|
-
const internalPaload = payload[parameter.name];
|
|
52
|
-
for (const value of internalPaload) {
|
|
53
|
-
this.writeByDesc(value, parameter.typed);
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
this.write(parameter.type as DataType, payload[parameter.name], options);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return this.getPosition() - start;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public readByDesc(params: ParamsDesc[]): KeyValue {
|
|
63
|
-
const payload: KeyValue = {};
|
|
64
|
-
|
|
65
|
-
for (const parameter of params) {
|
|
66
|
-
const options: BuffaloZclOptions = {payload};
|
|
67
|
-
|
|
68
|
-
if (parameter.condition && !parameter.condition(payload, this)) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (parameter.options) parameter.options(payload, options);
|
|
72
|
-
|
|
73
|
-
if (parameter.type === BuffaloZBOSSDataType.LIST_TYPED && parameter.typed) {
|
|
74
|
-
payload[parameter.name] = [];
|
|
75
|
-
|
|
76
|
-
if (!this.isMore()) break;
|
|
77
|
-
|
|
78
|
-
for (let i = 0; i < (options.length || 0); i++) {
|
|
79
|
-
const internalPaload = this.readByDesc(parameter.typed);
|
|
80
|
-
payload[parameter.name].push(internalPaload);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
if (!this.isMore()) break;
|
|
84
|
-
|
|
85
|
-
payload[parameter.name] = this.read(parameter.type as DataType, options);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return payload;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getFrameDesc(type: FrameType, key: CommandId): ParamsDesc[] {
|
|
94
|
-
const frameDesc = FRAMES[key];
|
|
95
|
-
if (!frameDesc) throw new Error(`Unrecognized frame type from FrameID ${key}`);
|
|
96
|
-
switch (type) {
|
|
97
|
-
case FrameType.REQUEST:
|
|
98
|
-
return frameDesc.request || [];
|
|
99
|
-
case FrameType.RESPONSE:
|
|
100
|
-
return frameDesc.response || [];
|
|
101
|
-
case FrameType.INDICATION:
|
|
102
|
-
return frameDesc.indication || [];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function fixNonStandardZdoRspPayload(clusterId: ZdoClusterId, buffer: Buffer): Buffer {
|
|
107
|
-
switch (clusterId) {
|
|
108
|
-
case ZdoClusterId.NODE_DESCRIPTOR_RESPONSE:
|
|
109
|
-
case ZdoClusterId.POWER_DESCRIPTOR_RESPONSE:
|
|
110
|
-
case ZdoClusterId.ACTIVE_ENDPOINTS_RESPONSE:
|
|
111
|
-
case ZdoClusterId.MATCH_DESCRIPTORS_RESPONSE: {
|
|
112
|
-
// flip nwkAddress from end to start
|
|
113
|
-
return Buffer.concat([buffer.subarray(0, 1), buffer.subarray(-2), buffer.subarray(1, -2)]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
case ZdoClusterId.SIMPLE_DESCRIPTOR_RESPONSE: {
|
|
117
|
-
// flip nwkAddress from end to start
|
|
118
|
-
// add length after nwkAddress
|
|
119
|
-
// move outClusterCount before inClusterList
|
|
120
|
-
const inClusterListSize = buffer[7] * 2; // uint16
|
|
121
|
-
return Buffer.concat([
|
|
122
|
-
buffer.subarray(0, 1), // status
|
|
123
|
-
buffer.subarray(-2), // nwkAddress
|
|
124
|
-
Buffer.from([buffer.length - 3 /* status + nwkAddress */]),
|
|
125
|
-
buffer.subarray(1, 8), // endpoint>inClusterCount
|
|
126
|
-
buffer.subarray(9, 9 + inClusterListSize), // inClusterList
|
|
127
|
-
buffer.subarray(8, 9), // outClusterCount
|
|
128
|
-
buffer.subarray(9 + inClusterListSize, -2), // outClusterList
|
|
129
|
-
]);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return buffer;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function readZBOSSFrame(buffer: Buffer): ZBOSSFrame {
|
|
137
|
-
const buf = new ZBOSSBuffaloZcl(buffer);
|
|
138
|
-
const version = buf.readUInt8();
|
|
139
|
-
const type: FrameType = buf.readUInt8();
|
|
140
|
-
const commandId: CommandId = buf.readUInt16();
|
|
141
|
-
const tsn = type === FrameType.REQUEST || type === FrameType.RESPONSE ? buf.readUInt8() : 0;
|
|
142
|
-
|
|
143
|
-
const zdoResponseClusterId =
|
|
144
|
-
type === FrameType.RESPONSE || type === FrameType.INDICATION ? ZBOSS_COMMAND_ID_TO_ZDO_RSP_CLUSTER_ID[commandId] : undefined;
|
|
145
|
-
|
|
146
|
-
if (zdoResponseClusterId !== undefined) {
|
|
147
|
-
// FrameType.INDICATION has no tsn (above), no category
|
|
148
|
-
const category = type === FrameType.RESPONSE ? buf.readUInt8() : undefined;
|
|
149
|
-
const zdoPayload = fixNonStandardZdoRspPayload(zdoResponseClusterId, buffer.subarray(type === FrameType.RESPONSE ? 6 : 4));
|
|
150
|
-
const zdo = BuffaloZdo.readResponse(false, zdoResponseClusterId, zdoPayload);
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
version,
|
|
154
|
-
type,
|
|
155
|
-
commandId,
|
|
156
|
-
tsn,
|
|
157
|
-
payload: {
|
|
158
|
-
category,
|
|
159
|
-
zdoClusterId: zdoResponseClusterId,
|
|
160
|
-
zdo,
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
version,
|
|
167
|
-
type,
|
|
168
|
-
commandId,
|
|
169
|
-
tsn,
|
|
170
|
-
payload: readPayload(type, commandId, buf),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function writeZBOSSFrame(frame: ZBOSSFrame): Buffer {
|
|
175
|
-
const buf = new ZBOSSBuffaloZcl(Buffer.alloc(247));
|
|
176
|
-
buf.writeInt8(frame.version);
|
|
177
|
-
buf.writeInt8(frame.type);
|
|
178
|
-
buf.writeUInt16(frame.commandId);
|
|
179
|
-
buf.writeUInt8(frame.tsn);
|
|
180
|
-
writePayload(frame.type, frame.commandId, frame.payload, buf);
|
|
181
|
-
return buf.getWritten();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export enum FrameType {
|
|
185
|
-
REQUEST = 0,
|
|
186
|
-
RESPONSE = 1,
|
|
187
|
-
INDICATION = 2,
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface ZBOSSFrame {
|
|
191
|
-
version: number;
|
|
192
|
-
type: FrameType;
|
|
193
|
-
commandId: CommandId;
|
|
194
|
-
tsn: number;
|
|
195
|
-
payload: KeyValue & {zdoCluster?: ZdoClusterId; zdo?: GenericZdoResponse};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function makeFrame(type: FrameType, commandId: CommandId, params: KeyValue): ZBOSSFrame {
|
|
199
|
-
const frameDesc = getFrameDesc(type, commandId);
|
|
200
|
-
const payload: KeyValue = {};
|
|
201
|
-
for (const parameter of frameDesc) {
|
|
202
|
-
// const options: BuffaloZclOptions = {payload};
|
|
203
|
-
|
|
204
|
-
if (parameter.condition && !parameter.condition(params, undefined)) {
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
payload[parameter.name] = params[parameter.name];
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
version: 0,
|
|
212
|
-
type: type,
|
|
213
|
-
commandId: commandId,
|
|
214
|
-
tsn: 0,
|
|
215
|
-
payload: payload,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function readPayload(type: FrameType, commandId: CommandId, buffalo: ZBOSSBuffaloZcl): KeyValue {
|
|
220
|
-
const frameDesc = getFrameDesc(type, commandId);
|
|
221
|
-
return buffalo.readByDesc(frameDesc);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function writePayload(type: FrameType, commandId: CommandId, payload: KeyValue, buffalo: ZBOSSBuffaloZcl): number {
|
|
225
|
-
const frameDesc = getFrameDesc(type, commandId);
|
|
226
|
-
return buffalo.writeByDesc(payload, frameDesc);
|
|
227
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/* v8 ignore start */
|
|
2
|
-
|
|
3
|
-
import {Transform, type TransformCallback, type TransformOptions} from "node:stream";
|
|
4
|
-
|
|
5
|
-
import {logger} from "../../utils/logger";
|
|
6
|
-
import {SIGNATURE} from "./consts";
|
|
7
|
-
|
|
8
|
-
const NS = "zh:zboss:read";
|
|
9
|
-
|
|
10
|
-
export class ZBOSSReader extends Transform {
|
|
11
|
-
private buffer: Buffer;
|
|
12
|
-
|
|
13
|
-
public constructor(opts?: TransformOptions) {
|
|
14
|
-
super(opts);
|
|
15
|
-
|
|
16
|
-
this.buffer = Buffer.alloc(0);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override _transform(chunk: Buffer, _encoding: BufferEncoding, cb: TransformCallback): void {
|
|
20
|
-
let data = Buffer.concat([this.buffer, chunk]);
|
|
21
|
-
let position: number;
|
|
22
|
-
|
|
23
|
-
logger.debug(`<<< DATA [${chunk.toString("hex")}]`, NS);
|
|
24
|
-
// SIGNATURE - start of package
|
|
25
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: shorter
|
|
26
|
-
while ((position = data.indexOf(SIGNATURE)) !== -1) {
|
|
27
|
-
// need for read length
|
|
28
|
-
if (data.length > position + 3) {
|
|
29
|
-
const len = data.readUInt16LE(position + 1);
|
|
30
|
-
if (data.length >= position + 1 + len) {
|
|
31
|
-
const frame = data.subarray(position + 1, position + 1 + len);
|
|
32
|
-
logger.debug(`<<< FRAME [${frame.toString("hex")}]`, NS);
|
|
33
|
-
// emit the frame via 'data' event
|
|
34
|
-
this.push(frame);
|
|
35
|
-
|
|
36
|
-
// if position not 1 - try to convert buffer before position to text - chip console output
|
|
37
|
-
if (position > 1) {
|
|
38
|
-
logger.debug(`<<< CONSOLE:\n\r${data.subarray(0, position - 1).toString()}`, NS);
|
|
39
|
-
}
|
|
40
|
-
// remove the frame from internal buffer (set below)
|
|
41
|
-
data = data.subarray(position + 1 + len);
|
|
42
|
-
if (data.length) logger.debug(`<<< TAIL [${data.toString("hex")}]`, NS);
|
|
43
|
-
} else {
|
|
44
|
-
logger.debug(`<<< Not enough data. Length=${data.length}, frame length=${len}. Waiting`, NS);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
logger.debug(`<<< Not enough data. Length=${data.length}. Waiting`, NS);
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.buffer = data;
|
|
54
|
-
|
|
55
|
-
cb();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override _flush(cb: TransformCallback): void {
|
|
59
|
-
this.push(this.buffer);
|
|
60
|
-
|
|
61
|
-
this.buffer = Buffer.alloc(0);
|
|
62
|
-
|
|
63
|
-
cb();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
File without changes
|