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,1850 +0,0 @@
|
|
|
1
|
-
import {describe, expect, it} from "vitest";
|
|
2
|
-
import * as ZSpec from "../../../src/zspec";
|
|
3
|
-
import type {ClusterId, Eui64, ExtendedPanId, NodeId} from "../../../src/zspec/tstypes";
|
|
4
|
-
import * as Zcl from "../../../src/zspec/zcl";
|
|
5
|
-
import * as Zdo from "../../../src/zspec/zdo";
|
|
6
|
-
import {BuffaloZdo} from "../../../src/zspec/zdo/buffaloZdo";
|
|
7
|
-
import type {
|
|
8
|
-
ActiveEndpointsResponse,
|
|
9
|
-
APSFrameCounterChallengeTLV,
|
|
10
|
-
APSFrameCounterResponseTLV,
|
|
11
|
-
AuthenticationTokenIdTLV,
|
|
12
|
-
BeaconAppendixEncapsulationGlobalTLV,
|
|
13
|
-
BeaconSurveyConfigurationTLV,
|
|
14
|
-
BeaconSurveyResultsTLV,
|
|
15
|
-
BindingTableResponse,
|
|
16
|
-
ClearAllBindingsReqEUI64TLV,
|
|
17
|
-
ConfigurationParametersGlobalTLV,
|
|
18
|
-
Curve25519PublicPointTLV,
|
|
19
|
-
DeviceAuthenticationLevelTLV,
|
|
20
|
-
DeviceCapabilityExtensionGlobalTLV,
|
|
21
|
-
DeviceEUI64ListTLV,
|
|
22
|
-
EndDeviceAnnounce,
|
|
23
|
-
FragmentationParametersGlobalTLV,
|
|
24
|
-
IEEEAddressResponse,
|
|
25
|
-
JoinerEncapsulationGlobalTLV,
|
|
26
|
-
LQITableResponse,
|
|
27
|
-
ManufacturerSpecificGlobalTLV,
|
|
28
|
-
MatchDescriptorsResponse,
|
|
29
|
-
NetworkAddressResponse,
|
|
30
|
-
NextChannelChangeGlobalTLV,
|
|
31
|
-
NextPanIdChangeGlobalTLV,
|
|
32
|
-
NodeDescriptorResponse,
|
|
33
|
-
NwkBeaconSurveyResponse,
|
|
34
|
-
NwkEnhancedUpdateResponse,
|
|
35
|
-
NwkIEEEJoiningListResponse,
|
|
36
|
-
NwkUnsolicitedEnhancedUpdateResponse,
|
|
37
|
-
NwkUpdateResponse,
|
|
38
|
-
PanIdConflictReportGlobalTLV,
|
|
39
|
-
PotentialParentsTLV,
|
|
40
|
-
PowerDescriptorResponse,
|
|
41
|
-
ProcessingStatusTLV,
|
|
42
|
-
RouterInformationGlobalTLV,
|
|
43
|
-
RoutingTableResponse,
|
|
44
|
-
SelectedKeyNegotiationMethodTLV,
|
|
45
|
-
ServerMask,
|
|
46
|
-
SimpleDescriptorResponse,
|
|
47
|
-
SupportedKeyNegotiationMethodsGlobalTLV,
|
|
48
|
-
SymmetricPassphraseGlobalTLV,
|
|
49
|
-
SystemServerDiscoveryResponse,
|
|
50
|
-
TargetIEEEAddressTLV,
|
|
51
|
-
} from "../../../src/zspec/zdo/definition/tstypes";
|
|
52
|
-
import {uint16To8Array, uint32To8Array} from "../../utils/math";
|
|
53
|
-
|
|
54
|
-
const IEEE_ADDRESS1: Eui64 = "0xfe34ac2385ff8311";
|
|
55
|
-
const IEEE_ADDRESS1_BYTES = [0x11, 0x83, 0xff, 0x85, 0x23, 0xac, 0x34, 0xfe];
|
|
56
|
-
const IEEE_ADDRESS2: Eui64 = "0x28373fecd834ba37";
|
|
57
|
-
const IEEE_ADDRESS2_BYTES = [0x37, 0xba, 0x34, 0xd8, 0xec, 0x3f, 0x37, 0x28];
|
|
58
|
-
const NODE_ID1: NodeId = 0xfe32;
|
|
59
|
-
const NODE_ID1_BYTES = uint16To8Array(NODE_ID1);
|
|
60
|
-
const NODE_ID2: NodeId = 0xab39;
|
|
61
|
-
const NODE_ID2_BYTES = uint16To8Array(NODE_ID2);
|
|
62
|
-
const EXT_PAN_ID1: ExtendedPanId = [3, 43, 56, 23, 65, 23, 67, 23];
|
|
63
|
-
const EXT_PAN_ID2: ExtendedPanId = [253, 231, 21, 3, 0, 44, 24, 46];
|
|
64
|
-
const CLUSTER_LIST1: ClusterId[] = [Zcl.Clusters.genAlarms.ID, Zcl.Clusters.seMetering.ID, Zcl.Clusters.haApplianceStatistics.ID];
|
|
65
|
-
const CLUSTER_LIST1_BYTES = [...uint16To8Array(CLUSTER_LIST1[0]), ...uint16To8Array(CLUSTER_LIST1[1]), ...uint16To8Array(CLUSTER_LIST1[2])];
|
|
66
|
-
const CLUSTER_LIST2: ClusterId[] = [Zcl.Clusters.genOnOff.ID, Zcl.Clusters.genBasic.ID, Zcl.Clusters.ssIasZone.ID, Zcl.Clusters.genLevelCtrl.ID];
|
|
67
|
-
const CLUSTER_LIST2_BYTES = [
|
|
68
|
-
...uint16To8Array(CLUSTER_LIST2[0]),
|
|
69
|
-
...uint16To8Array(CLUSTER_LIST2[1]),
|
|
70
|
-
...uint16To8Array(CLUSTER_LIST2[2]),
|
|
71
|
-
...uint16To8Array(CLUSTER_LIST2[3]),
|
|
72
|
-
];
|
|
73
|
-
const SERVER_MASK_R22: ServerMask = {
|
|
74
|
-
primaryTrustCenter: 1,
|
|
75
|
-
backupTrustCenter: 1,
|
|
76
|
-
deprecated1: 0,
|
|
77
|
-
deprecated2: 0,
|
|
78
|
-
deprecated3: 0,
|
|
79
|
-
deprecated4: 0,
|
|
80
|
-
networkManager: 1,
|
|
81
|
-
reserved1: 0,
|
|
82
|
-
reserved2: 0,
|
|
83
|
-
stackComplianceRevision: 22,
|
|
84
|
-
};
|
|
85
|
-
const SERVER_MASK_R22_BYTE = Zdo.Utils.createServerMask(SERVER_MASK_R22);
|
|
86
|
-
|
|
87
|
-
const SERVER_MASK_R23: ServerMask = {
|
|
88
|
-
primaryTrustCenter: 1,
|
|
89
|
-
backupTrustCenter: 1,
|
|
90
|
-
deprecated1: 0,
|
|
91
|
-
deprecated2: 0,
|
|
92
|
-
deprecated3: 0,
|
|
93
|
-
deprecated4: 0,
|
|
94
|
-
networkManager: 1,
|
|
95
|
-
reserved1: 0,
|
|
96
|
-
reserved2: 0,
|
|
97
|
-
stackComplianceRevision: 23,
|
|
98
|
-
};
|
|
99
|
-
const SERVER_MASK_R23_BYTE = Zdo.Utils.createServerMask(SERVER_MASK_R23);
|
|
100
|
-
|
|
101
|
-
describe("ZDO Buffalo", () => {
|
|
102
|
-
it("Sets & Gets position", () => {
|
|
103
|
-
const buffalo = new BuffaloZdo(Buffer.alloc(3));
|
|
104
|
-
expect(buffalo.getPosition()).toStrictEqual(0);
|
|
105
|
-
buffalo.setPosition(3);
|
|
106
|
-
expect(buffalo.getPosition()).toStrictEqual(3);
|
|
107
|
-
buffalo.setPosition(1);
|
|
108
|
-
expect(buffalo.getPosition()).toStrictEqual(1);
|
|
109
|
-
buffalo.setPosition(0);
|
|
110
|
-
expect(buffalo.getPosition()).toStrictEqual(0);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("Sets & Gets bytes without changing internal position", () => {
|
|
114
|
-
const buffalo = new BuffaloZdo(Buffer.from([1, 2, 3, 255]));
|
|
115
|
-
expect(buffalo.getByte(0)).toStrictEqual(1);
|
|
116
|
-
expect(buffalo.getByte(1)).toStrictEqual(2);
|
|
117
|
-
expect(buffalo.getByte(2)).toStrictEqual(3);
|
|
118
|
-
expect(buffalo.getByte(3)).toStrictEqual(255);
|
|
119
|
-
expect(buffalo.getPosition()).toStrictEqual(0);
|
|
120
|
-
buffalo.setByte(3, 127);
|
|
121
|
-
expect(buffalo.getByte(3)).toStrictEqual(127);
|
|
122
|
-
buffalo.setByte(0, 7);
|
|
123
|
-
expect(buffalo.getByte(0)).toStrictEqual(7);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("Checks if more available to by amount", () => {
|
|
127
|
-
const buffalo = new BuffaloZdo(Buffer.from([1, 2, 3, 255]));
|
|
128
|
-
buffalo.setPosition(4);
|
|
129
|
-
expect(buffalo.isMoreBy(0)).toBeTruthy();
|
|
130
|
-
expect(buffalo.isMoreBy(1)).toBeFalsy();
|
|
131
|
-
buffalo.setPosition(1);
|
|
132
|
-
expect(buffalo.isMoreBy(0)).toBeTruthy();
|
|
133
|
-
expect(buffalo.isMoreBy(3)).toBeTruthy();
|
|
134
|
-
expect(buffalo.isMoreBy(4)).toBeFalsy();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("Throws when duplicate TLV tag found and not valid", () => {
|
|
138
|
-
expect(() => {
|
|
139
|
-
new BuffaloZdo(
|
|
140
|
-
Buffer.from([
|
|
141
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
142
|
-
5 - 1,
|
|
143
|
-
...uint16To8Array(NODE_ID1),
|
|
144
|
-
1,
|
|
145
|
-
...uint16To8Array(213),
|
|
146
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
147
|
-
5 - 1,
|
|
148
|
-
...uint16To8Array(NODE_ID2),
|
|
149
|
-
0,
|
|
150
|
-
...uint16To8Array(344),
|
|
151
|
-
]),
|
|
152
|
-
).readTLVs();
|
|
153
|
-
}).toThrow(`Duplicate tag. Cannot have more than one of tagId=${Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS}.`);
|
|
154
|
-
expect(() => {
|
|
155
|
-
new BuffaloZdo(
|
|
156
|
-
Buffer.from([
|
|
157
|
-
Zdo.GlobalTLV.MANUFACTURER_SPECIFIC,
|
|
158
|
-
2 - 1,
|
|
159
|
-
...uint16To8Array(Zcl.ManufacturerCode.ABB),
|
|
160
|
-
Zdo.GlobalTLV.MANUFACTURER_SPECIFIC,
|
|
161
|
-
2 - 1,
|
|
162
|
-
...uint16To8Array(Zcl.ManufacturerCode.ABB_GENWAY_XIAMEN_ELECTRICAL_EQUIPMENT_CO_LTD),
|
|
163
|
-
]),
|
|
164
|
-
).readTLVs();
|
|
165
|
-
}).not.toThrow();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("Throws when encapsulated TLV tag found inside encapsulated", () => {
|
|
169
|
-
expect(() => {
|
|
170
|
-
new BuffaloZdo(
|
|
171
|
-
Buffer.from([Zdo.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION, 4 - 1, Zdo.GlobalTLV.JOINER_ENCAPSULATION, 2 - 1, 123, 456]),
|
|
172
|
-
).readTLVs();
|
|
173
|
-
}).toThrow(`Invalid nested encapsulation for tagId=${Zdo.GlobalTLV.JOINER_ENCAPSULATION}.`);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("Throws when not enough bytes to read in TLV", () => {
|
|
177
|
-
expect(() => {
|
|
178
|
-
new BuffaloZdo(Buffer.from([Zdo.GlobalTLV.MANUFACTURER_SPECIFIC, 6 - 1, ...uint16To8Array(Zcl.ManufacturerCode.ABB)])).readTLVs();
|
|
179
|
-
}).toThrow(`Malformed TLV. Invalid data length for tagId=${Zdo.GlobalTLV.MANUFACTURER_SPECIFIC}, expected ${6}.`);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("Ignores invalid TLV tag and reads next TLV", () => {
|
|
183
|
-
const buffalo = new BuffaloZdo(
|
|
184
|
-
Buffer.from([
|
|
185
|
-
0xff,
|
|
186
|
-
5 - 1,
|
|
187
|
-
...uint16To8Array(Zcl.ManufacturerCode.ABB),
|
|
188
|
-
4,
|
|
189
|
-
5,
|
|
190
|
-
6,
|
|
191
|
-
Zdo.GlobalTLV.MANUFACTURER_SPECIFIC,
|
|
192
|
-
5 - 1,
|
|
193
|
-
...uint16To8Array(Zcl.ManufacturerCode.ABB),
|
|
194
|
-
1,
|
|
195
|
-
2,
|
|
196
|
-
3,
|
|
197
|
-
]),
|
|
198
|
-
);
|
|
199
|
-
const tlvs = buffalo.readTLVs();
|
|
200
|
-
|
|
201
|
-
expect(tlvs).toStrictEqual([
|
|
202
|
-
{
|
|
203
|
-
tagId: Zdo.GlobalTLV.MANUFACTURER_SPECIFIC,
|
|
204
|
-
length: 5,
|
|
205
|
-
tlv: {
|
|
206
|
-
zigbeeManufacturerId: Zcl.ManufacturerCode.ABB,
|
|
207
|
-
additionalData: Buffer.from([1, 2, 3]),
|
|
208
|
-
} as ManufacturerSpecificGlobalTLV,
|
|
209
|
-
},
|
|
210
|
-
]);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("Throws when writing invalid TLV tag", () => {
|
|
214
|
-
const buffalo = new BuffaloZdo(Buffer.alloc(3));
|
|
215
|
-
|
|
216
|
-
expect(() => {
|
|
217
|
-
buffalo.writeGlobalTLV({tagId: 0xfe, length: 2, tlv: {nwkPanIdConflictCount: NODE_ID2} as PanIdConflictReportGlobalTLV});
|
|
218
|
-
}).toThrow(new Zdo.StatusError(Zdo.Status.NOT_SUPPORTED));
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it.each([
|
|
222
|
-
["readProcessingStatusTLV", {length: 6, error: `Malformed TLV. Invalid length '6', expected 5.`, bytes: [2]}],
|
|
223
|
-
["readDeviceAuthenticationLevelTLV", {length: 11, error: `Malformed TLV. Invalid length '11', expected 10.`, bytes: []}],
|
|
224
|
-
["readPotentialParentsTLV", {length: 3, error: `Malformed TLV. Invalid length '3', expected at least 4.`, bytes: []}],
|
|
225
|
-
["readPotentialParentsTLV", {length: 11, error: `Malformed TLV. Invalid length '11', expected 13.`, bytes: [1, 2, 230, 3]}],
|
|
226
|
-
["readBeaconSurveyResultsTLV", {length: 6, error: `Malformed TLV. Invalid length '6', expected 4.`, bytes: []}],
|
|
227
|
-
["readAPSFrameCounterResponseTLV", {length: 36, error: `Malformed TLV. Invalid length '36', expected 32.`, bytes: []}],
|
|
228
|
-
// ['readDeviceEUI64ListTLV', {length: 36, error: `Malformed TLV. Invalid length '36', expected 41.`, bytes: [5]}],
|
|
229
|
-
// ['readSelectedKeyNegotiationMethodTLV', {length: 11, error: `Malformed TLV. Invalid length '11', expected 10.`, bytes: []}],
|
|
230
|
-
// ['readTargetIEEEAddressTLV', {length: 11, error: `Malformed TLV. Invalid length '11', expected 8.`, bytes: []}],
|
|
231
|
-
["readCurve25519PublicPointTLV", {length: 11, error: `Malformed TLV. Invalid length '11', expected 40.`, bytes: []}],
|
|
232
|
-
// ['readBeaconSurveyConfigurationTLV', {length: 3, error: `Malformed TLV. Invalid length '3', expected 6.`, bytes: [1]}],
|
|
233
|
-
["readConfigurationParametersGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
234
|
-
["readBeaconAppendixEncapsulationGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
235
|
-
["readJoinerEncapsulationGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
236
|
-
["readFragmentationParametersGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
237
|
-
["readRouterInformationGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
238
|
-
["readSymmetricPassphraseGlobalTLV", {length: 13, error: `Malformed TLV. Invalid length '13', expected at least 16.`, bytes: []}],
|
|
239
|
-
["readNextChannelChangeGlobalTLV", {length: 3, error: `Malformed TLV. Invalid length '3', expected at least 4.`, bytes: []}],
|
|
240
|
-
["readNextPanIdChangeGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
241
|
-
["readPanIdConflictReportGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
242
|
-
["readSupportedKeyNegotiationMethodsGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
243
|
-
["readManufacturerSpecificGlobalTLV", {length: 1, error: `Malformed TLV. Invalid length '1', expected at least 2.`, bytes: []}],
|
|
244
|
-
])("Throws when reading invalid length TLV %s", (func, payload) => {
|
|
245
|
-
expect(() => {
|
|
246
|
-
const buffalo = new BuffaloZdo(Buffer.from(payload.bytes));
|
|
247
|
-
|
|
248
|
-
buffalo[func](payload.length);
|
|
249
|
-
}).toThrow(payload.error);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it.each([
|
|
253
|
-
[
|
|
254
|
-
"MANUFACTURER_SPECIFIC",
|
|
255
|
-
[Zdo.GlobalTLV.MANUFACTURER_SPECIFIC, 3 - 1, ...uint16To8Array(256), 123],
|
|
256
|
-
[
|
|
257
|
-
{
|
|
258
|
-
tagId: Zdo.GlobalTLV.MANUFACTURER_SPECIFIC,
|
|
259
|
-
length: 3,
|
|
260
|
-
tlv: {zigbeeManufacturerId: 256, additionalData: Buffer.from([123])} as ManufacturerSpecificGlobalTLV,
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
],
|
|
264
|
-
[
|
|
265
|
-
"SUPPORTED_KEY_NEGOTIATION_METHODS",
|
|
266
|
-
[Zdo.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS, 2 - 1, 1, 2],
|
|
267
|
-
[
|
|
268
|
-
{
|
|
269
|
-
tagId: Zdo.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS,
|
|
270
|
-
length: 2,
|
|
271
|
-
tlv: {
|
|
272
|
-
keyNegotiationProtocolsBitmask: 1,
|
|
273
|
-
preSharedSecretsBitmask: 2,
|
|
274
|
-
sourceDeviceEui64: undefined,
|
|
275
|
-
} as SupportedKeyNegotiationMethodsGlobalTLV,
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
],
|
|
279
|
-
[
|
|
280
|
-
"SUPPORTED_KEY_NEGOTIATION_METHODS with IEEE",
|
|
281
|
-
[Zdo.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS, 10 - 1, 1, 2, ...IEEE_ADDRESS1_BYTES],
|
|
282
|
-
[
|
|
283
|
-
{
|
|
284
|
-
tagId: Zdo.GlobalTLV.SUPPORTED_KEY_NEGOTIATION_METHODS,
|
|
285
|
-
length: 10,
|
|
286
|
-
tlv: {
|
|
287
|
-
keyNegotiationProtocolsBitmask: 1,
|
|
288
|
-
preSharedSecretsBitmask: 2,
|
|
289
|
-
sourceDeviceEui64: IEEE_ADDRESS1,
|
|
290
|
-
} as SupportedKeyNegotiationMethodsGlobalTLV,
|
|
291
|
-
},
|
|
292
|
-
],
|
|
293
|
-
],
|
|
294
|
-
[
|
|
295
|
-
"PAN_ID_CONFLICT_REPORT",
|
|
296
|
-
[Zdo.GlobalTLV.PAN_ID_CONFLICT_REPORT, 2 - 1, ...NODE_ID2_BYTES],
|
|
297
|
-
[{tagId: Zdo.GlobalTLV.PAN_ID_CONFLICT_REPORT, length: 2, tlv: {nwkPanIdConflictCount: NODE_ID2} as PanIdConflictReportGlobalTLV}],
|
|
298
|
-
],
|
|
299
|
-
[
|
|
300
|
-
"NEXT_PAN_ID_CHANGE",
|
|
301
|
-
[Zdo.GlobalTLV.NEXT_PAN_ID_CHANGE, 2 - 1, ...uint16To8Array(0xff00)],
|
|
302
|
-
[{tagId: Zdo.GlobalTLV.NEXT_PAN_ID_CHANGE, length: 2, tlv: {panId: 0xff00} as NextPanIdChangeGlobalTLV}],
|
|
303
|
-
],
|
|
304
|
-
[
|
|
305
|
-
"NEXT_CHANNEL_CHANGE",
|
|
306
|
-
[Zdo.GlobalTLV.NEXT_CHANNEL_CHANGE, 4 - 1, ...uint32To8Array(423432)],
|
|
307
|
-
[{tagId: Zdo.GlobalTLV.NEXT_CHANNEL_CHANGE, length: 4, tlv: {channel: 423432} as NextChannelChangeGlobalTLV}],
|
|
308
|
-
],
|
|
309
|
-
[
|
|
310
|
-
"SYMMETRIC_PASSPHRASE",
|
|
311
|
-
[
|
|
312
|
-
Zdo.GlobalTLV.SYMMETRIC_PASSPHRASE,
|
|
313
|
-
ZSpec.DEFAULT_ENCRYPTION_KEY_SIZE - 1,
|
|
314
|
-
...Buffer.alloc(ZSpec.DEFAULT_ENCRYPTION_KEY_SIZE).fill(0xca),
|
|
315
|
-
],
|
|
316
|
-
[
|
|
317
|
-
{
|
|
318
|
-
tagId: Zdo.GlobalTLV.SYMMETRIC_PASSPHRASE,
|
|
319
|
-
length: ZSpec.DEFAULT_ENCRYPTION_KEY_SIZE,
|
|
320
|
-
tlv: {passphrase: Buffer.alloc(ZSpec.DEFAULT_ENCRYPTION_KEY_SIZE).fill(0xca)} as SymmetricPassphraseGlobalTLV,
|
|
321
|
-
},
|
|
322
|
-
],
|
|
323
|
-
],
|
|
324
|
-
[
|
|
325
|
-
"ROUTER_INFORMATION",
|
|
326
|
-
[Zdo.GlobalTLV.ROUTER_INFORMATION, 2 - 1, ...uint16To8Array(4396)],
|
|
327
|
-
[{tagId: Zdo.GlobalTLV.ROUTER_INFORMATION, length: 2, tlv: {bitmask: 4396} as RouterInformationGlobalTLV}],
|
|
328
|
-
],
|
|
329
|
-
[
|
|
330
|
-
"FRAGMENTATION_PARAMETERS",
|
|
331
|
-
[Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, 5 - 1, ...NODE_ID1_BYTES, 5, ...uint16To8Array(32456)],
|
|
332
|
-
[
|
|
333
|
-
{
|
|
334
|
-
tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
335
|
-
length: 5,
|
|
336
|
-
tlv: {nwkAddress: NODE_ID1, fragmentationOptions: 5, maxIncomingTransferUnit: 32456} as FragmentationParametersGlobalTLV,
|
|
337
|
-
},
|
|
338
|
-
],
|
|
339
|
-
],
|
|
340
|
-
[
|
|
341
|
-
"JOINER_ENCAPSULATION",
|
|
342
|
-
[Zdo.GlobalTLV.JOINER_ENCAPSULATION, 4 - 1, Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, 2 - 1, ...NODE_ID1_BYTES],
|
|
343
|
-
[
|
|
344
|
-
{
|
|
345
|
-
tagId: Zdo.GlobalTLV.JOINER_ENCAPSULATION,
|
|
346
|
-
length: 4,
|
|
347
|
-
tlv: {
|
|
348
|
-
additionalTLVs: [
|
|
349
|
-
{
|
|
350
|
-
tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
351
|
-
length: 2,
|
|
352
|
-
tlv: {nwkAddress: NODE_ID1, fragmentationOptions: undefined, maxIncomingTransferUnit: undefined},
|
|
353
|
-
},
|
|
354
|
-
],
|
|
355
|
-
} as JoinerEncapsulationGlobalTLV,
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
],
|
|
359
|
-
[
|
|
360
|
-
"BEACON_APPENDIX_ENCAPSULATION",
|
|
361
|
-
[Zdo.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION, 4 - 1, Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, 2 - 1, ...NODE_ID1_BYTES],
|
|
362
|
-
[
|
|
363
|
-
{
|
|
364
|
-
tagId: Zdo.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION,
|
|
365
|
-
length: 4,
|
|
366
|
-
tlv: {
|
|
367
|
-
additionalTLVs: [
|
|
368
|
-
{
|
|
369
|
-
tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
370
|
-
length: 2,
|
|
371
|
-
tlv: {nwkAddress: NODE_ID1, fragmentationOptions: undefined, maxIncomingTransferUnit: undefined},
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
} as BeaconAppendixEncapsulationGlobalTLV,
|
|
375
|
-
},
|
|
376
|
-
],
|
|
377
|
-
],
|
|
378
|
-
[
|
|
379
|
-
"CONFIGURATION_PARAMETERS",
|
|
380
|
-
[Zdo.GlobalTLV.CONFIGURATION_PARAMETERS, 2 - 1, ...uint16To8Array(47593)],
|
|
381
|
-
[{tagId: Zdo.GlobalTLV.CONFIGURATION_PARAMETERS, length: 2, tlv: {configurationParameters: 47593} as ConfigurationParametersGlobalTLV}],
|
|
382
|
-
],
|
|
383
|
-
[
|
|
384
|
-
"DEVICE_CAPABILITY_EXTENSION",
|
|
385
|
-
[Zdo.GlobalTLV.DEVICE_CAPABILITY_EXTENSION, 3 - 1, 3, 1, 2],
|
|
386
|
-
[
|
|
387
|
-
{
|
|
388
|
-
tagId: Zdo.GlobalTLV.DEVICE_CAPABILITY_EXTENSION,
|
|
389
|
-
length: 3,
|
|
390
|
-
tlv: {data: Buffer.from([3, 1, 2])} as DeviceCapabilityExtensionGlobalTLV,
|
|
391
|
-
},
|
|
392
|
-
],
|
|
393
|
-
],
|
|
394
|
-
["invalid", [0xfe, 0, 0], []],
|
|
395
|
-
])("Reads & Writes global TLV %s", (_name, bytes, expected) => {
|
|
396
|
-
const readBuffalo = new BuffaloZdo(Buffer.from(bytes));
|
|
397
|
-
expect(readBuffalo.readTLVs()).toStrictEqual(expected);
|
|
398
|
-
|
|
399
|
-
const writeBuffer = new BuffaloZdo(Buffer.alloc(255));
|
|
400
|
-
writeBuffer.writeGlobalTLVs(expected);
|
|
401
|
-
expect(writeBuffer.getWritten()).toStrictEqual(Buffer.from(expected.length ? bytes : []));
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it("Throws when building unknown cluster ID", () => {
|
|
405
|
-
const clusterId = 0x8005;
|
|
406
|
-
|
|
407
|
-
expect(() => {
|
|
408
|
-
// @ts-expect-error
|
|
409
|
-
BuffaloZdo.buildRequest(true, clusterId, Buffer.from([1, 123]));
|
|
410
|
-
}).toThrow(`Unsupported request building for cluster ID '${clusterId}'.`);
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it("buildNetworkAddressRequest without ZDO_MESSAGE_OVERHEAD", () => {
|
|
414
|
-
expect(Zdo.Buffalo.buildRequest(false, Zdo.ClusterId.NETWORK_ADDRESS_REQUEST, IEEE_ADDRESS1, false, 1)).toStrictEqual(
|
|
415
|
-
Buffer.from([...IEEE_ADDRESS1_BYTES, 0, 1]),
|
|
416
|
-
);
|
|
417
|
-
expect(Zdo.Buffalo.buildRequest(false, Zdo.ClusterId.NETWORK_ADDRESS_REQUEST, IEEE_ADDRESS2, true, 3)).toStrictEqual(
|
|
418
|
-
Buffer.from([...IEEE_ADDRESS2_BYTES, 1, 3]),
|
|
419
|
-
);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it("buildNetworkAddressRequest", () => {
|
|
423
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NETWORK_ADDRESS_REQUEST, IEEE_ADDRESS1, false, 1)).toStrictEqual(
|
|
424
|
-
Buffer.from([0, ...IEEE_ADDRESS1_BYTES, 0, 1]),
|
|
425
|
-
);
|
|
426
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NETWORK_ADDRESS_REQUEST, IEEE_ADDRESS2, true, 3)).toStrictEqual(
|
|
427
|
-
Buffer.from([0, ...IEEE_ADDRESS2_BYTES, 1, 3]),
|
|
428
|
-
);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it("buildIeeeAddressRequest", () => {
|
|
432
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.IEEE_ADDRESS_REQUEST, NODE_ID1, false, 1)).toStrictEqual(
|
|
433
|
-
Buffer.from([0, ...NODE_ID1_BYTES, 0, 1]),
|
|
434
|
-
);
|
|
435
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.IEEE_ADDRESS_REQUEST, NODE_ID1, true, 3)).toStrictEqual(
|
|
436
|
-
Buffer.from([0, ...NODE_ID1_BYTES, 1, 3]),
|
|
437
|
-
);
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it("buildNodeDescriptorRequest", () => {
|
|
441
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NODE_DESCRIPTOR_REQUEST, NODE_ID1)).toStrictEqual(Buffer.from([0, ...NODE_ID1_BYTES]));
|
|
442
|
-
|
|
443
|
-
const tlv: FragmentationParametersGlobalTLV = {
|
|
444
|
-
nwkAddress: NODE_ID1,
|
|
445
|
-
/*fragmentationOptions: undefined,*/
|
|
446
|
-
/*maxIncomingTransferUnit: undefined,*/
|
|
447
|
-
};
|
|
448
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NODE_DESCRIPTOR_REQUEST, NODE_ID1, tlv)).toStrictEqual(
|
|
449
|
-
Buffer.from([0, ...NODE_ID1_BYTES, Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, 1, ...uint16To8Array(tlv.nwkAddress)]),
|
|
450
|
-
);
|
|
451
|
-
|
|
452
|
-
const tlv2: FragmentationParametersGlobalTLV = {
|
|
453
|
-
nwkAddress: NODE_ID1,
|
|
454
|
-
fragmentationOptions: 1,
|
|
455
|
-
/*maxIncomingTransferUnit: undefined,*/
|
|
456
|
-
};
|
|
457
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NODE_DESCRIPTOR_REQUEST, NODE_ID1, tlv2)).toStrictEqual(
|
|
458
|
-
Buffer.from([
|
|
459
|
-
0,
|
|
460
|
-
...NODE_ID1_BYTES,
|
|
461
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
462
|
-
2,
|
|
463
|
-
...uint16To8Array(tlv2.nwkAddress),
|
|
464
|
-
tlv2.fragmentationOptions!,
|
|
465
|
-
]),
|
|
466
|
-
);
|
|
467
|
-
|
|
468
|
-
const tlv3: FragmentationParametersGlobalTLV = {
|
|
469
|
-
nwkAddress: NODE_ID1,
|
|
470
|
-
/*fragmentationOptions: undefined,*/
|
|
471
|
-
maxIncomingTransferUnit: 256,
|
|
472
|
-
};
|
|
473
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NODE_DESCRIPTOR_REQUEST, NODE_ID1, tlv3)).toStrictEqual(
|
|
474
|
-
Buffer.from([
|
|
475
|
-
0,
|
|
476
|
-
...NODE_ID1_BYTES,
|
|
477
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
478
|
-
3,
|
|
479
|
-
...uint16To8Array(tlv3.nwkAddress),
|
|
480
|
-
...uint16To8Array(tlv3.maxIncomingTransferUnit!),
|
|
481
|
-
]),
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
const tlv4: FragmentationParametersGlobalTLV = {
|
|
485
|
-
nwkAddress: NODE_ID1,
|
|
486
|
-
fragmentationOptions: 1,
|
|
487
|
-
maxIncomingTransferUnit: 65352,
|
|
488
|
-
};
|
|
489
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NODE_DESCRIPTOR_REQUEST, NODE_ID1, tlv4)).toStrictEqual(
|
|
490
|
-
Buffer.from([
|
|
491
|
-
0,
|
|
492
|
-
...NODE_ID1_BYTES,
|
|
493
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
494
|
-
4,
|
|
495
|
-
...uint16To8Array(tlv4.nwkAddress),
|
|
496
|
-
tlv4.fragmentationOptions!,
|
|
497
|
-
...uint16To8Array(tlv4.maxIncomingTransferUnit!),
|
|
498
|
-
]),
|
|
499
|
-
);
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
it("buildPowerDescriptorRequest", () => {
|
|
503
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.POWER_DESCRIPTOR_REQUEST, NODE_ID1)).toStrictEqual(Buffer.from([0, ...NODE_ID1_BYTES]));
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
it("buildSimpleDescriptorRequest", () => {
|
|
507
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.SIMPLE_DESCRIPTOR_REQUEST, NODE_ID1, 3)).toStrictEqual(
|
|
508
|
-
Buffer.from([0, ...NODE_ID1_BYTES, 3]),
|
|
509
|
-
);
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
it("buildActiveEndpointsRequest", () => {
|
|
513
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.ACTIVE_ENDPOINTS_REQUEST, NODE_ID1)).toStrictEqual(Buffer.from([0, ...NODE_ID1_BYTES]));
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it("buildMatchDescriptorRequest", () => {
|
|
517
|
-
expect(
|
|
518
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.MATCH_DESCRIPTORS_REQUEST, NODE_ID1, ZSpec.HA_PROFILE_ID, CLUSTER_LIST1, CLUSTER_LIST2),
|
|
519
|
-
).toStrictEqual(
|
|
520
|
-
Buffer.from([
|
|
521
|
-
0,
|
|
522
|
-
...NODE_ID1_BYTES,
|
|
523
|
-
...uint16To8Array(ZSpec.HA_PROFILE_ID),
|
|
524
|
-
CLUSTER_LIST1.length,
|
|
525
|
-
...CLUSTER_LIST1_BYTES,
|
|
526
|
-
CLUSTER_LIST2.length,
|
|
527
|
-
...CLUSTER_LIST2_BYTES,
|
|
528
|
-
]),
|
|
529
|
-
);
|
|
530
|
-
expect(
|
|
531
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.MATCH_DESCRIPTORS_REQUEST, NODE_ID1, ZSpec.HA_PROFILE_ID, CLUSTER_LIST1, []),
|
|
532
|
-
).toStrictEqual(Buffer.from([0, ...NODE_ID1_BYTES, ...uint16To8Array(ZSpec.HA_PROFILE_ID), CLUSTER_LIST1.length, ...CLUSTER_LIST1_BYTES, 0]));
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
it("buildSystemServiceDiscoveryRequest", () => {
|
|
536
|
-
expect(
|
|
537
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.SYSTEM_SERVER_DISCOVERY_REQUEST, {
|
|
538
|
-
primaryTrustCenter: 1,
|
|
539
|
-
backupTrustCenter: 0,
|
|
540
|
-
deprecated1: 0,
|
|
541
|
-
deprecated2: 0,
|
|
542
|
-
deprecated3: 0,
|
|
543
|
-
deprecated4: 0,
|
|
544
|
-
networkManager: 0,
|
|
545
|
-
reserved1: 0,
|
|
546
|
-
reserved2: 0,
|
|
547
|
-
stackComplianceRevision: 0,
|
|
548
|
-
}),
|
|
549
|
-
).toStrictEqual(Buffer.from([0, ...uint16To8Array(0b0000000000000001)]));
|
|
550
|
-
expect(
|
|
551
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.SYSTEM_SERVER_DISCOVERY_REQUEST, {
|
|
552
|
-
primaryTrustCenter: 1,
|
|
553
|
-
backupTrustCenter: 0,
|
|
554
|
-
deprecated1: 0,
|
|
555
|
-
deprecated2: 0,
|
|
556
|
-
deprecated3: 0,
|
|
557
|
-
deprecated4: 0,
|
|
558
|
-
networkManager: 1,
|
|
559
|
-
reserved1: 0,
|
|
560
|
-
reserved2: 0,
|
|
561
|
-
stackComplianceRevision: 23,
|
|
562
|
-
}),
|
|
563
|
-
).toStrictEqual(Buffer.from([0, ...uint16To8Array(0b0010111001000001)]));
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
it("buildParentAnnounce", () => {
|
|
567
|
-
const children = [IEEE_ADDRESS1, IEEE_ADDRESS2];
|
|
568
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.PARENT_ANNOUNCE, children)).toStrictEqual(
|
|
569
|
-
Buffer.from([0, children.length, ...IEEE_ADDRESS1_BYTES, ...IEEE_ADDRESS2_BYTES]),
|
|
570
|
-
);
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
it("buildBindRequest", () => {
|
|
574
|
-
expect(
|
|
575
|
-
Zdo.Buffalo.buildRequest(
|
|
576
|
-
true,
|
|
577
|
-
Zdo.ClusterId.BIND_REQUEST,
|
|
578
|
-
IEEE_ADDRESS1,
|
|
579
|
-
2,
|
|
580
|
-
Zcl.Clusters.seMetering.ID,
|
|
581
|
-
Zdo.UNICAST_BINDING,
|
|
582
|
-
IEEE_ADDRESS2,
|
|
583
|
-
123,
|
|
584
|
-
64,
|
|
585
|
-
),
|
|
586
|
-
).toStrictEqual(
|
|
587
|
-
Buffer.from([
|
|
588
|
-
0,
|
|
589
|
-
...IEEE_ADDRESS1_BYTES,
|
|
590
|
-
2,
|
|
591
|
-
...uint16To8Array(Zcl.Clusters.seMetering.ID),
|
|
592
|
-
Zdo.UNICAST_BINDING,
|
|
593
|
-
...IEEE_ADDRESS2_BYTES,
|
|
594
|
-
64,
|
|
595
|
-
]),
|
|
596
|
-
);
|
|
597
|
-
expect(
|
|
598
|
-
Zdo.Buffalo.buildRequest(
|
|
599
|
-
true,
|
|
600
|
-
Zdo.ClusterId.BIND_REQUEST,
|
|
601
|
-
IEEE_ADDRESS1,
|
|
602
|
-
3,
|
|
603
|
-
Zcl.Clusters.seMetering.ID,
|
|
604
|
-
Zdo.MULTICAST_BINDING,
|
|
605
|
-
IEEE_ADDRESS2,
|
|
606
|
-
123,
|
|
607
|
-
64,
|
|
608
|
-
),
|
|
609
|
-
).toStrictEqual(
|
|
610
|
-
Buffer.from([0, ...IEEE_ADDRESS1_BYTES, 3, ...uint16To8Array(Zcl.Clusters.seMetering.ID), Zdo.MULTICAST_BINDING, ...uint16To8Array(123)]),
|
|
611
|
-
);
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it("buildUnbindRequest", () => {
|
|
615
|
-
expect(
|
|
616
|
-
Zdo.Buffalo.buildRequest(
|
|
617
|
-
true,
|
|
618
|
-
Zdo.ClusterId.UNBIND_REQUEST,
|
|
619
|
-
IEEE_ADDRESS1,
|
|
620
|
-
2,
|
|
621
|
-
Zcl.Clusters.seMetering.ID,
|
|
622
|
-
Zdo.UNICAST_BINDING,
|
|
623
|
-
IEEE_ADDRESS2,
|
|
624
|
-
123,
|
|
625
|
-
64,
|
|
626
|
-
),
|
|
627
|
-
).toStrictEqual(
|
|
628
|
-
Buffer.from([
|
|
629
|
-
0,
|
|
630
|
-
...IEEE_ADDRESS1_BYTES,
|
|
631
|
-
2,
|
|
632
|
-
...uint16To8Array(Zcl.Clusters.seMetering.ID),
|
|
633
|
-
Zdo.UNICAST_BINDING,
|
|
634
|
-
...IEEE_ADDRESS2_BYTES,
|
|
635
|
-
64,
|
|
636
|
-
]),
|
|
637
|
-
);
|
|
638
|
-
expect(
|
|
639
|
-
Zdo.Buffalo.buildRequest(
|
|
640
|
-
true,
|
|
641
|
-
Zdo.ClusterId.UNBIND_REQUEST,
|
|
642
|
-
IEEE_ADDRESS1,
|
|
643
|
-
3,
|
|
644
|
-
Zcl.Clusters.seMetering.ID,
|
|
645
|
-
Zdo.MULTICAST_BINDING,
|
|
646
|
-
IEEE_ADDRESS2,
|
|
647
|
-
123,
|
|
648
|
-
64,
|
|
649
|
-
),
|
|
650
|
-
).toStrictEqual(
|
|
651
|
-
Buffer.from([0, ...IEEE_ADDRESS1_BYTES, 3, ...uint16To8Array(Zcl.Clusters.seMetering.ID), Zdo.MULTICAST_BINDING, ...uint16To8Array(123)]),
|
|
652
|
-
);
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
it("Throws when buildBindRequest/buildUnbindRequest invalid type", () => {
|
|
656
|
-
expect(() => {
|
|
657
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.BIND_REQUEST, IEEE_ADDRESS1, 2, Zcl.Clusters.seMetering.ID, 99, IEEE_ADDRESS2, 123, 64);
|
|
658
|
-
}).toThrow(`Status 'NOT_SUPPORTED'`);
|
|
659
|
-
expect(() => {
|
|
660
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.UNBIND_REQUEST, IEEE_ADDRESS1, 2, Zcl.Clusters.seMetering.ID, 99, IEEE_ADDRESS2, 123, 64);
|
|
661
|
-
}).toThrow(`Status 'NOT_SUPPORTED'`);
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
it("buildClearAllBindingsRequest", () => {
|
|
665
|
-
const eui64List = [IEEE_ADDRESS1, IEEE_ADDRESS2];
|
|
666
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.CLEAR_ALL_BINDINGS_REQUEST, {eui64List} as ClearAllBindingsReqEUI64TLV)).toStrictEqual(
|
|
667
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE * eui64List.length + 1 - 1, eui64List.length, ...IEEE_ADDRESS1_BYTES, ...IEEE_ADDRESS2_BYTES]),
|
|
668
|
-
);
|
|
669
|
-
expect(
|
|
670
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.CLEAR_ALL_BINDINGS_REQUEST, {eui64List: []} as ClearAllBindingsReqEUI64TLV),
|
|
671
|
-
).toStrictEqual(Buffer.from([0, 0, 0, 0]));
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
it("buildLqiTableRequest", () => {
|
|
675
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.LQI_TABLE_REQUEST, 1)).toStrictEqual(Buffer.from([0, 1]));
|
|
676
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.LQI_TABLE_REQUEST, 254)).toStrictEqual(Buffer.from([0, 254]));
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
it("buildRoutingTableRequest", () => {
|
|
680
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.ROUTING_TABLE_REQUEST, 1)).toStrictEqual(Buffer.from([0, 1]));
|
|
681
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.ROUTING_TABLE_REQUEST, 254)).toStrictEqual(Buffer.from([0, 254]));
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
it("buildBindingTableRequest", () => {
|
|
685
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.BINDING_TABLE_REQUEST, 1)).toStrictEqual(Buffer.from([0, 1]));
|
|
686
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.BINDING_TABLE_REQUEST, 254)).toStrictEqual(Buffer.from([0, 254]));
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it("buildLeaveRequest", () => {
|
|
690
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.LEAVE_REQUEST, IEEE_ADDRESS2, Zdo.LeaveRequestFlags.WITHOUT_REJOIN)).toStrictEqual(
|
|
691
|
-
Buffer.from([0, ...IEEE_ADDRESS2_BYTES, Zdo.LeaveRequestFlags.WITHOUT_REJOIN]),
|
|
692
|
-
);
|
|
693
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.LEAVE_REQUEST, IEEE_ADDRESS2, Zdo.LeaveRequestFlags.AND_REJOIN)).toStrictEqual(
|
|
694
|
-
Buffer.from([0, ...IEEE_ADDRESS2_BYTES, Zdo.LeaveRequestFlags.AND_REJOIN]),
|
|
695
|
-
);
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
it("buildPermitJoining", () => {
|
|
699
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.PERMIT_JOINING_REQUEST, 254, 1, [])).toStrictEqual(Buffer.from([0, 254, 1]));
|
|
700
|
-
|
|
701
|
-
const tlvs = [
|
|
702
|
-
{
|
|
703
|
-
tagId: Zdo.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION,
|
|
704
|
-
length: 4,
|
|
705
|
-
tlv: {
|
|
706
|
-
additionalTLVs: [{tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, length: 2, tlv: {nwkAddress: NODE_ID1}}],
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
];
|
|
710
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.PERMIT_JOINING_REQUEST, 255, 1, tlvs)).toStrictEqual(
|
|
711
|
-
Buffer.from([
|
|
712
|
-
0,
|
|
713
|
-
255,
|
|
714
|
-
1,
|
|
715
|
-
Zdo.GlobalTLV.BEACON_APPENDIX_ENCAPSULATION,
|
|
716
|
-
4 - 1,
|
|
717
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
718
|
-
2 - 1,
|
|
719
|
-
...NODE_ID1_BYTES,
|
|
720
|
-
]),
|
|
721
|
-
);
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
it("buildScanChannelsRequest", () => {
|
|
725
|
-
expect(
|
|
726
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_UPDATE_REQUEST, ZSpec.ALL_802_15_4_CHANNELS, 3, 3, undefined, undefined),
|
|
727
|
-
).toStrictEqual(Buffer.from([0, ...uint32To8Array(ZSpec.ALL_802_15_4_CHANNELS_MASK), 3, 3]));
|
|
728
|
-
expect(
|
|
729
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_UPDATE_REQUEST, ZSpec.ALL_802_15_4_CHANNELS, 64, 3, undefined, undefined),
|
|
730
|
-
).toStrictEqual(Buffer.from([0, ...uint32To8Array(ZSpec.ALL_802_15_4_CHANNELS_MASK), 64 /*, 3*/]));
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
it("buildChannelChangeRequest", () => {
|
|
734
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_UPDATE_REQUEST, [15], 0xfe, undefined, 1, undefined)).toStrictEqual(
|
|
735
|
-
Buffer.from([0, ...uint32To8Array(ZSpec.Utils.channelsToUInt32Mask([15])), 0xfe, 1]),
|
|
736
|
-
);
|
|
737
|
-
});
|
|
738
|
-
|
|
739
|
-
it("buildSetActiveChannelsAndNwkManagerIdRequest", () => {
|
|
740
|
-
expect(
|
|
741
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_UPDATE_REQUEST, ZSpec.PREFERRED_802_15_4_CHANNELS, 0xff, undefined, 3, 123),
|
|
742
|
-
).toStrictEqual(Buffer.from([0, ...uint32To8Array(ZSpec.PREFERRED_802_15_4_CHANNELS_MASK), 0xff, 3, ...uint16To8Array(123)]));
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
it("buildEnhancedScanChannelsRequest", () => {
|
|
746
|
-
const channelPages = [123, 54394, 29344];
|
|
747
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_ENHANCED_UPDATE_REQUEST, channelPages, 5, 3, undefined, undefined, 1)).toStrictEqual(
|
|
748
|
-
Buffer.from([
|
|
749
|
-
0,
|
|
750
|
-
channelPages.length,
|
|
751
|
-
...uint32To8Array(channelPages[0]),
|
|
752
|
-
...uint32To8Array(channelPages[1]),
|
|
753
|
-
...uint32To8Array(channelPages[2]),
|
|
754
|
-
5,
|
|
755
|
-
3,
|
|
756
|
-
1,
|
|
757
|
-
]),
|
|
758
|
-
);
|
|
759
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_ENHANCED_UPDATE_REQUEST, channelPages, 6, 3, undefined, undefined, 1)).toStrictEqual(
|
|
760
|
-
Buffer.from([
|
|
761
|
-
0,
|
|
762
|
-
channelPages.length,
|
|
763
|
-
...uint32To8Array(channelPages[0]),
|
|
764
|
-
...uint32To8Array(channelPages[1]),
|
|
765
|
-
...uint32To8Array(channelPages[2]),
|
|
766
|
-
6 /*, 3*/,
|
|
767
|
-
1,
|
|
768
|
-
]),
|
|
769
|
-
);
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
it("buildEnhancedChannelChangeRequest", () => {
|
|
773
|
-
const channelPage = 54394;
|
|
774
|
-
expect(
|
|
775
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_ENHANCED_UPDATE_REQUEST, [channelPage], 0xfe, undefined, 3, undefined, 1),
|
|
776
|
-
).toStrictEqual(Buffer.from([0, 1, ...uint32To8Array(channelPage), 0xfe, 3, 1]));
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
it("buildEnhancedSetActiveChannelsAndNwkManagerIdRequest", () => {
|
|
780
|
-
const channelPages = [123, 54394, 29344];
|
|
781
|
-
const nwkManagerAddr = 0xfe01;
|
|
782
|
-
expect(
|
|
783
|
-
Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_ENHANCED_UPDATE_REQUEST, channelPages, 0xff, undefined, 2, nwkManagerAddr, 1),
|
|
784
|
-
).toStrictEqual(
|
|
785
|
-
Buffer.from([
|
|
786
|
-
0,
|
|
787
|
-
channelPages.length,
|
|
788
|
-
...uint32To8Array(channelPages[0]),
|
|
789
|
-
...uint32To8Array(channelPages[1]),
|
|
790
|
-
...uint32To8Array(channelPages[2]),
|
|
791
|
-
0xff,
|
|
792
|
-
2,
|
|
793
|
-
...uint16To8Array(nwkManagerAddr),
|
|
794
|
-
1,
|
|
795
|
-
]),
|
|
796
|
-
);
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
it("buildNwkIEEEJoiningListRequest", () => {
|
|
800
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_IEEE_JOINING_LIST_REQUEST, 3)).toStrictEqual(Buffer.from([0, 3]));
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
it("buildNwkBeaconSurveyRequest", () => {
|
|
804
|
-
const tlv: BeaconSurveyConfigurationTLV = {
|
|
805
|
-
scanChannelList: [],
|
|
806
|
-
configurationBitmask: 0,
|
|
807
|
-
};
|
|
808
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_BEACON_SURVEY_REQUEST, tlv)).toStrictEqual(Buffer.from([0, 0, 2 - 1, 0, 0]));
|
|
809
|
-
const tlv2: BeaconSurveyConfigurationTLV = {
|
|
810
|
-
scanChannelList: [34252],
|
|
811
|
-
configurationBitmask: 1,
|
|
812
|
-
};
|
|
813
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_BEACON_SURVEY_REQUEST, tlv2)).toStrictEqual(
|
|
814
|
-
Buffer.from([0, 0, 6 - 1, 1, ...uint32To8Array(tlv2.scanChannelList[0]), 1]),
|
|
815
|
-
);
|
|
816
|
-
const tlv3: BeaconSurveyConfigurationTLV = {
|
|
817
|
-
scanChannelList: [34252, 123],
|
|
818
|
-
configurationBitmask: 1,
|
|
819
|
-
};
|
|
820
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.NWK_BEACON_SURVEY_REQUEST, tlv3)).toStrictEqual(
|
|
821
|
-
Buffer.from([0, 0, 10 - 1, 2, ...uint32To8Array(tlv3.scanChannelList[0]), ...uint32To8Array(tlv3.scanChannelList[1]), 1]),
|
|
822
|
-
);
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
it("buildStartKeyNegotiationRequest", () => {
|
|
826
|
-
const tlv: Curve25519PublicPointTLV = {
|
|
827
|
-
eui64: IEEE_ADDRESS1,
|
|
828
|
-
publicPoint: Buffer.alloc(Zdo.CURVE_PUBLIC_POINT_SIZE).fill(0xcd),
|
|
829
|
-
};
|
|
830
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.START_KEY_NEGOTIATION_REQUEST, tlv)).toStrictEqual(
|
|
831
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE + Zdo.CURVE_PUBLIC_POINT_SIZE - 1, ...IEEE_ADDRESS1_BYTES, ...tlv.publicPoint]),
|
|
832
|
-
);
|
|
833
|
-
const tlv2: Curve25519PublicPointTLV = {
|
|
834
|
-
eui64: IEEE_ADDRESS2,
|
|
835
|
-
publicPoint: Buffer.alloc(Zdo.CURVE_PUBLIC_POINT_SIZE).fill(0x3c),
|
|
836
|
-
};
|
|
837
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.START_KEY_NEGOTIATION_REQUEST, tlv2)).toStrictEqual(
|
|
838
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE + Zdo.CURVE_PUBLIC_POINT_SIZE - 1, ...IEEE_ADDRESS2_BYTES, ...tlv2.publicPoint]),
|
|
839
|
-
);
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
it("buildRetrieveAuthenticationTokenRequest", () => {
|
|
843
|
-
const tlv: AuthenticationTokenIdTLV = {tlvTypeTagId: 0};
|
|
844
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_REQUEST, tlv)).toStrictEqual(Buffer.from([0, 0, 1 - 1, 0]));
|
|
845
|
-
const tlv2: AuthenticationTokenIdTLV = {tlvTypeTagId: 31};
|
|
846
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_REQUEST, tlv2)).toStrictEqual(
|
|
847
|
-
Buffer.from([0, 0, 1 - 1, 31]),
|
|
848
|
-
);
|
|
849
|
-
});
|
|
850
|
-
|
|
851
|
-
it("buildGetAuthenticationLevelRequest", () => {
|
|
852
|
-
const tlv: TargetIEEEAddressTLV = {ieee: IEEE_ADDRESS2};
|
|
853
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.GET_AUTHENTICATION_LEVEL_REQUEST, tlv)).toStrictEqual(
|
|
854
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE - 1, ...IEEE_ADDRESS2_BYTES]),
|
|
855
|
-
);
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
it.each([
|
|
859
|
-
{panId: 0xfeef, channel: 0, configurationParameters: 0},
|
|
860
|
-
{panId: 0x1234, channel: 15, configurationParameters: 0},
|
|
861
|
-
{panId: 0x1234, channel: 0, configurationParameters: 1},
|
|
862
|
-
{panId: 0x6543, channel: 45, configurationParameters: 1},
|
|
863
|
-
])("buildSetConfigurationRequest", ({panId, channel, configurationParameters}) => {
|
|
864
|
-
expect(
|
|
865
|
-
Zdo.Buffalo.buildRequest(
|
|
866
|
-
true,
|
|
867
|
-
Zdo.ClusterId.SET_CONFIGURATION_REQUEST,
|
|
868
|
-
{panId} as NextPanIdChangeGlobalTLV,
|
|
869
|
-
{channel} as NextChannelChangeGlobalTLV,
|
|
870
|
-
{configurationParameters} as ConfigurationParametersGlobalTLV,
|
|
871
|
-
),
|
|
872
|
-
).toStrictEqual(
|
|
873
|
-
Buffer.from([
|
|
874
|
-
0,
|
|
875
|
-
Zdo.GlobalTLV.NEXT_PAN_ID_CHANGE,
|
|
876
|
-
ZSpec.PAN_ID_SIZE - 1,
|
|
877
|
-
...uint16To8Array(panId),
|
|
878
|
-
Zdo.GlobalTLV.NEXT_CHANNEL_CHANGE,
|
|
879
|
-
4 - 1,
|
|
880
|
-
...uint32To8Array(channel),
|
|
881
|
-
Zdo.GlobalTLV.CONFIGURATION_PARAMETERS,
|
|
882
|
-
2 - 1,
|
|
883
|
-
...uint16To8Array(configurationParameters),
|
|
884
|
-
]),
|
|
885
|
-
);
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
it("buildGetConfigurationRequest", () => {
|
|
889
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.GET_CONFIGURATION_REQUEST, [84])).toStrictEqual(Buffer.from([0, 1, 84]));
|
|
890
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.GET_CONFIGURATION_REQUEST, [67, 71])).toStrictEqual(Buffer.from([0, 2, 67, 71]));
|
|
891
|
-
});
|
|
892
|
-
|
|
893
|
-
it("buildStartKeyUpdateRequest", () => {
|
|
894
|
-
const method: SelectedKeyNegotiationMethodTLV = {
|
|
895
|
-
protocol: Zdo.SelectedKeyNegotiationProtocol.SPEKE_CURVE25519_SHA256,
|
|
896
|
-
presharedSecret: Zdo.SelectedPreSharedSecret.BASIC_AUTHORIZATION_KEY,
|
|
897
|
-
sendingDeviceEui64: IEEE_ADDRESS2,
|
|
898
|
-
};
|
|
899
|
-
const params: FragmentationParametersGlobalTLV = {
|
|
900
|
-
nwkAddress: NODE_ID1,
|
|
901
|
-
fragmentationOptions: 1,
|
|
902
|
-
maxIncomingTransferUnit: 2345,
|
|
903
|
-
};
|
|
904
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.START_KEY_UPDATE_REQUEST, method, params)).toStrictEqual(
|
|
905
|
-
Buffer.from([
|
|
906
|
-
0,
|
|
907
|
-
0,
|
|
908
|
-
ZSpec.EUI64_SIZE + 2 - 1,
|
|
909
|
-
method.protocol,
|
|
910
|
-
method.presharedSecret,
|
|
911
|
-
...IEEE_ADDRESS2_BYTES,
|
|
912
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
913
|
-
5 - 1,
|
|
914
|
-
...NODE_ID1_BYTES,
|
|
915
|
-
params.fragmentationOptions!,
|
|
916
|
-
...uint16To8Array(params.maxIncomingTransferUnit!),
|
|
917
|
-
]),
|
|
918
|
-
);
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
it("buildDecommissionRequest", () => {
|
|
922
|
-
const tlv: DeviceEUI64ListTLV = {
|
|
923
|
-
eui64List: [IEEE_ADDRESS1],
|
|
924
|
-
};
|
|
925
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.DECOMMISSION_REQUEST, tlv)).toStrictEqual(
|
|
926
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE * tlv.eui64List.length + 1 - 1, tlv.eui64List.length, ...IEEE_ADDRESS1_BYTES]),
|
|
927
|
-
);
|
|
928
|
-
|
|
929
|
-
const tlv2: DeviceEUI64ListTLV = {
|
|
930
|
-
eui64List: [IEEE_ADDRESS2, IEEE_ADDRESS1],
|
|
931
|
-
};
|
|
932
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.DECOMMISSION_REQUEST, tlv2)).toStrictEqual(
|
|
933
|
-
Buffer.from([
|
|
934
|
-
0,
|
|
935
|
-
0,
|
|
936
|
-
ZSpec.EUI64_SIZE * tlv2.eui64List.length + 1 - 1,
|
|
937
|
-
tlv2.eui64List.length,
|
|
938
|
-
...IEEE_ADDRESS2_BYTES,
|
|
939
|
-
...IEEE_ADDRESS1_BYTES,
|
|
940
|
-
]),
|
|
941
|
-
);
|
|
942
|
-
|
|
943
|
-
const tlv3: DeviceEUI64ListTLV = {
|
|
944
|
-
eui64List: [],
|
|
945
|
-
};
|
|
946
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.DECOMMISSION_REQUEST, tlv3)).toStrictEqual(
|
|
947
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE * tlv3.eui64List.length + 1 - 1, tlv3.eui64List.length]),
|
|
948
|
-
);
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
it("buildChallengeRequest", () => {
|
|
952
|
-
const tlv: APSFrameCounterChallengeTLV = {
|
|
953
|
-
senderEui64: IEEE_ADDRESS2,
|
|
954
|
-
challengeValue: Buffer.alloc(Zdo.CHALLENGE_VALUE_SIZE).fill(0xfe),
|
|
955
|
-
};
|
|
956
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.CHALLENGE_REQUEST, tlv)).toStrictEqual(
|
|
957
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE + Zdo.CHALLENGE_VALUE_SIZE - 1, ...IEEE_ADDRESS2_BYTES, ...tlv.challengeValue]),
|
|
958
|
-
);
|
|
959
|
-
|
|
960
|
-
const tlv2: APSFrameCounterChallengeTLV = {
|
|
961
|
-
senderEui64: IEEE_ADDRESS1,
|
|
962
|
-
challengeValue: Buffer.from([0xfe, 0xac, 0x12, 0x23, 0x85, 0x8c, 0x7c, 0xa3]),
|
|
963
|
-
};
|
|
964
|
-
expect(Zdo.Buffalo.buildRequest(true, Zdo.ClusterId.CHALLENGE_REQUEST, tlv2)).toStrictEqual(
|
|
965
|
-
Buffer.from([0, 0, ZSpec.EUI64_SIZE + Zdo.CHALLENGE_VALUE_SIZE - 1, ...IEEE_ADDRESS1_BYTES, ...tlv2.challengeValue]),
|
|
966
|
-
);
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
it.each([
|
|
970
|
-
Zdo.ClusterId.NETWORK_ADDRESS_RESPONSE,
|
|
971
|
-
Zdo.ClusterId.IEEE_ADDRESS_RESPONSE,
|
|
972
|
-
Zdo.ClusterId.NODE_DESCRIPTOR_RESPONSE,
|
|
973
|
-
Zdo.ClusterId.POWER_DESCRIPTOR_RESPONSE,
|
|
974
|
-
Zdo.ClusterId.SIMPLE_DESCRIPTOR_RESPONSE,
|
|
975
|
-
Zdo.ClusterId.ACTIVE_ENDPOINTS_RESPONSE,
|
|
976
|
-
Zdo.ClusterId.MATCH_DESCRIPTORS_RESPONSE,
|
|
977
|
-
Zdo.ClusterId.SYSTEM_SERVER_DISCOVERY_RESPONSE,
|
|
978
|
-
Zdo.ClusterId.PARENT_ANNOUNCE_RESPONSE,
|
|
979
|
-
Zdo.ClusterId.BIND_RESPONSE,
|
|
980
|
-
Zdo.ClusterId.UNBIND_RESPONSE,
|
|
981
|
-
Zdo.ClusterId.CLEAR_ALL_BINDINGS_RESPONSE,
|
|
982
|
-
Zdo.ClusterId.LQI_TABLE_RESPONSE,
|
|
983
|
-
Zdo.ClusterId.ROUTING_TABLE_RESPONSE,
|
|
984
|
-
Zdo.ClusterId.BINDING_TABLE_RESPONSE,
|
|
985
|
-
Zdo.ClusterId.LEAVE_RESPONSE,
|
|
986
|
-
Zdo.ClusterId.PERMIT_JOINING_RESPONSE,
|
|
987
|
-
Zdo.ClusterId.NWK_UPDATE_RESPONSE,
|
|
988
|
-
Zdo.ClusterId.NWK_ENHANCED_UPDATE_RESPONSE,
|
|
989
|
-
Zdo.ClusterId.NWK_IEEE_JOINING_LIST_RESPONSE,
|
|
990
|
-
Zdo.ClusterId.NWK_UNSOLICITED_ENHANCED_UPDATE_RESPONSE,
|
|
991
|
-
Zdo.ClusterId.NWK_BEACON_SURVEY_RESPONSE,
|
|
992
|
-
Zdo.ClusterId.START_KEY_NEGOTIATION_RESPONSE,
|
|
993
|
-
Zdo.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_RESPONSE,
|
|
994
|
-
Zdo.ClusterId.GET_AUTHENTICATION_LEVEL_RESPONSE,
|
|
995
|
-
Zdo.ClusterId.SET_CONFIGURATION_RESPONSE,
|
|
996
|
-
Zdo.ClusterId.GET_CONFIGURATION_RESPONSE,
|
|
997
|
-
Zdo.ClusterId.START_KEY_UPDATE_RESPONSE,
|
|
998
|
-
Zdo.ClusterId.DECOMMISSION_RESPONSE,
|
|
999
|
-
Zdo.ClusterId.CHALLENGE_RESPONSE,
|
|
1000
|
-
])("Returns status and undefined when reading unsuccessful response for %s", (clusterId) => {
|
|
1001
|
-
const buffer = Buffer.from([1, Zdo.Status.INV_REQUESTTYPE, 1, 2, 3]);
|
|
1002
|
-
expect(Zdo.Buffalo.readResponse(true, clusterId, buffer)).toStrictEqual([Zdo.Status.INV_REQUESTTYPE, undefined]);
|
|
1003
|
-
});
|
|
1004
|
-
|
|
1005
|
-
it("Throws when reading unknown cluster ID", () => {
|
|
1006
|
-
const clusterId = 0x0005;
|
|
1007
|
-
|
|
1008
|
-
expect(() => {
|
|
1009
|
-
BuffaloZdo.readResponse(true, clusterId, Buffer.from([1, 123]));
|
|
1010
|
-
}).toThrow(`Unsupported response reading for cluster ID '${clusterId}'.`);
|
|
1011
|
-
});
|
|
1012
|
-
|
|
1013
|
-
it("readNetworkAddressResponse", () => {
|
|
1014
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...IEEE_ADDRESS1_BYTES, ...NODE_ID1_BYTES]);
|
|
1015
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NETWORK_ADDRESS_RESPONSE, buffer)).toStrictEqual([
|
|
1016
|
-
Zdo.Status.SUCCESS,
|
|
1017
|
-
{
|
|
1018
|
-
eui64: IEEE_ADDRESS1,
|
|
1019
|
-
nwkAddress: NODE_ID1,
|
|
1020
|
-
startIndex: 0,
|
|
1021
|
-
assocDevList: [],
|
|
1022
|
-
} as NetworkAddressResponse,
|
|
1023
|
-
]);
|
|
1024
|
-
const bufferWAssoc = Buffer.from([
|
|
1025
|
-
1,
|
|
1026
|
-
Zdo.Status.SUCCESS,
|
|
1027
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1028
|
-
...NODE_ID1_BYTES,
|
|
1029
|
-
2,
|
|
1030
|
-
3,
|
|
1031
|
-
...uint16To8Array(123),
|
|
1032
|
-
...uint16To8Array(52523),
|
|
1033
|
-
]);
|
|
1034
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NETWORK_ADDRESS_RESPONSE, bufferWAssoc)).toStrictEqual([
|
|
1035
|
-
Zdo.Status.SUCCESS,
|
|
1036
|
-
{
|
|
1037
|
-
eui64: IEEE_ADDRESS2,
|
|
1038
|
-
nwkAddress: NODE_ID1,
|
|
1039
|
-
startIndex: 3,
|
|
1040
|
-
assocDevList: [123, 52523],
|
|
1041
|
-
} as NetworkAddressResponse,
|
|
1042
|
-
]);
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
it("readIEEEAddressResponse", () => {
|
|
1046
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...IEEE_ADDRESS1_BYTES, ...NODE_ID1_BYTES]);
|
|
1047
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.IEEE_ADDRESS_RESPONSE, buffer)).toStrictEqual([
|
|
1048
|
-
Zdo.Status.SUCCESS,
|
|
1049
|
-
{
|
|
1050
|
-
eui64: IEEE_ADDRESS1,
|
|
1051
|
-
nwkAddress: NODE_ID1,
|
|
1052
|
-
startIndex: 0,
|
|
1053
|
-
assocDevList: [],
|
|
1054
|
-
} as IEEEAddressResponse,
|
|
1055
|
-
]);
|
|
1056
|
-
const bufferWAssoc = Buffer.from([
|
|
1057
|
-
1,
|
|
1058
|
-
Zdo.Status.SUCCESS,
|
|
1059
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1060
|
-
...NODE_ID1_BYTES,
|
|
1061
|
-
2,
|
|
1062
|
-
3,
|
|
1063
|
-
...uint16To8Array(123),
|
|
1064
|
-
...uint16To8Array(52523),
|
|
1065
|
-
]);
|
|
1066
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.IEEE_ADDRESS_RESPONSE, bufferWAssoc)).toStrictEqual([
|
|
1067
|
-
Zdo.Status.SUCCESS,
|
|
1068
|
-
{
|
|
1069
|
-
eui64: IEEE_ADDRESS2,
|
|
1070
|
-
nwkAddress: NODE_ID1,
|
|
1071
|
-
startIndex: 3,
|
|
1072
|
-
assocDevList: [123, 52523],
|
|
1073
|
-
} as IEEEAddressResponse,
|
|
1074
|
-
]);
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
it("readNodeDescriptorResponse", () => {
|
|
1078
|
-
const buffer = Buffer.from([
|
|
1079
|
-
1,
|
|
1080
|
-
Zdo.Status.SUCCESS,
|
|
1081
|
-
...NODE_ID1_BYTES,
|
|
1082
|
-
0b00100010,
|
|
1083
|
-
0b00100000,
|
|
1084
|
-
0b00001110,
|
|
1085
|
-
...uint16To8Array(Zcl.ManufacturerCode.BARACODA_SA),
|
|
1086
|
-
0x7c,
|
|
1087
|
-
...uint16To8Array(0x7eff),
|
|
1088
|
-
...uint16To8Array(SERVER_MASK_R22_BYTE),
|
|
1089
|
-
...uint16To8Array(0x3cff),
|
|
1090
|
-
0,
|
|
1091
|
-
]);
|
|
1092
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NODE_DESCRIPTOR_RESPONSE, buffer)).toStrictEqual([
|
|
1093
|
-
Zdo.Status.SUCCESS,
|
|
1094
|
-
{
|
|
1095
|
-
nwkAddress: NODE_ID1,
|
|
1096
|
-
logicalType: 0b010,
|
|
1097
|
-
fragmentationSupported: undefined,
|
|
1098
|
-
apsFlags: 0,
|
|
1099
|
-
frequencyBand: 0b00100,
|
|
1100
|
-
capabilities: {
|
|
1101
|
-
alternatePANCoordinator: 0,
|
|
1102
|
-
deviceType: 1,
|
|
1103
|
-
powerSource: 1,
|
|
1104
|
-
rxOnWhenIdle: 1,
|
|
1105
|
-
reserved1: 0,
|
|
1106
|
-
reserved2: 0,
|
|
1107
|
-
securityCapability: 0,
|
|
1108
|
-
allocateAddress: 0,
|
|
1109
|
-
},
|
|
1110
|
-
manufacturerCode: Zcl.ManufacturerCode.BARACODA_SA,
|
|
1111
|
-
maxBufSize: 0x7c,
|
|
1112
|
-
maxIncTxSize: 0x7eff,
|
|
1113
|
-
serverMask: SERVER_MASK_R22,
|
|
1114
|
-
maxOutTxSize: 0x3cff,
|
|
1115
|
-
deprecated1: 0,
|
|
1116
|
-
tlvs: [],
|
|
1117
|
-
} as NodeDescriptorResponse,
|
|
1118
|
-
]);
|
|
1119
|
-
|
|
1120
|
-
const tlv: FragmentationParametersGlobalTLV = {
|
|
1121
|
-
nwkAddress: NODE_ID1,
|
|
1122
|
-
fragmentationOptions: 1,
|
|
1123
|
-
maxIncomingTransferUnit: 65352,
|
|
1124
|
-
};
|
|
1125
|
-
const buffer2 = Buffer.from([
|
|
1126
|
-
1,
|
|
1127
|
-
Zdo.Status.SUCCESS,
|
|
1128
|
-
...NODE_ID1_BYTES,
|
|
1129
|
-
0b00100010,
|
|
1130
|
-
0b00100000,
|
|
1131
|
-
0b00001110,
|
|
1132
|
-
...uint16To8Array(Zcl.ManufacturerCode.BEIJING_RUYING_TECH_LIMITED),
|
|
1133
|
-
0x3a,
|
|
1134
|
-
...uint16To8Array(0x7cff),
|
|
1135
|
-
...uint16To8Array(SERVER_MASK_R23_BYTE),
|
|
1136
|
-
...uint16To8Array(0x11ff),
|
|
1137
|
-
0,
|
|
1138
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
1139
|
-
5 - 1,
|
|
1140
|
-
...uint16To8Array(tlv.nwkAddress),
|
|
1141
|
-
tlv.fragmentationOptions!,
|
|
1142
|
-
...uint16To8Array(tlv.maxIncomingTransferUnit!),
|
|
1143
|
-
]);
|
|
1144
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NODE_DESCRIPTOR_RESPONSE, buffer2)).toStrictEqual([
|
|
1145
|
-
Zdo.Status.SUCCESS,
|
|
1146
|
-
{
|
|
1147
|
-
nwkAddress: NODE_ID1,
|
|
1148
|
-
logicalType: 0b010,
|
|
1149
|
-
fragmentationSupported: true,
|
|
1150
|
-
apsFlags: 0,
|
|
1151
|
-
frequencyBand: 0b00100,
|
|
1152
|
-
capabilities: {
|
|
1153
|
-
alternatePANCoordinator: 0,
|
|
1154
|
-
deviceType: 1,
|
|
1155
|
-
powerSource: 1,
|
|
1156
|
-
rxOnWhenIdle: 1,
|
|
1157
|
-
reserved1: 0,
|
|
1158
|
-
reserved2: 0,
|
|
1159
|
-
securityCapability: 0,
|
|
1160
|
-
allocateAddress: 0,
|
|
1161
|
-
},
|
|
1162
|
-
manufacturerCode: Zcl.ManufacturerCode.BEIJING_RUYING_TECH_LIMITED,
|
|
1163
|
-
maxBufSize: 0x3a,
|
|
1164
|
-
maxIncTxSize: 0x7cff,
|
|
1165
|
-
serverMask: SERVER_MASK_R23,
|
|
1166
|
-
maxOutTxSize: 0x11ff,
|
|
1167
|
-
deprecated1: 0,
|
|
1168
|
-
tlvs: [{tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, length: 5, tlv}],
|
|
1169
|
-
} as NodeDescriptorResponse,
|
|
1170
|
-
]);
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
it("readPowerDescriptorResponse", () => {
|
|
1174
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...NODE_ID1_BYTES, 0b10100100, 0b11110100]);
|
|
1175
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.POWER_DESCRIPTOR_RESPONSE, buffer)).toStrictEqual([
|
|
1176
|
-
Zdo.Status.SUCCESS,
|
|
1177
|
-
{
|
|
1178
|
-
nwkAddress: NODE_ID1,
|
|
1179
|
-
currentPowerMode: 0b0100,
|
|
1180
|
-
availPowerSources: 0b1010,
|
|
1181
|
-
currentPowerSource: 0b0100,
|
|
1182
|
-
currentPowerSourceLevel: 0b1111,
|
|
1183
|
-
} as PowerDescriptorResponse,
|
|
1184
|
-
]);
|
|
1185
|
-
});
|
|
1186
|
-
|
|
1187
|
-
it("readSimpleDescriptorResponse", () => {
|
|
1188
|
-
const buffer = Buffer.from([
|
|
1189
|
-
1,
|
|
1190
|
-
Zdo.Status.SUCCESS,
|
|
1191
|
-
...NODE_ID1_BYTES,
|
|
1192
|
-
8,
|
|
1193
|
-
ZSpec.HA_ENDPOINT,
|
|
1194
|
-
...uint16To8Array(ZSpec.HA_PROFILE_ID),
|
|
1195
|
-
...uint16To8Array(123),
|
|
1196
|
-
0,
|
|
1197
|
-
2,
|
|
1198
|
-
...uint16To8Array(7653),
|
|
1199
|
-
...uint16To8Array(624),
|
|
1200
|
-
1,
|
|
1201
|
-
...uint16To8Array(5322),
|
|
1202
|
-
]);
|
|
1203
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.SIMPLE_DESCRIPTOR_RESPONSE, buffer)).toStrictEqual([
|
|
1204
|
-
Zdo.Status.SUCCESS,
|
|
1205
|
-
{
|
|
1206
|
-
nwkAddress: NODE_ID1,
|
|
1207
|
-
length: 8,
|
|
1208
|
-
endpoint: ZSpec.HA_ENDPOINT,
|
|
1209
|
-
profileId: ZSpec.HA_PROFILE_ID,
|
|
1210
|
-
deviceId: 123,
|
|
1211
|
-
deviceVersion: 0,
|
|
1212
|
-
inClusterList: [7653, 624],
|
|
1213
|
-
outClusterList: [5322],
|
|
1214
|
-
} as SimpleDescriptorResponse,
|
|
1215
|
-
]);
|
|
1216
|
-
const bufferEmpty = Buffer.from([
|
|
1217
|
-
1,
|
|
1218
|
-
Zdo.Status.SUCCESS,
|
|
1219
|
-
...NODE_ID1_BYTES,
|
|
1220
|
-
8,
|
|
1221
|
-
ZSpec.HA_ENDPOINT,
|
|
1222
|
-
...uint16To8Array(ZSpec.HA_PROFILE_ID),
|
|
1223
|
-
...uint16To8Array(123),
|
|
1224
|
-
0,
|
|
1225
|
-
0,
|
|
1226
|
-
0,
|
|
1227
|
-
]);
|
|
1228
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.SIMPLE_DESCRIPTOR_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1229
|
-
Zdo.Status.SUCCESS,
|
|
1230
|
-
{
|
|
1231
|
-
nwkAddress: NODE_ID1,
|
|
1232
|
-
length: 8,
|
|
1233
|
-
endpoint: ZSpec.HA_ENDPOINT,
|
|
1234
|
-
profileId: ZSpec.HA_PROFILE_ID,
|
|
1235
|
-
deviceId: 123,
|
|
1236
|
-
deviceVersion: 0,
|
|
1237
|
-
inClusterList: [],
|
|
1238
|
-
outClusterList: [],
|
|
1239
|
-
} as SimpleDescriptorResponse,
|
|
1240
|
-
]);
|
|
1241
|
-
});
|
|
1242
|
-
|
|
1243
|
-
it("readActiveEndpointsResponse", () => {
|
|
1244
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...NODE_ID1_BYTES, 2, 0xef, 0x87]);
|
|
1245
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.ACTIVE_ENDPOINTS_RESPONSE, buffer)).toStrictEqual([
|
|
1246
|
-
Zdo.Status.SUCCESS,
|
|
1247
|
-
{
|
|
1248
|
-
nwkAddress: NODE_ID1,
|
|
1249
|
-
endpointList: [0xef, 0x87],
|
|
1250
|
-
} as ActiveEndpointsResponse,
|
|
1251
|
-
]);
|
|
1252
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, ...NODE_ID1_BYTES, 0]);
|
|
1253
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.ACTIVE_ENDPOINTS_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1254
|
-
Zdo.Status.SUCCESS,
|
|
1255
|
-
{
|
|
1256
|
-
nwkAddress: NODE_ID1,
|
|
1257
|
-
endpointList: [],
|
|
1258
|
-
} as ActiveEndpointsResponse,
|
|
1259
|
-
]);
|
|
1260
|
-
});
|
|
1261
|
-
|
|
1262
|
-
it("readMatchDescriptorsResponse", () => {
|
|
1263
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...NODE_ID1_BYTES, 2, 0xef, 0x87]);
|
|
1264
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.MATCH_DESCRIPTORS_RESPONSE, buffer)).toStrictEqual([
|
|
1265
|
-
Zdo.Status.SUCCESS,
|
|
1266
|
-
{
|
|
1267
|
-
nwkAddress: NODE_ID1,
|
|
1268
|
-
endpointList: [0xef, 0x87],
|
|
1269
|
-
} as MatchDescriptorsResponse,
|
|
1270
|
-
]);
|
|
1271
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, ...NODE_ID1_BYTES, 0]);
|
|
1272
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.MATCH_DESCRIPTORS_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1273
|
-
Zdo.Status.SUCCESS,
|
|
1274
|
-
{
|
|
1275
|
-
nwkAddress: NODE_ID1,
|
|
1276
|
-
endpointList: [],
|
|
1277
|
-
} as MatchDescriptorsResponse,
|
|
1278
|
-
]);
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
it("readEndDeviceAnnounce", () => {
|
|
1282
|
-
const buffer = Buffer.from([1, ...NODE_ID1_BYTES, ...IEEE_ADDRESS2_BYTES, 0b01000000]);
|
|
1283
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.END_DEVICE_ANNOUNCE, buffer)).toStrictEqual([
|
|
1284
|
-
Zdo.Status.SUCCESS,
|
|
1285
|
-
{
|
|
1286
|
-
nwkAddress: NODE_ID1,
|
|
1287
|
-
eui64: IEEE_ADDRESS2,
|
|
1288
|
-
capabilities: {
|
|
1289
|
-
alternatePANCoordinator: 0,
|
|
1290
|
-
deviceType: 0,
|
|
1291
|
-
powerSource: 0,
|
|
1292
|
-
rxOnWhenIdle: 0,
|
|
1293
|
-
reserved1: 0,
|
|
1294
|
-
reserved2: 0,
|
|
1295
|
-
securityCapability: 1,
|
|
1296
|
-
allocateAddress: 0,
|
|
1297
|
-
},
|
|
1298
|
-
} as EndDeviceAnnounce,
|
|
1299
|
-
]);
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
it("readSystemServerDiscoveryResponse", () => {
|
|
1303
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, ...uint16To8Array(SERVER_MASK_R23_BYTE)]);
|
|
1304
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.SYSTEM_SERVER_DISCOVERY_RESPONSE, buffer)).toStrictEqual([
|
|
1305
|
-
Zdo.Status.SUCCESS,
|
|
1306
|
-
{
|
|
1307
|
-
serverMask: SERVER_MASK_R23,
|
|
1308
|
-
} as SystemServerDiscoveryResponse,
|
|
1309
|
-
]);
|
|
1310
|
-
});
|
|
1311
|
-
|
|
1312
|
-
it("readParentAnnounceResponse", () => {
|
|
1313
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, 2, ...IEEE_ADDRESS2_BYTES, ...IEEE_ADDRESS1_BYTES]);
|
|
1314
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.PARENT_ANNOUNCE_RESPONSE, buffer)).toStrictEqual([
|
|
1315
|
-
Zdo.Status.SUCCESS,
|
|
1316
|
-
{
|
|
1317
|
-
children: [IEEE_ADDRESS2, IEEE_ADDRESS1],
|
|
1318
|
-
},
|
|
1319
|
-
]);
|
|
1320
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 0]);
|
|
1321
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.PARENT_ANNOUNCE_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1322
|
-
Zdo.Status.SUCCESS,
|
|
1323
|
-
{
|
|
1324
|
-
children: [],
|
|
1325
|
-
},
|
|
1326
|
-
]);
|
|
1327
|
-
});
|
|
1328
|
-
|
|
1329
|
-
it("readLQITableResponse", () => {
|
|
1330
|
-
const buffer = Buffer.from([
|
|
1331
|
-
1,
|
|
1332
|
-
Zdo.Status.SUCCESS,
|
|
1333
|
-
16,
|
|
1334
|
-
3,
|
|
1335
|
-
2,
|
|
1336
|
-
...EXT_PAN_ID2,
|
|
1337
|
-
...IEEE_ADDRESS1_BYTES,
|
|
1338
|
-
...NODE_ID2_BYTES,
|
|
1339
|
-
0b00100101,
|
|
1340
|
-
0b00000001,
|
|
1341
|
-
1,
|
|
1342
|
-
235,
|
|
1343
|
-
...EXT_PAN_ID1,
|
|
1344
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1345
|
-
...NODE_ID1_BYTES,
|
|
1346
|
-
0b01000010,
|
|
1347
|
-
0b00000000,
|
|
1348
|
-
1,
|
|
1349
|
-
179,
|
|
1350
|
-
]);
|
|
1351
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.LQI_TABLE_RESPONSE, buffer)).toStrictEqual([
|
|
1352
|
-
Zdo.Status.SUCCESS,
|
|
1353
|
-
{
|
|
1354
|
-
neighborTableEntries: 16,
|
|
1355
|
-
startIndex: 3,
|
|
1356
|
-
entryList: [
|
|
1357
|
-
{
|
|
1358
|
-
extendedPanId: EXT_PAN_ID2,
|
|
1359
|
-
eui64: IEEE_ADDRESS1,
|
|
1360
|
-
nwkAddress: NODE_ID2,
|
|
1361
|
-
deviceType: 1,
|
|
1362
|
-
rxOnWhenIdle: 1,
|
|
1363
|
-
relationship: 2,
|
|
1364
|
-
reserved1: 0,
|
|
1365
|
-
permitJoining: 1,
|
|
1366
|
-
reserved2: 0,
|
|
1367
|
-
depth: 1,
|
|
1368
|
-
lqi: 235,
|
|
1369
|
-
},
|
|
1370
|
-
{
|
|
1371
|
-
extendedPanId: EXT_PAN_ID1,
|
|
1372
|
-
eui64: IEEE_ADDRESS2,
|
|
1373
|
-
nwkAddress: NODE_ID1,
|
|
1374
|
-
deviceType: 2,
|
|
1375
|
-
rxOnWhenIdle: 0,
|
|
1376
|
-
relationship: 4,
|
|
1377
|
-
reserved1: 0,
|
|
1378
|
-
permitJoining: 0,
|
|
1379
|
-
reserved2: 0,
|
|
1380
|
-
depth: 1,
|
|
1381
|
-
lqi: 179,
|
|
1382
|
-
},
|
|
1383
|
-
],
|
|
1384
|
-
} as LQITableResponse,
|
|
1385
|
-
]);
|
|
1386
|
-
|
|
1387
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 5, 4, 0]);
|
|
1388
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.LQI_TABLE_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1389
|
-
Zdo.Status.SUCCESS,
|
|
1390
|
-
{
|
|
1391
|
-
neighborTableEntries: 5,
|
|
1392
|
-
startIndex: 4,
|
|
1393
|
-
entryList: [],
|
|
1394
|
-
} as LQITableResponse,
|
|
1395
|
-
]);
|
|
1396
|
-
});
|
|
1397
|
-
|
|
1398
|
-
it("readRoutingTableResponse", () => {
|
|
1399
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, 4, 3, 1, ...NODE_ID2_BYTES, 0b00101000, ...NODE_ID1_BYTES]);
|
|
1400
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.ROUTING_TABLE_RESPONSE, buffer)).toStrictEqual([
|
|
1401
|
-
Zdo.Status.SUCCESS,
|
|
1402
|
-
{
|
|
1403
|
-
routingTableEntries: 4,
|
|
1404
|
-
startIndex: 3,
|
|
1405
|
-
entryList: [
|
|
1406
|
-
{
|
|
1407
|
-
destinationAddress: NODE_ID2,
|
|
1408
|
-
status: Zdo.RoutingTableStatus[0],
|
|
1409
|
-
memoryConstrained: 1,
|
|
1410
|
-
manyToOne: 0,
|
|
1411
|
-
routeRecordRequired: 1,
|
|
1412
|
-
reserved1: 0,
|
|
1413
|
-
nextHopAddress: NODE_ID1,
|
|
1414
|
-
},
|
|
1415
|
-
],
|
|
1416
|
-
} as RoutingTableResponse,
|
|
1417
|
-
]);
|
|
1418
|
-
|
|
1419
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 0, 0, 0]);
|
|
1420
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.ROUTING_TABLE_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1421
|
-
Zdo.Status.SUCCESS,
|
|
1422
|
-
{
|
|
1423
|
-
routingTableEntries: 0,
|
|
1424
|
-
startIndex: 0,
|
|
1425
|
-
entryList: [],
|
|
1426
|
-
} as RoutingTableResponse,
|
|
1427
|
-
]);
|
|
1428
|
-
});
|
|
1429
|
-
|
|
1430
|
-
it("readBindingTableResponse", () => {
|
|
1431
|
-
const buffer = Buffer.from([
|
|
1432
|
-
1,
|
|
1433
|
-
Zdo.Status.SUCCESS,
|
|
1434
|
-
1,
|
|
1435
|
-
0,
|
|
1436
|
-
3,
|
|
1437
|
-
...IEEE_ADDRESS1_BYTES,
|
|
1438
|
-
0xf0,
|
|
1439
|
-
...uint16To8Array(Zcl.Clusters.barrierControl.ID),
|
|
1440
|
-
0x03,
|
|
1441
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1442
|
-
ZSpec.GP_ENDPOINT,
|
|
1443
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1444
|
-
0x34,
|
|
1445
|
-
...uint16To8Array(Zcl.Clusters.closuresShadeCfg.ID),
|
|
1446
|
-
0x01,
|
|
1447
|
-
...NODE_ID2_BYTES,
|
|
1448
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1449
|
-
0xf4,
|
|
1450
|
-
...uint16To8Array(Zcl.Clusters.genAnalogInput.ID),
|
|
1451
|
-
0x02,
|
|
1452
|
-
]);
|
|
1453
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.BINDING_TABLE_RESPONSE, buffer)).toStrictEqual([
|
|
1454
|
-
Zdo.Status.SUCCESS,
|
|
1455
|
-
{
|
|
1456
|
-
bindingTableEntries: 1,
|
|
1457
|
-
startIndex: 0,
|
|
1458
|
-
entryList: [
|
|
1459
|
-
{
|
|
1460
|
-
sourceEui64: IEEE_ADDRESS1,
|
|
1461
|
-
sourceEndpoint: 0xf0,
|
|
1462
|
-
clusterId: Zcl.Clusters.barrierControl.ID,
|
|
1463
|
-
destAddrMode: 0x03,
|
|
1464
|
-
dest: IEEE_ADDRESS2,
|
|
1465
|
-
destEndpoint: ZSpec.GP_ENDPOINT,
|
|
1466
|
-
},
|
|
1467
|
-
{
|
|
1468
|
-
sourceEui64: IEEE_ADDRESS2,
|
|
1469
|
-
sourceEndpoint: 0x34,
|
|
1470
|
-
clusterId: Zcl.Clusters.closuresShadeCfg.ID,
|
|
1471
|
-
destAddrMode: 0x01,
|
|
1472
|
-
dest: NODE_ID2,
|
|
1473
|
-
destEndpoint: undefined,
|
|
1474
|
-
},
|
|
1475
|
-
// invalid destAddrMode is ignored
|
|
1476
|
-
// {
|
|
1477
|
-
// sourceEui64: IEEE_ADDRESS2,
|
|
1478
|
-
// sourceEndpoint: 0xf4,
|
|
1479
|
-
// clusterId: Zcl.Clusters.genAnalogInput.ID,
|
|
1480
|
-
// destAddrMode: 0x02,
|
|
1481
|
-
// dest: undefined,
|
|
1482
|
-
// destEndpoint: undefined,
|
|
1483
|
-
// },
|
|
1484
|
-
],
|
|
1485
|
-
} as BindingTableResponse,
|
|
1486
|
-
]);
|
|
1487
|
-
|
|
1488
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 30, 2, 0]);
|
|
1489
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.BINDING_TABLE_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1490
|
-
Zdo.Status.SUCCESS,
|
|
1491
|
-
{
|
|
1492
|
-
bindingTableEntries: 30,
|
|
1493
|
-
startIndex: 2,
|
|
1494
|
-
entryList: [],
|
|
1495
|
-
} as BindingTableResponse,
|
|
1496
|
-
]);
|
|
1497
|
-
});
|
|
1498
|
-
|
|
1499
|
-
it("readNwkUpdateResponse", () => {
|
|
1500
|
-
const buffer = Buffer.from([
|
|
1501
|
-
1,
|
|
1502
|
-
Zdo.Status.SUCCESS,
|
|
1503
|
-
...uint32To8Array(34732495),
|
|
1504
|
-
...uint16To8Array(445),
|
|
1505
|
-
...uint16To8Array(34),
|
|
1506
|
-
3,
|
|
1507
|
-
0x43,
|
|
1508
|
-
0xff,
|
|
1509
|
-
0x6f,
|
|
1510
|
-
]);
|
|
1511
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_UPDATE_RESPONSE, buffer)).toStrictEqual([
|
|
1512
|
-
Zdo.Status.SUCCESS,
|
|
1513
|
-
{
|
|
1514
|
-
scannedChannels: 34732495,
|
|
1515
|
-
totalTransmissions: 445,
|
|
1516
|
-
totalFailures: 34,
|
|
1517
|
-
entryList: [0x43, 0xff, 0x6f],
|
|
1518
|
-
} as NwkUpdateResponse,
|
|
1519
|
-
]);
|
|
1520
|
-
});
|
|
1521
|
-
|
|
1522
|
-
it("readNwkEnhancedUpdateResponse", () => {
|
|
1523
|
-
const buffer = Buffer.from([
|
|
1524
|
-
1,
|
|
1525
|
-
Zdo.Status.SUCCESS,
|
|
1526
|
-
...uint32To8Array(34732495),
|
|
1527
|
-
...uint16To8Array(445),
|
|
1528
|
-
...uint16To8Array(34),
|
|
1529
|
-
3,
|
|
1530
|
-
0x43,
|
|
1531
|
-
0xff,
|
|
1532
|
-
0x6f,
|
|
1533
|
-
]);
|
|
1534
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_ENHANCED_UPDATE_RESPONSE, buffer)).toStrictEqual([
|
|
1535
|
-
Zdo.Status.SUCCESS,
|
|
1536
|
-
{
|
|
1537
|
-
scannedChannels: 34732495,
|
|
1538
|
-
totalTransmissions: 445,
|
|
1539
|
-
totalFailures: 34,
|
|
1540
|
-
entryList: [0x43, 0xff, 0x6f],
|
|
1541
|
-
} as NwkEnhancedUpdateResponse,
|
|
1542
|
-
]);
|
|
1543
|
-
});
|
|
1544
|
-
|
|
1545
|
-
it("readNwkIEEEJoiningListResponse", () => {
|
|
1546
|
-
const buffer = Buffer.from([
|
|
1547
|
-
1,
|
|
1548
|
-
Zdo.Status.SUCCESS,
|
|
1549
|
-
3,
|
|
1550
|
-
Zdo.JoiningPolicy.IEEELIST_JOIN,
|
|
1551
|
-
4,
|
|
1552
|
-
0,
|
|
1553
|
-
2,
|
|
1554
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1555
|
-
...IEEE_ADDRESS1_BYTES,
|
|
1556
|
-
]);
|
|
1557
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_IEEE_JOINING_LIST_RESPONSE, buffer)).toStrictEqual([
|
|
1558
|
-
Zdo.Status.SUCCESS,
|
|
1559
|
-
{
|
|
1560
|
-
updateId: 3,
|
|
1561
|
-
joiningPolicy: Zdo.JoiningPolicy.IEEELIST_JOIN,
|
|
1562
|
-
entryListTotal: 4,
|
|
1563
|
-
startIndex: 0,
|
|
1564
|
-
entryList: [IEEE_ADDRESS2, IEEE_ADDRESS1],
|
|
1565
|
-
} as NwkIEEEJoiningListResponse,
|
|
1566
|
-
]);
|
|
1567
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 0xff, Zdo.JoiningPolicy.ALL_JOIN, 0]);
|
|
1568
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_IEEE_JOINING_LIST_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1569
|
-
Zdo.Status.SUCCESS,
|
|
1570
|
-
{
|
|
1571
|
-
updateId: 0xff,
|
|
1572
|
-
joiningPolicy: Zdo.JoiningPolicy.ALL_JOIN,
|
|
1573
|
-
entryListTotal: 0,
|
|
1574
|
-
startIndex: undefined,
|
|
1575
|
-
entryList: undefined,
|
|
1576
|
-
} as NwkIEEEJoiningListResponse,
|
|
1577
|
-
]);
|
|
1578
|
-
});
|
|
1579
|
-
|
|
1580
|
-
it("readNwkUnsolicitedEnhancedUpdateResponse", () => {
|
|
1581
|
-
const buffer = Buffer.from([
|
|
1582
|
-
1,
|
|
1583
|
-
Zdo.Status.SUCCESS,
|
|
1584
|
-
...uint32To8Array(9023342),
|
|
1585
|
-
...uint16To8Array(3454),
|
|
1586
|
-
...uint16To8Array(435),
|
|
1587
|
-
...uint16To8Array(1239),
|
|
1588
|
-
32,
|
|
1589
|
-
]);
|
|
1590
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_UNSOLICITED_ENHANCED_UPDATE_RESPONSE, buffer)).toStrictEqual([
|
|
1591
|
-
Zdo.Status.SUCCESS,
|
|
1592
|
-
{
|
|
1593
|
-
channelInUse: 9023342,
|
|
1594
|
-
macTxUCastTotal: 3454,
|
|
1595
|
-
macTxUCastFailures: 435,
|
|
1596
|
-
macTxUCastRetries: 1239,
|
|
1597
|
-
timePeriod: 32,
|
|
1598
|
-
} as NwkUnsolicitedEnhancedUpdateResponse,
|
|
1599
|
-
]);
|
|
1600
|
-
});
|
|
1601
|
-
|
|
1602
|
-
it("readNwkBeaconSurveyResponse", () => {
|
|
1603
|
-
const buffer = Buffer.from([1, Zdo.Status.SUCCESS, 0x01, 4 - 1, 14, 7, 5, 2, 0x02, 7 - 1, ...NODE_ID1_BYTES, 234, 1, ...NODE_ID2_BYTES, 223]);
|
|
1604
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_BEACON_SURVEY_RESPONSE, buffer)).toStrictEqual([
|
|
1605
|
-
Zdo.Status.SUCCESS,
|
|
1606
|
-
{
|
|
1607
|
-
tlvs: [
|
|
1608
|
-
{
|
|
1609
|
-
tagId: 0x01,
|
|
1610
|
-
length: 4,
|
|
1611
|
-
tlv: {
|
|
1612
|
-
totalBeaconsReceived: 14,
|
|
1613
|
-
onNetworkBeacons: 7,
|
|
1614
|
-
potentialParentBeacons: 5,
|
|
1615
|
-
otherNetworkBeacons: 2,
|
|
1616
|
-
} as BeaconSurveyResultsTLV,
|
|
1617
|
-
},
|
|
1618
|
-
{
|
|
1619
|
-
tagId: 0x02,
|
|
1620
|
-
length: 7,
|
|
1621
|
-
tlv: {
|
|
1622
|
-
currentParentNwkAddress: NODE_ID1,
|
|
1623
|
-
currentParentLQA: 234,
|
|
1624
|
-
entryCount: 1,
|
|
1625
|
-
potentialParents: [{nwkAddress: NODE_ID2, lqa: 223}],
|
|
1626
|
-
} as PotentialParentsTLV,
|
|
1627
|
-
},
|
|
1628
|
-
],
|
|
1629
|
-
} as NwkBeaconSurveyResponse,
|
|
1630
|
-
]);
|
|
1631
|
-
|
|
1632
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS]);
|
|
1633
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.NWK_BEACON_SURVEY_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1634
|
-
Zdo.Status.SUCCESS,
|
|
1635
|
-
{
|
|
1636
|
-
tlvs: [],
|
|
1637
|
-
} as NwkBeaconSurveyResponse,
|
|
1638
|
-
]);
|
|
1639
|
-
});
|
|
1640
|
-
|
|
1641
|
-
it("readStartKeyNegotiationResponse", () => {
|
|
1642
|
-
const buffer = Buffer.from([
|
|
1643
|
-
1,
|
|
1644
|
-
Zdo.Status.SUCCESS,
|
|
1645
|
-
0x00,
|
|
1646
|
-
ZSpec.EUI64_SIZE + Zdo.CURVE_PUBLIC_POINT_SIZE - 1,
|
|
1647
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1648
|
-
...Buffer.alloc(Zdo.CURVE_PUBLIC_POINT_SIZE).fill(0xab),
|
|
1649
|
-
]);
|
|
1650
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.START_KEY_NEGOTIATION_RESPONSE, buffer)).toStrictEqual([
|
|
1651
|
-
Zdo.Status.SUCCESS,
|
|
1652
|
-
{
|
|
1653
|
-
tlvs: [
|
|
1654
|
-
{
|
|
1655
|
-
tagId: 0x00,
|
|
1656
|
-
length: ZSpec.EUI64_SIZE + Zdo.CURVE_PUBLIC_POINT_SIZE,
|
|
1657
|
-
tlv: {
|
|
1658
|
-
eui64: IEEE_ADDRESS2,
|
|
1659
|
-
publicPoint: Buffer.alloc(Zdo.CURVE_PUBLIC_POINT_SIZE).fill(0xab),
|
|
1660
|
-
} as Curve25519PublicPointTLV,
|
|
1661
|
-
},
|
|
1662
|
-
],
|
|
1663
|
-
},
|
|
1664
|
-
]);
|
|
1665
|
-
});
|
|
1666
|
-
|
|
1667
|
-
it("readRetrieveAuthenticationTokenResponse", () => {
|
|
1668
|
-
// this one has no local TLV, so test with a global one
|
|
1669
|
-
const tlv: FragmentationParametersGlobalTLV = {
|
|
1670
|
-
nwkAddress: NODE_ID1,
|
|
1671
|
-
fragmentationOptions: 1,
|
|
1672
|
-
maxIncomingTransferUnit: 65352,
|
|
1673
|
-
};
|
|
1674
|
-
const buffer = Buffer.from([
|
|
1675
|
-
1,
|
|
1676
|
-
Zdo.Status.SUCCESS,
|
|
1677
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
1678
|
-
5 - 1,
|
|
1679
|
-
...uint16To8Array(tlv.nwkAddress),
|
|
1680
|
-
tlv.fragmentationOptions!,
|
|
1681
|
-
...uint16To8Array(tlv.maxIncomingTransferUnit!),
|
|
1682
|
-
]);
|
|
1683
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_RESPONSE, buffer)).toStrictEqual([
|
|
1684
|
-
Zdo.Status.SUCCESS,
|
|
1685
|
-
{
|
|
1686
|
-
tlvs: [{tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, length: 5, tlv}],
|
|
1687
|
-
},
|
|
1688
|
-
]);
|
|
1689
|
-
|
|
1690
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS]);
|
|
1691
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.RETRIEVE_AUTHENTICATION_TOKEN_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1692
|
-
Zdo.Status.SUCCESS,
|
|
1693
|
-
{
|
|
1694
|
-
tlvs: [],
|
|
1695
|
-
},
|
|
1696
|
-
]);
|
|
1697
|
-
});
|
|
1698
|
-
|
|
1699
|
-
it("readGetAuthenticationLevelResponse", () => {
|
|
1700
|
-
const buffer = Buffer.from([
|
|
1701
|
-
1,
|
|
1702
|
-
Zdo.Status.SUCCESS,
|
|
1703
|
-
0x00,
|
|
1704
|
-
10 - 1,
|
|
1705
|
-
...IEEE_ADDRESS2_BYTES,
|
|
1706
|
-
Zdo.InitialJoinMethod.INSTALL_CODE_KEY,
|
|
1707
|
-
Zdo.ActiveLinkKeyType.AUTHENTICATED_KEY_NEGOTIATION,
|
|
1708
|
-
]);
|
|
1709
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.GET_AUTHENTICATION_LEVEL_RESPONSE, buffer)).toStrictEqual([
|
|
1710
|
-
Zdo.Status.SUCCESS,
|
|
1711
|
-
{
|
|
1712
|
-
tlvs: [
|
|
1713
|
-
{
|
|
1714
|
-
tagId: 0x00,
|
|
1715
|
-
length: 10,
|
|
1716
|
-
tlv: {
|
|
1717
|
-
remoteNodeIeee: IEEE_ADDRESS2,
|
|
1718
|
-
initialJoinMethod: Zdo.InitialJoinMethod.INSTALL_CODE_KEY,
|
|
1719
|
-
activeLinkKeyType: Zdo.ActiveLinkKeyType.AUTHENTICATED_KEY_NEGOTIATION,
|
|
1720
|
-
} as DeviceAuthenticationLevelTLV,
|
|
1721
|
-
},
|
|
1722
|
-
],
|
|
1723
|
-
},
|
|
1724
|
-
]);
|
|
1725
|
-
});
|
|
1726
|
-
|
|
1727
|
-
it("readSetConfigurationResponse", () => {
|
|
1728
|
-
const buffer = Buffer.from([
|
|
1729
|
-
1,
|
|
1730
|
-
Zdo.Status.SUCCESS,
|
|
1731
|
-
0x00,
|
|
1732
|
-
7 - 1,
|
|
1733
|
-
3,
|
|
1734
|
-
0x00,
|
|
1735
|
-
Zdo.Status.SUCCESS,
|
|
1736
|
-
Zdo.GlobalTLV.CONFIGURATION_PARAMETERS,
|
|
1737
|
-
Zdo.Status.SUCCESS,
|
|
1738
|
-
Zdo.GlobalTLV.ROUTER_INFORMATION,
|
|
1739
|
-
Zdo.Status.INV_REQUESTTYPE,
|
|
1740
|
-
]);
|
|
1741
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.SET_CONFIGURATION_RESPONSE, buffer)).toStrictEqual([
|
|
1742
|
-
Zdo.Status.SUCCESS,
|
|
1743
|
-
{
|
|
1744
|
-
tlvs: [
|
|
1745
|
-
{
|
|
1746
|
-
tagId: 0x00,
|
|
1747
|
-
length: 7,
|
|
1748
|
-
tlv: {
|
|
1749
|
-
count: 3,
|
|
1750
|
-
tlvs: [
|
|
1751
|
-
{tagId: 0x00, processingStatus: Zdo.Status.SUCCESS},
|
|
1752
|
-
{tagId: Zdo.GlobalTLV.CONFIGURATION_PARAMETERS, processingStatus: Zdo.Status.SUCCESS},
|
|
1753
|
-
{tagId: Zdo.GlobalTLV.ROUTER_INFORMATION, processingStatus: Zdo.Status.INV_REQUESTTYPE},
|
|
1754
|
-
],
|
|
1755
|
-
} as ProcessingStatusTLV,
|
|
1756
|
-
},
|
|
1757
|
-
],
|
|
1758
|
-
},
|
|
1759
|
-
]);
|
|
1760
|
-
|
|
1761
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS, 0x00, 1 - 1, 0]);
|
|
1762
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.SET_CONFIGURATION_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1763
|
-
Zdo.Status.SUCCESS,
|
|
1764
|
-
{
|
|
1765
|
-
tlvs: [
|
|
1766
|
-
{
|
|
1767
|
-
tagId: 0x00,
|
|
1768
|
-
length: 1,
|
|
1769
|
-
tlv: {
|
|
1770
|
-
count: 0,
|
|
1771
|
-
tlvs: [],
|
|
1772
|
-
} as ProcessingStatusTLV,
|
|
1773
|
-
},
|
|
1774
|
-
],
|
|
1775
|
-
},
|
|
1776
|
-
]);
|
|
1777
|
-
});
|
|
1778
|
-
|
|
1779
|
-
it("readGetConfigurationResponse", () => {
|
|
1780
|
-
// this one has no local TLV, so test with a global one
|
|
1781
|
-
const tlv: FragmentationParametersGlobalTLV = {
|
|
1782
|
-
nwkAddress: NODE_ID1,
|
|
1783
|
-
fragmentationOptions: 1,
|
|
1784
|
-
maxIncomingTransferUnit: 65352,
|
|
1785
|
-
};
|
|
1786
|
-
const buffer = Buffer.from([
|
|
1787
|
-
1,
|
|
1788
|
-
Zdo.Status.SUCCESS,
|
|
1789
|
-
Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS,
|
|
1790
|
-
5 - 1,
|
|
1791
|
-
...uint16To8Array(tlv.nwkAddress),
|
|
1792
|
-
tlv.fragmentationOptions!,
|
|
1793
|
-
...uint16To8Array(tlv.maxIncomingTransferUnit!),
|
|
1794
|
-
]);
|
|
1795
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.GET_CONFIGURATION_RESPONSE, buffer)).toStrictEqual([
|
|
1796
|
-
Zdo.Status.SUCCESS,
|
|
1797
|
-
{
|
|
1798
|
-
tlvs: [{tagId: Zdo.GlobalTLV.FRAGMENTATION_PARAMETERS, length: 5, tlv}],
|
|
1799
|
-
},
|
|
1800
|
-
]);
|
|
1801
|
-
|
|
1802
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS]);
|
|
1803
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.GET_CONFIGURATION_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1804
|
-
Zdo.Status.SUCCESS,
|
|
1805
|
-
{
|
|
1806
|
-
tlvs: [],
|
|
1807
|
-
},
|
|
1808
|
-
]);
|
|
1809
|
-
});
|
|
1810
|
-
|
|
1811
|
-
it("readChallengeResponse", () => {
|
|
1812
|
-
const buffer = Buffer.from([
|
|
1813
|
-
1,
|
|
1814
|
-
Zdo.Status.SUCCESS,
|
|
1815
|
-
0x00,
|
|
1816
|
-
32 - 1,
|
|
1817
|
-
...IEEE_ADDRESS1_BYTES,
|
|
1818
|
-
...Buffer.alloc(Zdo.CHALLENGE_VALUE_SIZE).fill(0x39),
|
|
1819
|
-
...uint32To8Array(4302952),
|
|
1820
|
-
...uint32To8Array(12435682),
|
|
1821
|
-
...Buffer.from([0xff, 0xfe, 0x34, 0x04, 0x49, 0x9f, 0x03, 0xbc]),
|
|
1822
|
-
]);
|
|
1823
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.CHALLENGE_RESPONSE, buffer)).toStrictEqual([
|
|
1824
|
-
Zdo.Status.SUCCESS,
|
|
1825
|
-
{
|
|
1826
|
-
tlvs: [
|
|
1827
|
-
{
|
|
1828
|
-
tagId: 0x00,
|
|
1829
|
-
length: 32,
|
|
1830
|
-
tlv: {
|
|
1831
|
-
responderEui64: IEEE_ADDRESS1,
|
|
1832
|
-
receivedChallengeValue: Buffer.alloc(Zdo.CHALLENGE_VALUE_SIZE).fill(0x39),
|
|
1833
|
-
apsFrameCounter: 4302952,
|
|
1834
|
-
challengeSecurityFrameCounter: 12435682,
|
|
1835
|
-
mic: Buffer.from([0xff, 0xfe, 0x34, 0x04, 0x49, 0x9f, 0x03, 0xbc]),
|
|
1836
|
-
} as APSFrameCounterResponseTLV,
|
|
1837
|
-
},
|
|
1838
|
-
],
|
|
1839
|
-
},
|
|
1840
|
-
]);
|
|
1841
|
-
|
|
1842
|
-
const bufferEmpty = Buffer.from([1, Zdo.Status.SUCCESS]);
|
|
1843
|
-
expect(Zdo.Buffalo.readResponse(true, Zdo.ClusterId.CHALLENGE_RESPONSE, bufferEmpty)).toStrictEqual([
|
|
1844
|
-
Zdo.Status.SUCCESS,
|
|
1845
|
-
{
|
|
1846
|
-
tlvs: [],
|
|
1847
|
-
},
|
|
1848
|
-
]);
|
|
1849
|
-
});
|
|
1850
|
-
});
|