zigbee-herdsman 6.0.1 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/adapter/ezsp/driver/uart.js +1 -1
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +4 -4
- package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.js +4 -4
- package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +1 -0
- package/dist/controller/model/device.js.map +1 -1
- package/package.json +14 -6
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/dependabot.yml +0 -22
- package/.github/workflows/ci.yml +0 -64
- package/.github/workflows/release-please.yml +0 -18
- package/.github/workflows/stale.yml +0 -20
- package/.github/workflows/typedoc.yaml +0 -47
- package/.release-please-manifest.json +0 -3
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -11
- package/biome.json +0 -98
- package/examples/join-and-log.js +0 -24
- package/release-please-config.json +0 -9
- package/src/adapter/adapter.ts +0 -189
- package/src/adapter/adapterDiscovery.ts +0 -666
- package/src/adapter/const.ts +0 -12
- package/src/adapter/deconz/adapter/deconzAdapter.ts +0 -877
- package/src/adapter/deconz/driver/constants.ts +0 -246
- package/src/adapter/deconz/driver/driver.ts +0 -1540
- package/src/adapter/deconz/driver/frame.ts +0 -11
- package/src/adapter/deconz/driver/frameParser.ts +0 -753
- package/src/adapter/deconz/driver/parser.ts +0 -45
- package/src/adapter/deconz/driver/writer.ts +0 -22
- package/src/adapter/deconz/types.d.ts +0 -13
- package/src/adapter/ember/adapter/emberAdapter.ts +0 -2265
- package/src/adapter/ember/adapter/endpoints.ts +0 -86
- package/src/adapter/ember/adapter/oneWaitress.ts +0 -324
- package/src/adapter/ember/adapter/tokensManager.ts +0 -782
- package/src/adapter/ember/consts.ts +0 -178
- package/src/adapter/ember/enums.ts +0 -1746
- package/src/adapter/ember/ezsp/buffalo.ts +0 -1392
- package/src/adapter/ember/ezsp/consts.ts +0 -148
- package/src/adapter/ember/ezsp/enums.ts +0 -1114
- package/src/adapter/ember/ezsp/ezsp.ts +0 -9061
- package/src/adapter/ember/ezspError.ts +0 -10
- package/src/adapter/ember/types.ts +0 -866
- package/src/adapter/ember/uart/ash.ts +0 -1960
- package/src/adapter/ember/uart/consts.ts +0 -109
- package/src/adapter/ember/uart/enums.ts +0 -192
- package/src/adapter/ember/uart/parser.ts +0 -48
- package/src/adapter/ember/uart/queues.ts +0 -247
- package/src/adapter/ember/uart/writer.ts +0 -53
- package/src/adapter/ember/utils/initters.ts +0 -58
- package/src/adapter/ember/utils/math.ts +0 -73
- package/src/adapter/events.ts +0 -21
- package/src/adapter/ezsp/adapter/backup.ts +0 -109
- package/src/adapter/ezsp/adapter/ezspAdapter.ts +0 -614
- package/src/adapter/ezsp/driver/commands.ts +0 -2497
- package/src/adapter/ezsp/driver/consts.ts +0 -11
- package/src/adapter/ezsp/driver/driver.ts +0 -1002
- package/src/adapter/ezsp/driver/ezsp.ts +0 -802
- package/src/adapter/ezsp/driver/frame.ts +0 -101
- package/src/adapter/ezsp/driver/index.ts +0 -4
- package/src/adapter/ezsp/driver/multicast.ts +0 -78
- package/src/adapter/ezsp/driver/parser.ts +0 -81
- package/src/adapter/ezsp/driver/types/basic.ts +0 -201
- package/src/adapter/ezsp/driver/types/index.ts +0 -239
- package/src/adapter/ezsp/driver/types/named.ts +0 -2330
- package/src/adapter/ezsp/driver/types/struct.ts +0 -844
- package/src/adapter/ezsp/driver/uart.ts +0 -460
- package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +0 -44
- package/src/adapter/ezsp/driver/utils/index.ts +0 -32
- package/src/adapter/ezsp/driver/writer.ts +0 -64
- package/src/adapter/index.ts +0 -3
- package/src/adapter/serialPort.ts +0 -58
- package/src/adapter/socketPortUtils.ts +0 -16
- package/src/adapter/tstype.ts +0 -78
- package/src/adapter/z-stack/adapter/adapter-backup.ts +0 -519
- package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +0 -457
- package/src/adapter/z-stack/adapter/endpoints.ts +0 -57
- package/src/adapter/z-stack/adapter/manager.ts +0 -543
- package/src/adapter/z-stack/adapter/tstype.ts +0 -6
- package/src/adapter/z-stack/adapter/zStackAdapter.ts +0 -1190
- package/src/adapter/z-stack/constants/af.ts +0 -27
- package/src/adapter/z-stack/constants/common.ts +0 -285
- package/src/adapter/z-stack/constants/dbg.ts +0 -23
- package/src/adapter/z-stack/constants/index.ts +0 -11
- package/src/adapter/z-stack/constants/mac.ts +0 -128
- package/src/adapter/z-stack/constants/sapi.ts +0 -25
- package/src/adapter/z-stack/constants/sys.ts +0 -72
- package/src/adapter/z-stack/constants/util.ts +0 -82
- package/src/adapter/z-stack/constants/utils.ts +0 -14
- package/src/adapter/z-stack/constants/zdo.ts +0 -103
- package/src/adapter/z-stack/models/startup-options.ts +0 -13
- package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +0 -44
- package/src/adapter/z-stack/structs/entries/address-manager-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +0 -12
- package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +0 -19
- package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +0 -21
- package/src/adapter/z-stack/structs/entries/channel-list.ts +0 -8
- package/src/adapter/z-stack/structs/entries/has-configured.ts +0 -16
- package/src/adapter/z-stack/structs/entries/index.ts +0 -16
- package/src/adapter/z-stack/structs/entries/nib.ts +0 -66
- package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +0 -15
- package/src/adapter/z-stack/structs/entries/nwk-key.ts +0 -13
- package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +0 -8
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +0 -20
- package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +0 -19
- package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +0 -33
- package/src/adapter/z-stack/structs/entries/security-manager-table.ts +0 -22
- package/src/adapter/z-stack/structs/index.ts +0 -4
- package/src/adapter/z-stack/structs/serializable-memory-object.ts +0 -14
- package/src/adapter/z-stack/structs/struct.ts +0 -367
- package/src/adapter/z-stack/structs/table.ts +0 -198
- package/src/adapter/z-stack/unpi/constants.ts +0 -33
- package/src/adapter/z-stack/unpi/frame.ts +0 -62
- package/src/adapter/z-stack/unpi/index.ts +0 -4
- package/src/adapter/z-stack/unpi/parser.ts +0 -56
- package/src/adapter/z-stack/unpi/writer.ts +0 -21
- package/src/adapter/z-stack/utils/channel-list.ts +0 -40
- package/src/adapter/z-stack/utils/index.ts +0 -2
- package/src/adapter/z-stack/utils/network-options.ts +0 -26
- package/src/adapter/z-stack/znp/buffaloZnp.ts +0 -175
- package/src/adapter/z-stack/znp/definition.ts +0 -2713
- package/src/adapter/z-stack/znp/index.ts +0 -2
- package/src/adapter/z-stack/znp/parameterType.ts +0 -22
- package/src/adapter/z-stack/znp/tstype.ts +0 -44
- package/src/adapter/z-stack/znp/utils.ts +0 -10
- package/src/adapter/z-stack/znp/znp.ts +0 -342
- package/src/adapter/z-stack/znp/zpiObject.ts +0 -148
- package/src/adapter/zboss/adapter/zbossAdapter.ts +0 -526
- package/src/adapter/zboss/commands.ts +0 -1184
- package/src/adapter/zboss/consts.ts +0 -9
- package/src/adapter/zboss/driver.ts +0 -422
- package/src/adapter/zboss/enums.ts +0 -360
- package/src/adapter/zboss/frame.ts +0 -227
- package/src/adapter/zboss/reader.ts +0 -65
- package/src/adapter/zboss/types.ts +0 -0
- package/src/adapter/zboss/uart.ts +0 -428
- package/src/adapter/zboss/utils.ts +0 -58
- package/src/adapter/zboss/writer.ts +0 -49
- package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +0 -27
- package/src/adapter/zigate/adapter/zigateAdapter.ts +0 -618
- package/src/adapter/zigate/driver/LICENSE +0 -17
- package/src/adapter/zigate/driver/buffaloZiGate.ts +0 -212
- package/src/adapter/zigate/driver/commandType.ts +0 -418
- package/src/adapter/zigate/driver/constants.ts +0 -150
- package/src/adapter/zigate/driver/frame.ts +0 -197
- package/src/adapter/zigate/driver/messageType.ts +0 -287
- package/src/adapter/zigate/driver/parameterType.ts +0 -32
- package/src/adapter/zigate/driver/ziGateObject.ts +0 -146
- package/src/adapter/zigate/driver/zigate.ts +0 -423
- package/src/adapter/zoh/adapter/utils.ts +0 -27
- package/src/adapter/zoh/adapter/zohAdapter.ts +0 -838
- package/src/buffalo/buffalo.ts +0 -342
- package/src/buffalo/index.ts +0 -1
- package/src/controller/controller.ts +0 -1022
- package/src/controller/database.ts +0 -124
- package/src/controller/events.ts +0 -52
- package/src/controller/greenPower.ts +0 -603
- package/src/controller/helpers/index.ts +0 -1
- package/src/controller/helpers/installCodes.ts +0 -107
- package/src/controller/helpers/request.ts +0 -96
- package/src/controller/helpers/requestQueue.ts +0 -125
- package/src/controller/helpers/zclFrameConverter.ts +0 -47
- package/src/controller/helpers/zclTransactionSequenceNumber.ts +0 -19
- package/src/controller/index.ts +0 -6
- package/src/controller/model/device.ts +0 -1248
- package/src/controller/model/endpoint.ts +0 -1105
- package/src/controller/model/entity.ts +0 -23
- package/src/controller/model/group.ts +0 -424
- package/src/controller/model/index.ts +0 -5
- package/src/controller/model/zigbeeEntity.ts +0 -30
- package/src/controller/touchlink.ts +0 -189
- package/src/controller/tstype.ts +0 -274
- package/src/index.ts +0 -12
- package/src/models/backup-storage-legacy.ts +0 -48
- package/src/models/backup-storage-unified.ts +0 -47
- package/src/models/backup.ts +0 -37
- package/src/models/index.ts +0 -5
- package/src/models/network-options.ts +0 -11
- package/src/utils/backup.ts +0 -152
- package/src/utils/index.ts +0 -5
- package/src/utils/logger.ts +0 -20
- package/src/utils/patchBigIntSerialization.ts +0 -8
- package/src/utils/queue.ts +0 -76
- package/src/utils/types.d.ts +0 -3
- package/src/utils/utils.ts +0 -19
- package/src/utils/wait.ts +0 -5
- package/src/utils/waitress.ts +0 -96
- package/src/zspec/consts.ts +0 -84
- package/src/zspec/enums.ts +0 -22
- package/src/zspec/index.ts +0 -3
- package/src/zspec/tstypes.ts +0 -18
- package/src/zspec/utils.ts +0 -247
- package/src/zspec/zcl/buffaloZcl.ts +0 -1220
- package/src/zspec/zcl/definition/cluster.ts +0 -5915
- package/src/zspec/zcl/definition/clusters-typegen.ts +0 -588
- package/src/zspec/zcl/definition/clusters-types.ts +0 -7331
- package/src/zspec/zcl/definition/consts.ts +0 -24
- package/src/zspec/zcl/definition/enums.ts +0 -203
- package/src/zspec/zcl/definition/foundation.ts +0 -329
- package/src/zspec/zcl/definition/manufacturerCode.ts +0 -729
- package/src/zspec/zcl/definition/status.ts +0 -69
- package/src/zspec/zcl/definition/tstype.ts +0 -377
- package/src/zspec/zcl/index.ts +0 -11
- package/src/zspec/zcl/utils.ts +0 -321
- package/src/zspec/zcl/zclFrame.ts +0 -356
- package/src/zspec/zcl/zclHeader.ts +0 -102
- package/src/zspec/zcl/zclStatusError.ts +0 -10
- package/src/zspec/zdo/buffaloZdo.ts +0 -2336
- package/src/zspec/zdo/definition/clusters.ts +0 -722
- package/src/zspec/zdo/definition/consts.ts +0 -16
- package/src/zspec/zdo/definition/enums.ts +0 -99
- package/src/zspec/zdo/definition/status.ts +0 -105
- package/src/zspec/zdo/definition/tstypes.ts +0 -1062
- package/src/zspec/zdo/index.ts +0 -7
- package/src/zspec/zdo/utils.ts +0 -76
- package/src/zspec/zdo/zdoStatusError.ts +0 -10
- package/test/adapter/adapter.test.ts +0 -1062
- package/test/adapter/ember/ash.test.ts +0 -337
- package/test/adapter/ember/consts.ts +0 -131
- package/test/adapter/ember/emberAdapter.test.ts +0 -3449
- package/test/adapter/ember/ezsp.test.ts +0 -385
- package/test/adapter/ember/ezspBuffalo.test.ts +0 -93
- package/test/adapter/ember/ezspError.test.ts +0 -12
- package/test/adapter/ember/math.test.ts +0 -206
- package/test/adapter/ezsp/frame.test.ts +0 -30
- package/test/adapter/ezsp/uart.test.ts +0 -181
- package/test/adapter/z-stack/adapter.test.ts +0 -3984
- package/test/adapter/z-stack/constants.test.ts +0 -33
- package/test/adapter/z-stack/structs.test.ts +0 -115
- package/test/adapter/z-stack/unpi.test.ts +0 -213
- package/test/adapter/z-stack/znp.test.ts +0 -1284
- package/test/adapter/zboss/fixZdoResponse.test.ts +0 -179
- package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +0 -81
- package/test/adapter/zigate/zdo.test.ts +0 -187
- package/test/adapter/zoh/utils.test.ts +0 -36
- package/test/adapter/zoh/zohAdapter.test.ts +0 -1307
- package/test/buffalo.test.ts +0 -431
- package/test/controller.bench.ts +0 -193
- package/test/controller.test.ts +0 -8702
- package/test/greenpower.test.ts +0 -1408
- package/test/mockAdapters.ts +0 -65
- package/test/mockDevices.ts +0 -598
- package/test/requests.bench.ts +0 -206
- package/test/testUtils.ts +0 -20
- package/test/tsconfig.json +0 -9
- package/test/utils/math.ts +0 -19
- package/test/utils.test.ts +0 -279
- package/test/vitest.config.mts +0 -27
- package/test/zcl.test.ts +0 -2831
- package/test/zspec/utils.test.ts +0 -68
- package/test/zspec/zcl/buffalo.test.ts +0 -1374
- package/test/zspec/zcl/frame.test.ts +0 -960
- package/test/zspec/zcl/utils.test.ts +0 -273
- package/test/zspec/zdo/buffalo.test.ts +0 -1850
- package/test/zspec/zdo/utils.test.ts +0 -241
- package/tsconfig.json +0 -24
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
/* v8 ignore start */
|
|
2
|
-
|
|
3
|
-
import type * as Models from "../../../models";
|
|
4
|
-
import {Queue, Waitress, wait} from "../../../utils";
|
|
5
|
-
import {logger} from "../../../utils/logger";
|
|
6
|
-
import * as ZSpec from "../../../zspec";
|
|
7
|
-
import type {BroadcastAddress} from "../../../zspec/enums";
|
|
8
|
-
import * as Zcl from "../../../zspec/zcl";
|
|
9
|
-
import * as Zdo from "../../../zspec/zdo";
|
|
10
|
-
import type * as ZdoTypes from "../../../zspec/zdo/definition/tstypes";
|
|
11
|
-
import Adapter from "../../adapter";
|
|
12
|
-
import type * as Events from "../../events";
|
|
13
|
-
import type * as TsType from "../../tstype";
|
|
14
|
-
import type {RawAPSDataRequestPayload} from "../driver/commandType";
|
|
15
|
-
import {AddressMode, DeviceType, ZiGateCommandCode, ZiGateMessageCode, ZPSNwkKeyState} from "../driver/constants";
|
|
16
|
-
import type ZiGateObject from "../driver/ziGateObject";
|
|
17
|
-
import Driver from "../driver/zigate";
|
|
18
|
-
import {patchZdoBuffaloBE} from "./patchZdoBuffaloBE";
|
|
19
|
-
|
|
20
|
-
const NS = "zh:zigate";
|
|
21
|
-
const default_bind_group = 901; // https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/constants.js#L3
|
|
22
|
-
interface WaitressMatcher {
|
|
23
|
-
address?: number | string;
|
|
24
|
-
endpoint: number;
|
|
25
|
-
transactionSequenceNumber?: number;
|
|
26
|
-
frameType: Zcl.FrameType;
|
|
27
|
-
clusterID: number;
|
|
28
|
-
commandIdentifier: number;
|
|
29
|
-
direction: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export class ZiGateAdapter extends Adapter {
|
|
33
|
-
private driver: Driver;
|
|
34
|
-
private joinPermitted: boolean;
|
|
35
|
-
private waitress: Waitress<Events.ZclPayload, WaitressMatcher>;
|
|
36
|
-
private closing: boolean;
|
|
37
|
-
private queue: Queue;
|
|
38
|
-
|
|
39
|
-
public constructor(
|
|
40
|
-
networkOptions: TsType.NetworkOptions,
|
|
41
|
-
serialPortOptions: TsType.SerialPortOptions,
|
|
42
|
-
backupPath: string,
|
|
43
|
-
adapterOptions: TsType.AdapterOptions,
|
|
44
|
-
) {
|
|
45
|
-
patchZdoBuffaloBE();
|
|
46
|
-
super(networkOptions, serialPortOptions, backupPath, adapterOptions);
|
|
47
|
-
this.hasZdoMessageOverhead = false; // false for requests, true for responses
|
|
48
|
-
this.manufacturerID = Zcl.ManufacturerCode.RESERVED_10;
|
|
49
|
-
|
|
50
|
-
this.joinPermitted = false;
|
|
51
|
-
this.closing = false;
|
|
52
|
-
const concurrent = this.adapterOptions?.concurrent ? this.adapterOptions.concurrent : 2;
|
|
53
|
-
logger.debug(`Adapter concurrent: ${concurrent}`, NS);
|
|
54
|
-
this.queue = new Queue(concurrent);
|
|
55
|
-
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
56
|
-
this.driver = new Driver(serialPortOptions.path!, serialPortOptions);
|
|
57
|
-
this.waitress = new Waitress<Events.ZclPayload, WaitressMatcher>(this.waitressValidator, this.waitressTimeoutFormatter);
|
|
58
|
-
|
|
59
|
-
this.driver.on("received", this.dataListener.bind(this));
|
|
60
|
-
this.driver.on("LeaveIndication", this.leaveIndicationListener.bind(this));
|
|
61
|
-
this.driver.on("DeviceAnnounce", this.deviceAnnounceListener.bind(this));
|
|
62
|
-
this.driver.on("close", this.onZiGateClose.bind(this));
|
|
63
|
-
this.driver.on("zdoResponse", this.onZdoResponse.bind(this));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Adapter methods
|
|
68
|
-
*/
|
|
69
|
-
public async start(): Promise<TsType.StartResult> {
|
|
70
|
-
let startResult: TsType.StartResult = "resumed";
|
|
71
|
-
try {
|
|
72
|
-
await this.driver.open();
|
|
73
|
-
logger.info("Connected to ZiGate adapter successfully.", NS);
|
|
74
|
-
|
|
75
|
-
const resetResponse = await this.driver.sendCommand(ZiGateCommandCode.Reset, {}, 5000);
|
|
76
|
-
if (resetResponse.code === ZiGateMessageCode.RestartNonFactoryNew) {
|
|
77
|
-
startResult = "resumed";
|
|
78
|
-
} else if (resetResponse.code === ZiGateMessageCode.RestartFactoryNew) {
|
|
79
|
-
startResult = "reset";
|
|
80
|
-
}
|
|
81
|
-
await this.driver.sendCommand(ZiGateCommandCode.RawMode, {enabled: 0x01});
|
|
82
|
-
// @todo check
|
|
83
|
-
await this.driver.sendCommand(ZiGateCommandCode.SetDeviceType, {
|
|
84
|
-
deviceType: DeviceType.Coordinator,
|
|
85
|
-
});
|
|
86
|
-
await this.initNetwork();
|
|
87
|
-
|
|
88
|
-
await this.driver.sendCommand(ZiGateCommandCode.AddGroup, {
|
|
89
|
-
addressMode: AddressMode.Short,
|
|
90
|
-
shortAddress: ZSpec.COORDINATOR_ADDRESS,
|
|
91
|
-
sourceEndpoint: ZSpec.HA_ENDPOINT,
|
|
92
|
-
destinationEndpoint: ZSpec.HA_ENDPOINT,
|
|
93
|
-
groupAddress: default_bind_group,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (this.adapterOptions.transmitPower != null) {
|
|
97
|
-
await this.driver.sendCommand(ZiGateCommandCode.SetTXpower, {value: this.adapterOptions.transmitPower});
|
|
98
|
-
}
|
|
99
|
-
} catch (error) {
|
|
100
|
-
throw new Error(`failed to connect to zigate adapter ${(error as Error).message}`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return startResult; // 'resumed' | 'reset' | 'restored'
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public async stop(): Promise<void> {
|
|
107
|
-
this.closing = true;
|
|
108
|
-
await this.driver.close();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public async getCoordinatorIEEE(): Promise<string> {
|
|
112
|
-
const networkResponse = await this.driver.sendCommand(ZiGateCommandCode.GetNetworkState);
|
|
113
|
-
return networkResponse.payload.extendedAddress;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public async getCoordinatorVersion(): Promise<TsType.CoordinatorVersion> {
|
|
117
|
-
const result = await this.driver.sendCommand(ZiGateCommandCode.GetVersion, {});
|
|
118
|
-
const meta = {
|
|
119
|
-
transportrev: 0,
|
|
120
|
-
product: 0,
|
|
121
|
-
majorrel: Number.parseInt(<string>result.payload.major).toString(16),
|
|
122
|
-
minorrel: Number.parseInt(<string>result.payload.minor).toString(16),
|
|
123
|
-
maintrel: Number.parseInt(<string>result.payload.revision).toString(16),
|
|
124
|
-
revision: Number.parseInt(<string>result.payload.revision).toString(16),
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
type: "zigate",
|
|
129
|
-
meta: meta,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public async permitJoin(seconds: number, networkAddress?: number): Promise<void> {
|
|
134
|
-
const clusterId = Zdo.ClusterId.PERMIT_JOINING_REQUEST;
|
|
135
|
-
|
|
136
|
-
if (networkAddress !== undefined) {
|
|
137
|
-
// specific device that is not `Coordinator`
|
|
138
|
-
// `authentication`: TC significance always 1 (zb specs)
|
|
139
|
-
const zdoPayload = Zdo.Buffalo.buildRequest(this.hasZdoMessageOverhead, clusterId, seconds, 1, []);
|
|
140
|
-
|
|
141
|
-
const result = await this.sendZdo(ZSpec.BLANK_EUI64, networkAddress, clusterId, zdoPayload, false);
|
|
142
|
-
|
|
143
|
-
if (!Zdo.Buffalo.checkStatus<Zdo.ClusterId.PERMIT_JOINING_RESPONSE>(result)) {
|
|
144
|
-
// TODO: will disappear once moved upstream
|
|
145
|
-
throw new Zdo.StatusError(result[0]);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
// broadcast permit joining ZDO
|
|
149
|
-
// `authentication`: TC significance always 1 (zb specs)
|
|
150
|
-
const zdoPayload = Zdo.Buffalo.buildRequest(this.hasZdoMessageOverhead, clusterId, seconds, 1, []);
|
|
151
|
-
|
|
152
|
-
await this.sendZdo(ZSpec.BLANK_EUI64, ZSpec.BroadcastAddress.DEFAULT, clusterId, zdoPayload, true);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
this.joinPermitted = seconds !== 0;
|
|
156
|
-
}
|
|
157
|
-
public async addInstallCode(_ieeeAddress: string, _key: Buffer, _hashed: boolean): Promise<void> {
|
|
158
|
-
await Promise.reject(new Error("Add install code is not supported"));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
public async reset(type: "soft" | "hard"): Promise<void> {
|
|
162
|
-
if (type === "soft") {
|
|
163
|
-
await this.driver.sendCommand(ZiGateCommandCode.Reset, {}, 5000);
|
|
164
|
-
} else if (type === "hard") {
|
|
165
|
-
await this.driver.sendCommand(ZiGateCommandCode.ErasePersistentData, {}, 5000);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
public async getNetworkParameters(): Promise<TsType.NetworkParameters> {
|
|
170
|
-
try {
|
|
171
|
-
const result = await this.driver.sendCommand(ZiGateCommandCode.GetNetworkState, {}, 10000);
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
panID: result.payload.PANID as number,
|
|
175
|
-
extendedPanID: result.payload.ExtPANID as string, // read as IEEEADDR, so `0x${string}`
|
|
176
|
-
channel: result.payload.Channel as number,
|
|
177
|
-
nwkUpdateID: 0 as number,
|
|
178
|
-
};
|
|
179
|
-
} catch (error) {
|
|
180
|
-
throw new Error(`Get network parameters failed ${error}`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* https://zigate.fr/documentation/deplacer-le-pdm-de-la-zigate/
|
|
186
|
-
* pdm from host
|
|
187
|
-
*/
|
|
188
|
-
public async supportsBackup(): Promise<boolean> {
|
|
189
|
-
return await Promise.resolve(false);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public async backup(): Promise<Models.Backup> {
|
|
193
|
-
return await Promise.reject(new Error("This adapter does not support backup"));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
public async sendZdo(
|
|
197
|
-
ieeeAddress: string,
|
|
198
|
-
networkAddress: number,
|
|
199
|
-
clusterId: Zdo.ClusterId,
|
|
200
|
-
payload: Buffer,
|
|
201
|
-
disableResponse: true,
|
|
202
|
-
): Promise<void>;
|
|
203
|
-
public async sendZdo<K extends keyof ZdoTypes.RequestToResponseMap>(
|
|
204
|
-
ieeeAddress: string,
|
|
205
|
-
networkAddress: number,
|
|
206
|
-
clusterId: K,
|
|
207
|
-
payload: Buffer,
|
|
208
|
-
disableResponse: false,
|
|
209
|
-
): Promise<ZdoTypes.RequestToResponseMap[K]>;
|
|
210
|
-
public async sendZdo<K extends keyof ZdoTypes.RequestToResponseMap>(
|
|
211
|
-
ieeeAddress: string,
|
|
212
|
-
networkAddress: number,
|
|
213
|
-
clusterId: K,
|
|
214
|
-
payload: Buffer,
|
|
215
|
-
disableResponse: boolean,
|
|
216
|
-
): Promise<ZdoTypes.RequestToResponseMap[K] | undefined> {
|
|
217
|
-
return await this.queue.execute(async () => {
|
|
218
|
-
// stack-specific requirements
|
|
219
|
-
// https://zigate.fr/documentation/commandes-zigate/
|
|
220
|
-
switch (clusterId) {
|
|
221
|
-
case Zdo.ClusterId.LEAVE_REQUEST: {
|
|
222
|
-
// extra zero for `removeChildren`
|
|
223
|
-
const prefixedPayload = Buffer.alloc(payload.length + 1);
|
|
224
|
-
prefixedPayload.set(payload, 0);
|
|
225
|
-
|
|
226
|
-
payload = prefixedPayload;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
case Zdo.ClusterId.BIND_REQUEST:
|
|
231
|
-
case Zdo.ClusterId.UNBIND_REQUEST: {
|
|
232
|
-
// only need adjusting when Zdo.MULTICAST_BINDING
|
|
233
|
-
if (payload.length === 14) {
|
|
234
|
-
// extra zero for `endpoint`
|
|
235
|
-
const prefixedPayload = Buffer.alloc(payload.length + 1);
|
|
236
|
-
prefixedPayload.set(payload, 0);
|
|
237
|
-
|
|
238
|
-
payload = prefixedPayload;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
case Zdo.ClusterId.PERMIT_JOINING_REQUEST:
|
|
245
|
-
case Zdo.ClusterId.SYSTEM_SERVER_DISCOVERY_REQUEST:
|
|
246
|
-
case Zdo.ClusterId.LQI_TABLE_REQUEST:
|
|
247
|
-
case Zdo.ClusterId.ROUTING_TABLE_REQUEST:
|
|
248
|
-
case Zdo.ClusterId.BINDING_TABLE_REQUEST:
|
|
249
|
-
case Zdo.ClusterId.NWK_UPDATE_REQUEST: {
|
|
250
|
-
const prefixedPayload = Buffer.alloc(payload.length + 2);
|
|
251
|
-
prefixedPayload.writeUInt16BE(networkAddress, 0);
|
|
252
|
-
prefixedPayload.set(payload, 2);
|
|
253
|
-
|
|
254
|
-
payload = prefixedPayload;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
let waiter: ReturnType<typeof this.driver.zdoWaitFor> | undefined;
|
|
260
|
-
|
|
261
|
-
if (!disableResponse) {
|
|
262
|
-
const responseClusterId = Zdo.Utils.getResponseClusterId(clusterId);
|
|
263
|
-
|
|
264
|
-
if (responseClusterId) {
|
|
265
|
-
waiter = this.driver.zdoWaitFor({
|
|
266
|
-
clusterId: responseClusterId,
|
|
267
|
-
target:
|
|
268
|
-
responseClusterId === Zdo.ClusterId.NETWORK_ADDRESS_RESPONSE || responseClusterId === Zdo.ClusterId.LEAVE_RESPONSE
|
|
269
|
-
? ieeeAddress
|
|
270
|
-
: networkAddress,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
await this.driver.requestZdo(clusterId, payload);
|
|
276
|
-
|
|
277
|
-
if (waiter) {
|
|
278
|
-
const result = await waiter.start().promise;
|
|
279
|
-
|
|
280
|
-
return result.zdo as ZdoTypes.RequestToResponseMap[K];
|
|
281
|
-
}
|
|
282
|
-
}, networkAddress);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
public async sendZclFrameToEndpoint(
|
|
286
|
-
ieeeAddr: string,
|
|
287
|
-
networkAddress: number,
|
|
288
|
-
endpoint: number,
|
|
289
|
-
zclFrame: Zcl.Frame,
|
|
290
|
-
timeout: number,
|
|
291
|
-
disableResponse: boolean,
|
|
292
|
-
disableRecovery: boolean,
|
|
293
|
-
sourceEndpoint?: number,
|
|
294
|
-
): Promise<Events.ZclPayload | undefined> {
|
|
295
|
-
return await this.queue.execute<Events.ZclPayload | undefined>(async () => {
|
|
296
|
-
return await this.sendZclFrameToEndpointInternal(
|
|
297
|
-
ieeeAddr,
|
|
298
|
-
networkAddress,
|
|
299
|
-
endpoint,
|
|
300
|
-
sourceEndpoint || 1,
|
|
301
|
-
zclFrame,
|
|
302
|
-
timeout,
|
|
303
|
-
disableResponse,
|
|
304
|
-
disableRecovery,
|
|
305
|
-
0,
|
|
306
|
-
0,
|
|
307
|
-
false,
|
|
308
|
-
false,
|
|
309
|
-
);
|
|
310
|
-
}, networkAddress);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
private async sendZclFrameToEndpointInternal(
|
|
314
|
-
ieeeAddr: string | undefined,
|
|
315
|
-
networkAddress: number,
|
|
316
|
-
endpoint: number,
|
|
317
|
-
sourceEndpoint: number,
|
|
318
|
-
zclFrame: Zcl.Frame,
|
|
319
|
-
timeout: number,
|
|
320
|
-
disableResponse: boolean,
|
|
321
|
-
disableRecovery: boolean,
|
|
322
|
-
responseAttempt: number,
|
|
323
|
-
dataRequestAttempt: number,
|
|
324
|
-
checkedNetworkAddress: boolean,
|
|
325
|
-
discoveredRoute: boolean,
|
|
326
|
-
): Promise<Events.ZclPayload | undefined> {
|
|
327
|
-
logger.debug(
|
|
328
|
-
`sendZclFrameToEndpointInternal ${ieeeAddr}:${networkAddress}/${endpoint} (${responseAttempt},${dataRequestAttempt},${this.queue.count()})`,
|
|
329
|
-
NS,
|
|
330
|
-
);
|
|
331
|
-
let response = null;
|
|
332
|
-
|
|
333
|
-
const data = zclFrame.toBuffer();
|
|
334
|
-
const command = zclFrame.command;
|
|
335
|
-
const payload: RawAPSDataRequestPayload = {
|
|
336
|
-
addressMode: AddressMode.Short, //nwk
|
|
337
|
-
targetShortAddress: networkAddress,
|
|
338
|
-
sourceEndpoint: sourceEndpoint || ZSpec.HA_ENDPOINT,
|
|
339
|
-
destinationEndpoint: endpoint,
|
|
340
|
-
profileID: ZSpec.HA_PROFILE_ID,
|
|
341
|
-
clusterID: zclFrame.cluster.ID,
|
|
342
|
-
securityMode: 0x02,
|
|
343
|
-
radius: 30,
|
|
344
|
-
dataLength: data.length,
|
|
345
|
-
data: data,
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
if (command.response !== undefined && disableResponse === false) {
|
|
349
|
-
response = this.waitFor(
|
|
350
|
-
networkAddress,
|
|
351
|
-
endpoint,
|
|
352
|
-
zclFrame.header.frameControl.frameType,
|
|
353
|
-
Zcl.Direction.SERVER_TO_CLIENT,
|
|
354
|
-
zclFrame.header.transactionSequenceNumber,
|
|
355
|
-
zclFrame.cluster.ID,
|
|
356
|
-
command.response,
|
|
357
|
-
timeout,
|
|
358
|
-
);
|
|
359
|
-
} else if (!zclFrame.header.frameControl.disableDefaultResponse) {
|
|
360
|
-
response = this.waitFor(
|
|
361
|
-
networkAddress,
|
|
362
|
-
endpoint,
|
|
363
|
-
Zcl.FrameType.GLOBAL,
|
|
364
|
-
Zcl.Direction.SERVER_TO_CLIENT,
|
|
365
|
-
zclFrame.header.transactionSequenceNumber,
|
|
366
|
-
zclFrame.cluster.ID,
|
|
367
|
-
Zcl.Foundation.defaultRsp.ID,
|
|
368
|
-
timeout,
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
try {
|
|
373
|
-
await this.driver.sendCommand(ZiGateCommandCode.RawAPSDataRequest, payload, undefined, {}, disableResponse);
|
|
374
|
-
} catch {
|
|
375
|
-
if (responseAttempt < 1 && !disableRecovery) {
|
|
376
|
-
// @todo discover route
|
|
377
|
-
return await this.sendZclFrameToEndpointInternal(
|
|
378
|
-
ieeeAddr,
|
|
379
|
-
networkAddress,
|
|
380
|
-
endpoint,
|
|
381
|
-
sourceEndpoint,
|
|
382
|
-
zclFrame,
|
|
383
|
-
timeout,
|
|
384
|
-
disableResponse,
|
|
385
|
-
disableRecovery,
|
|
386
|
-
responseAttempt + 1,
|
|
387
|
-
dataRequestAttempt,
|
|
388
|
-
checkedNetworkAddress,
|
|
389
|
-
discoveredRoute,
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// @TODO add dataConfirmResult
|
|
395
|
-
// @TODO if error codes route / no_resourses wait and resend
|
|
396
|
-
if (response !== null) {
|
|
397
|
-
try {
|
|
398
|
-
return await response.promise;
|
|
399
|
-
|
|
400
|
-
// @todo discover route
|
|
401
|
-
} catch (error) {
|
|
402
|
-
logger.error(`Response error ${(error as Error).message} (${ieeeAddr}:${networkAddress},${responseAttempt})`, NS);
|
|
403
|
-
if (responseAttempt < 1 && !disableRecovery) {
|
|
404
|
-
return await this.sendZclFrameToEndpointInternal(
|
|
405
|
-
ieeeAddr,
|
|
406
|
-
networkAddress,
|
|
407
|
-
endpoint,
|
|
408
|
-
sourceEndpoint,
|
|
409
|
-
zclFrame,
|
|
410
|
-
timeout,
|
|
411
|
-
disableResponse,
|
|
412
|
-
disableRecovery,
|
|
413
|
-
responseAttempt + 1,
|
|
414
|
-
dataRequestAttempt,
|
|
415
|
-
checkedNetworkAddress,
|
|
416
|
-
discoveredRoute,
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
throw error;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
public async sendZclFrameToAll(endpoint: number, zclFrame: Zcl.Frame, sourceEndpoint: number, destination: BroadcastAddress): Promise<void> {
|
|
426
|
-
return await this.queue.execute<void>(async () => {
|
|
427
|
-
if (sourceEndpoint !== 0x01 /*&& sourceEndpoint !== 242*/) {
|
|
428
|
-
// @todo on zigate firmware without gp causes hang
|
|
429
|
-
logger.error(`source endpoint ${sourceEndpoint}, not supported`, NS);
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
const data = zclFrame.toBuffer();
|
|
434
|
-
const payload: RawAPSDataRequestPayload = {
|
|
435
|
-
addressMode: AddressMode.Short, //nwk
|
|
436
|
-
targetShortAddress: destination,
|
|
437
|
-
sourceEndpoint: sourceEndpoint,
|
|
438
|
-
destinationEndpoint: endpoint,
|
|
439
|
-
profileID: /*sourceEndpoint === ZSpec.GP_ENDPOINT ? ZSpec.GP_PROFILE_ID :*/ ZSpec.HA_PROFILE_ID,
|
|
440
|
-
clusterID: zclFrame.cluster.ID,
|
|
441
|
-
securityMode: 0x02,
|
|
442
|
-
radius: 30,
|
|
443
|
-
dataLength: data.length,
|
|
444
|
-
data: data,
|
|
445
|
-
};
|
|
446
|
-
logger.debug(() => `sendZclFrameToAll ${JSON.stringify(payload)}`, NS);
|
|
447
|
-
|
|
448
|
-
await this.driver.sendCommand(ZiGateCommandCode.RawAPSDataRequest, payload, undefined, {}, true);
|
|
449
|
-
await wait(200);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
public async sendZclFrameToGroup(groupID: number, zclFrame: Zcl.Frame, sourceEndpoint?: number): Promise<void> {
|
|
454
|
-
return await this.queue.execute<void>(async () => {
|
|
455
|
-
const data = zclFrame.toBuffer();
|
|
456
|
-
const payload: RawAPSDataRequestPayload = {
|
|
457
|
-
addressMode: AddressMode.Group, //nwk
|
|
458
|
-
targetShortAddress: groupID,
|
|
459
|
-
sourceEndpoint: sourceEndpoint || ZSpec.HA_ENDPOINT,
|
|
460
|
-
destinationEndpoint: 0xff,
|
|
461
|
-
profileID: ZSpec.HA_PROFILE_ID,
|
|
462
|
-
clusterID: zclFrame.cluster.ID,
|
|
463
|
-
securityMode: 0x02,
|
|
464
|
-
radius: 30,
|
|
465
|
-
dataLength: data.length,
|
|
466
|
-
data: data,
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
await this.driver.sendCommand(ZiGateCommandCode.RawAPSDataRequest, payload, undefined, {}, true);
|
|
470
|
-
await wait(200);
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Supplementary functions
|
|
476
|
-
*/
|
|
477
|
-
private async initNetwork(): Promise<void> {
|
|
478
|
-
logger.debug(`Set channel mask ${this.networkOptions.channelList} key`, NS);
|
|
479
|
-
await this.driver.sendCommand(ZiGateCommandCode.SetChannelMask, {
|
|
480
|
-
channelMask: ZSpec.Utils.channelsToUInt32Mask(this.networkOptions.channelList),
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
logger.debug("Set security key", NS);
|
|
484
|
-
await this.driver.sendCommand(ZiGateCommandCode.SetSecurityStateKey, {
|
|
485
|
-
keyType: this.networkOptions.networkKeyDistribute
|
|
486
|
-
? ZPSNwkKeyState.ZPS_ZDO_DISTRIBUTED_LINK_KEY
|
|
487
|
-
: ZPSNwkKeyState.ZPS_ZDO_PRECONFIGURED_LINK_KEY,
|
|
488
|
-
key: this.networkOptions.networkKey,
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
try {
|
|
492
|
-
// The block is wrapped in trapping because if the network is already created, the firmware does not accept the new key.
|
|
493
|
-
logger.debug(
|
|
494
|
-
`Set EPanID ${
|
|
495
|
-
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
496
|
-
this.networkOptions.extendedPanID!.toString()
|
|
497
|
-
}`,
|
|
498
|
-
NS,
|
|
499
|
-
);
|
|
500
|
-
await this.driver.sendCommand(ZiGateCommandCode.SetExtendedPANID, {
|
|
501
|
-
panId: this.networkOptions.extendedPanID,
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
await this.driver.sendCommand(ZiGateCommandCode.StartNetwork, {});
|
|
505
|
-
} catch (error) {
|
|
506
|
-
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
507
|
-
logger.error((error as Error).stack!, NS);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
public waitFor(
|
|
512
|
-
networkAddress: number | undefined,
|
|
513
|
-
endpoint: number,
|
|
514
|
-
frameType: Zcl.FrameType,
|
|
515
|
-
direction: Zcl.Direction,
|
|
516
|
-
transactionSequenceNumber: number | undefined,
|
|
517
|
-
clusterID: number,
|
|
518
|
-
commandIdentifier: number,
|
|
519
|
-
timeout: number,
|
|
520
|
-
): {promise: Promise<Events.ZclPayload>; cancel: () => void} {
|
|
521
|
-
const payload = {
|
|
522
|
-
address: networkAddress,
|
|
523
|
-
endpoint,
|
|
524
|
-
clusterID,
|
|
525
|
-
commandIdentifier,
|
|
526
|
-
frameType,
|
|
527
|
-
direction,
|
|
528
|
-
transactionSequenceNumber,
|
|
529
|
-
};
|
|
530
|
-
const waiter = this.waitress.waitFor(payload, timeout);
|
|
531
|
-
const cancel = (): void => this.waitress.remove(waiter.ID);
|
|
532
|
-
return {promise: waiter.start().promise, cancel};
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* InterPAN !!! not implemented
|
|
537
|
-
*/
|
|
538
|
-
public async setChannelInterPAN(_channel: number): Promise<void> {
|
|
539
|
-
await Promise.reject(new Error("Not supported"));
|
|
540
|
-
}
|
|
541
|
-
public async sendZclFrameInterPANToIeeeAddr(_zclFrame: Zcl.Frame, _ieeeAddress: string): Promise<void> {
|
|
542
|
-
await Promise.reject(new Error("Not supported"));
|
|
543
|
-
}
|
|
544
|
-
public async sendZclFrameInterPANBroadcast(_zclFrame: Zcl.Frame, _timeout: number): Promise<Events.ZclPayload> {
|
|
545
|
-
return await Promise.reject(new Error("Not supported"));
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
public async restoreChannelInterPAN(): Promise<void> {
|
|
549
|
-
await Promise.reject(new Error("Not supported"));
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
private deviceAnnounceListener(response: ZdoTypes.EndDeviceAnnounce): void {
|
|
553
|
-
// @todo debounce
|
|
554
|
-
if (this.joinPermitted === true) {
|
|
555
|
-
this.emit("deviceJoined", {networkAddress: response.nwkAddress, ieeeAddr: response.eui64});
|
|
556
|
-
} else {
|
|
557
|
-
// convert to `zdoResponse` to avoid needing extra event upstream
|
|
558
|
-
this.emit("zdoResponse", Zdo.ClusterId.END_DEVICE_ANNOUNCE, [Zdo.Status.SUCCESS, response]);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
private onZdoResponse(clusterId: Zdo.ClusterId, response: ZdoTypes.GenericZdoResponse): void {
|
|
563
|
-
this.emit("zdoResponse", clusterId, response);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
private dataListener(ziGateObject: ZiGateObject): void {
|
|
567
|
-
const payload: Events.ZclPayload = {
|
|
568
|
-
address: <number>ziGateObject.payload.sourceAddress,
|
|
569
|
-
clusterID: ziGateObject.payload.clusterID,
|
|
570
|
-
data: ziGateObject.payload.payload,
|
|
571
|
-
header: Zcl.Header.fromBuffer(ziGateObject.payload.payload),
|
|
572
|
-
endpoint: <number>ziGateObject.payload.sourceEndpoint,
|
|
573
|
-
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
574
|
-
linkquality: ziGateObject.frame!.readRSSI(), // read: frame valid
|
|
575
|
-
groupID: 0, // @todo
|
|
576
|
-
wasBroadcast: false, // TODO
|
|
577
|
-
destinationEndpoint: <number>ziGateObject.payload.destinationEndpoint,
|
|
578
|
-
};
|
|
579
|
-
this.waitress.resolve(payload);
|
|
580
|
-
this.emit("zclPayload", payload);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
private leaveIndicationListener(ziGateObject: ZiGateObject): void {
|
|
584
|
-
logger.debug(() => `LeaveIndication ${JSON.stringify(ziGateObject)}`, NS);
|
|
585
|
-
const payload: Events.DeviceLeavePayload = {
|
|
586
|
-
networkAddress: <number>ziGateObject.payload.extendedAddress,
|
|
587
|
-
ieeeAddr: <string>ziGateObject.payload.extendedAddress,
|
|
588
|
-
};
|
|
589
|
-
this.emit("deviceLeave", payload);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
private waitressTimeoutFormatter(matcher: WaitressMatcher, timeout: number): string {
|
|
593
|
-
return (
|
|
594
|
-
`Timeout - ${matcher.address} - ${matcher.endpoint}` +
|
|
595
|
-
` - ${matcher.transactionSequenceNumber} - ${matcher.clusterID}` +
|
|
596
|
-
` - ${matcher.commandIdentifier} after ${timeout}ms`
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
private waitressValidator(payload: Events.ZclPayload, matcher: WaitressMatcher): boolean {
|
|
601
|
-
return Boolean(
|
|
602
|
-
payload.header &&
|
|
603
|
-
(!matcher.address || payload.address === matcher.address) &&
|
|
604
|
-
matcher.endpoint === payload.endpoint &&
|
|
605
|
-
(!matcher.transactionSequenceNumber || payload.header.transactionSequenceNumber === matcher.transactionSequenceNumber) &&
|
|
606
|
-
matcher.clusterID === payload.clusterID &&
|
|
607
|
-
matcher.frameType === payload.header.frameControl.frameType &&
|
|
608
|
-
matcher.commandIdentifier === payload.header.commandIdentifier &&
|
|
609
|
-
matcher.direction === payload.header.frameControl.direction,
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
private onZiGateClose(): void {
|
|
614
|
-
if (!this.closing) {
|
|
615
|
-
this.emit("disconnected");
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
When writing the adapter, the first tests and code implementation examples were taken from
|
|
2
|
-
https://github.com/nouknouk/node-zigate
|
|
3
|
-
https://github.com/Neonox31/zigate
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
The zigate frame parsing is mostly inherited from Neonox31/zigate
|
|
7
|
-
driver/frame.ts
|
|
8
|
-
|
|
9
|
-
Copyright 2017 WEBER Logan <weberlogan@gmail.com>
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
-
|
|
17
|
-
|