zigbee-herdsman 0.57.2 → 0.57.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release_please.yml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +21 -0
- package/dist/adapter/adapter.d.ts +1 -1
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +2 -1
- package/dist/adapter/adapter.js.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.d.ts.map +1 -1
- package/dist/adapter/deconz/adapter/deconzAdapter.js +13 -12
- package/dist/adapter/deconz/adapter/deconzAdapter.js.map +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.d.ts +0 -14
- package/dist/adapter/ember/adapter/emberAdapter.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/emberAdapter.js +69 -114
- package/dist/adapter/ember/adapter/emberAdapter.js.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.d.ts.map +1 -1
- package/dist/adapter/ember/adapter/oneWaitress.js +1 -2
- package/dist/adapter/ember/adapter/oneWaitress.js.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/ezsp.js +15 -15
- package/dist/adapter/ember/ezsp/ezsp.js.map +1 -1
- package/dist/adapter/ember/uart/ash.js +2 -2
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.d.ts.map +1 -1
- package/dist/adapter/ezsp/adapter/ezspAdapter.js +27 -26
- package/dist/adapter/ezsp/adapter/ezspAdapter.js.map +1 -1
- package/dist/adapter/ezsp/driver/driver.d.ts +1 -2
- package/dist/adapter/ezsp/driver/driver.d.ts.map +1 -1
- package/dist/adapter/ezsp/driver/driver.js +33 -11
- package/dist/adapter/ezsp/driver/driver.js.map +1 -1
- package/dist/adapter/ezsp/driver/ezsp.js +4 -4
- package/dist/adapter/ezsp/driver/ezsp.js.map +1 -1
- package/dist/adapter/ezsp/driver/uart.js +3 -3
- package/dist/adapter/ezsp/driver/uart.js.map +1 -1
- package/dist/adapter/serialPort.js +5 -5
- package/dist/adapter/serialPort.js.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/adapter-backup.js +9 -9
- package/dist/adapter/z-stack/adapter/adapter-backup.js.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.d.ts +3 -1
- package/dist/adapter/z-stack/adapter/manager.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/manager.js +5 -6
- package/dist/adapter/z-stack/adapter/manager.js.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts +1 -2
- package/dist/adapter/z-stack/adapter/zStackAdapter.d.ts.map +1 -1
- package/dist/adapter/z-stack/adapter/zStackAdapter.js +113 -112
- package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
- package/dist/adapter/z-stack/unpi/frame.js +2 -2
- package/dist/adapter/z-stack/unpi/frame.js.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts +0 -4
- package/dist/adapter/z-stack/znp/buffaloZnp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/buffaloZnp.js +6 -101
- package/dist/adapter/z-stack/znp/buffaloZnp.js.map +1 -1
- package/dist/adapter/z-stack/znp/definition.d.ts +13 -1
- package/dist/adapter/z-stack/znp/definition.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/definition.js +164 -75
- package/dist/adapter/z-stack/znp/definition.js.map +1 -1
- package/dist/adapter/z-stack/znp/parameterType.d.ts +0 -4
- package/dist/adapter/z-stack/znp/parameterType.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/parameterType.js +0 -4
- package/dist/adapter/z-stack/znp/parameterType.js.map +1 -1
- package/dist/adapter/z-stack/znp/tstype.d.ts +26 -8
- package/dist/adapter/z-stack/znp/tstype.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/utils.d.ts +3 -0
- package/dist/adapter/z-stack/znp/utils.d.ts.map +1 -0
- package/dist/adapter/z-stack/znp/utils.js +11 -0
- package/dist/adapter/z-stack/znp/utils.js.map +1 -0
- package/dist/adapter/z-stack/znp/znp.d.ts +0 -1
- package/dist/adapter/z-stack/znp/znp.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/znp.js +15 -35
- package/dist/adapter/z-stack/znp/znp.js.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.d.ts +7 -7
- package/dist/adapter/z-stack/znp/zpiObject.d.ts.map +1 -1
- package/dist/adapter/z-stack/znp/zpiObject.js +35 -43
- package/dist/adapter/z-stack/znp/zpiObject.js.map +1 -1
- package/dist/adapter/zboss/adapter/zbossAdapter.d.ts.map +1 -1
- package/dist/adapter/zboss/adapter/zbossAdapter.js +21 -20
- package/dist/adapter/zboss/adapter/zbossAdapter.js.map +1 -1
- package/dist/adapter/zboss/driver.js +16 -16
- package/dist/adapter/zboss/driver.js.map +1 -1
- package/dist/adapter/zboss/uart.d.ts.map +1 -1
- package/dist/adapter/zboss/uart.js +6 -5
- package/dist/adapter/zboss/uart.js.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.d.ts.map +1 -1
- package/dist/adapter/zigate/adapter/zigateAdapter.js +20 -19
- package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/buffaloZiGate.js +1 -2
- package/dist/adapter/zigate/driver/buffaloZiGate.js.map +1 -1
- package/dist/adapter/zigate/driver/frame.js +1 -1
- package/dist/adapter/zigate/driver/frame.js.map +1 -1
- package/dist/adapter/zigate/driver/zigate.d.ts.map +1 -1
- package/dist/adapter/zigate/driver/zigate.js +11 -11
- package/dist/adapter/zigate/driver/zigate.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +1 -2
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/controller/controller.d.ts +3 -1
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +8 -6
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/greenPower.d.ts.map +1 -1
- package/dist/controller/greenPower.js +8 -7
- package/dist/controller/greenPower.js.map +1 -1
- package/dist/controller/helpers/requestQueue.js +1 -1
- package/dist/controller/helpers/requestQueue.js.map +1 -1
- package/dist/controller/model/device.d.ts +6 -2
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +39 -41
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +12 -13
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts +5 -2
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +21 -19
- package/dist/controller/model/group.js.map +1 -1
- package/dist/utils/logger.d.ts +4 -4
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +4 -4
- package/dist/utils/logger.js.map +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/cluster.js +1 -0
- package/dist/zspec/zcl/definition/cluster.js.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.d.ts +199 -85
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.js +434 -404
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
- package/dist/zspec/zdo/definition/clusters.d.ts +1 -1
- package/dist/zspec/zdo/definition/clusters.d.ts.map +1 -1
- package/dist/zspec/zdo/definition/clusters.js +1 -1
- package/dist/zspec/zdo/definition/clusters.js.map +1 -1
- package/dist/zspec/zdo/definition/enums.d.ts +10 -0
- package/dist/zspec/zdo/definition/enums.d.ts.map +1 -1
- package/dist/zspec/zdo/definition/enums.js +12 -1
- package/dist/zspec/zdo/definition/enums.js.map +1 -1
- package/dist/zspec/zdo/definition/tstypes.d.ts +7 -5
- package/dist/zspec/zdo/definition/tstypes.d.ts.map +1 -1
- package/dist/zspec/zdo/index.d.ts +1 -0
- package/dist/zspec/zdo/index.d.ts.map +1 -1
- package/dist/zspec/zdo/index.js +3 -1
- package/dist/zspec/zdo/index.js.map +1 -1
- package/dist/zspec/zdo/utils.js +2 -2
- package/eslint.config.mjs +2 -2
- package/package.json +6 -6
|
@@ -30,8 +30,9 @@ const assert_1 = __importDefault(require("assert"));
|
|
|
30
30
|
const debounce_1 = __importDefault(require("debounce"));
|
|
31
31
|
const utils_1 = require("../../../utils");
|
|
32
32
|
const logger_1 = require("../../../utils/logger");
|
|
33
|
+
const ZSpec = __importStar(require("../../../zspec"));
|
|
33
34
|
const Zcl = __importStar(require("../../../zspec/zcl"));
|
|
34
|
-
const
|
|
35
|
+
const Zdo = __importStar(require("../../../zspec/zdo"));
|
|
35
36
|
const adapter_1 = __importDefault(require("../../adapter"));
|
|
36
37
|
const Constants = __importStar(require("../constants"));
|
|
37
38
|
const unpi_1 = require("../unpi");
|
|
@@ -77,6 +78,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
77
78
|
waitress;
|
|
78
79
|
constructor(networkOptions, serialPortOptions, backupPath, adapterOptions) {
|
|
79
80
|
super(networkOptions, serialPortOptions, backupPath, adapterOptions);
|
|
81
|
+
this.hasZdoMessageOverhead = false;
|
|
80
82
|
this.znp = new znp_1.Znp(this.serialPortOptions.path, this.serialPortOptions.baudRate, this.serialPortOptions.rtscts);
|
|
81
83
|
this.transactionID = 0;
|
|
82
84
|
this.deviceAnnounceRouteDiscoveryDebouncers = new Map();
|
|
@@ -120,10 +122,10 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
120
122
|
logger_1.logger.debug(`Adapter concurrent: ${concurrent}`, NS);
|
|
121
123
|
this.queue = new utils_1.Queue(concurrent);
|
|
122
124
|
logger_1.logger.debug(`Detected znp version '${tstype_1.ZnpVersion[this.version.product]}' (${JSON.stringify(this.version)})`, NS);
|
|
123
|
-
this.adapterManager = new manager_1.ZnpAdapterManager(this.znp, {
|
|
125
|
+
this.adapterManager = new manager_1.ZnpAdapterManager(this, this.znp, {
|
|
124
126
|
backupPath: this.backupPath,
|
|
125
127
|
version: this.version.product,
|
|
126
|
-
greenPowerGroup:
|
|
128
|
+
greenPowerGroup: ZSpec.GP_GROUP_ID,
|
|
127
129
|
networkOptions: this.networkOptions,
|
|
128
130
|
adapterOptions: this.adapterOptions,
|
|
129
131
|
});
|
|
@@ -136,36 +138,32 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
136
138
|
if (this.adapterOptions.transmitPower != null) {
|
|
137
139
|
await this.setTransmitPower(this.adapterOptions.transmitPower);
|
|
138
140
|
}
|
|
139
|
-
return startResult;
|
|
141
|
+
return await startResult;
|
|
140
142
|
}
|
|
141
143
|
async stop() {
|
|
142
144
|
this.closing = true;
|
|
143
145
|
await this.znp.close();
|
|
144
146
|
}
|
|
145
147
|
static async isValidPath(path) {
|
|
146
|
-
return znp_1.Znp.isValidPath(path);
|
|
148
|
+
return await znp_1.Znp.isValidPath(path);
|
|
147
149
|
}
|
|
148
150
|
static async autoDetectPath() {
|
|
149
|
-
return znp_1.Znp.autoDetectPath();
|
|
151
|
+
return await znp_1.Znp.autoDetectPath();
|
|
150
152
|
}
|
|
151
153
|
async getCoordinator() {
|
|
152
|
-
return this.queue.execute(async () => {
|
|
154
|
+
return await this.queue.execute(async () => {
|
|
153
155
|
this.checkInterpanLock();
|
|
154
|
-
const
|
|
155
|
-
await this.znp.request(Subsystem.ZDO, 'activeEpReq', { dstaddr: 0, nwkaddrofinterest: 0 }, activeEpRsp.ID);
|
|
156
|
-
const activeEp = await activeEpRsp.start();
|
|
156
|
+
const activeEp = await this.activeEndpoints(0);
|
|
157
157
|
const deviceInfo = await this.znp.requestWithReply(Subsystem.UTIL, 'getDeviceInfo', {});
|
|
158
158
|
const endpoints = [];
|
|
159
|
-
for (const endpoint of activeEp.
|
|
160
|
-
const
|
|
161
|
-
await this.znp.request(Subsystem.ZDO, 'simpleDescReq', { dstaddr: 0, nwkaddrofinterest: 0, endpoint }, simpleDescRsp.ID);
|
|
162
|
-
const simpleDesc = await simpleDescRsp.start();
|
|
159
|
+
for (const endpoint of activeEp.endpoints) {
|
|
160
|
+
const simpleDesc = await this.simpleDescriptor(0, endpoint);
|
|
163
161
|
endpoints.push({
|
|
164
|
-
ID: simpleDesc.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
inputClusters: simpleDesc.
|
|
168
|
-
outputClusters: simpleDesc.
|
|
162
|
+
ID: simpleDesc.endpointID,
|
|
163
|
+
deviceID: simpleDesc.deviceID,
|
|
164
|
+
profileID: simpleDesc.profileID,
|
|
165
|
+
inputClusters: simpleDesc.inputClusters,
|
|
166
|
+
outputClusters: simpleDesc.outputClusters,
|
|
169
167
|
});
|
|
170
168
|
}
|
|
171
169
|
return {
|
|
@@ -182,7 +180,9 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
182
180
|
await this.queue.execute(async () => {
|
|
183
181
|
this.checkInterpanLock();
|
|
184
182
|
const payload = { addrmode, dstaddr, duration: seconds, tcsignificance: 0 };
|
|
183
|
+
const permitJoinRsp = this.waitForAreqZdo('mgmtPermitJoinRsp');
|
|
185
184
|
await this.znp.request(Subsystem.ZDO, 'mgmtPermitJoinReq', payload);
|
|
185
|
+
await permitJoinRsp.start();
|
|
186
186
|
await this.setLED(seconds == 0 ? 'off' : 'on');
|
|
187
187
|
});
|
|
188
188
|
}
|
|
@@ -234,7 +234,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
234
234
|
const response = this.waitForAreqZdo('nwkAddrRsp', { ieeeaddr: ieeeAddr });
|
|
235
235
|
await this.znp.request(Subsystem.ZDO, 'nwkAddrReq', { ieeeaddr: ieeeAddr, reqtype: 0, startindex: 0 });
|
|
236
236
|
const result = await response.start();
|
|
237
|
-
return result.
|
|
237
|
+
return result.nwkAddress;
|
|
238
238
|
}
|
|
239
239
|
supportsAssocRemove() {
|
|
240
240
|
return this.version.product === tstype_1.ZnpVersion.zStack3x0 && parseInt(this.version.revision) >= 20200805;
|
|
@@ -251,7 +251,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
async nodeDescriptor(networkAddress) {
|
|
254
|
-
return this.queue.execute(async () => {
|
|
254
|
+
return await this.queue.execute(async () => {
|
|
255
255
|
this.checkInterpanLock();
|
|
256
256
|
try {
|
|
257
257
|
const result = await this.nodeDescriptorInternal(networkAddress);
|
|
@@ -268,12 +268,12 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
268
268
|
}, networkAddress);
|
|
269
269
|
}
|
|
270
270
|
async nodeDescriptorInternal(networkAddress) {
|
|
271
|
-
const response = this.waitForAreqZdo('nodeDescRsp', {
|
|
271
|
+
const response = this.waitForAreqZdo('nodeDescRsp', { srcaddr: networkAddress });
|
|
272
272
|
const payload = { dstaddr: networkAddress, nwkaddrofinterest: networkAddress };
|
|
273
273
|
await this.znp.request(Subsystem.ZDO, 'nodeDescReq', payload, response.ID);
|
|
274
274
|
const descriptor = await response.start();
|
|
275
275
|
let type = 'Unknown';
|
|
276
|
-
const logicalType = descriptor.
|
|
276
|
+
const logicalType = descriptor.logicalType;
|
|
277
277
|
for (const [key, value] of Object.entries(Constants.ZDO.deviceLogicalType)) {
|
|
278
278
|
if (value === logicalType) {
|
|
279
279
|
if (key === 'COORDINATOR')
|
|
@@ -285,39 +285,38 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
return { manufacturerCode: descriptor.
|
|
288
|
+
return { manufacturerCode: descriptor.manufacturerCode, type };
|
|
289
289
|
}
|
|
290
290
|
async activeEndpoints(networkAddress) {
|
|
291
|
-
return this.queue.execute(async () => {
|
|
291
|
+
return await this.queue.execute(async () => {
|
|
292
292
|
this.checkInterpanLock();
|
|
293
|
-
const response = this.waitForAreqZdo('activeEpRsp', {
|
|
293
|
+
const response = this.waitForAreqZdo('activeEpRsp', { srcaddr: networkAddress });
|
|
294
294
|
const payload = { dstaddr: networkAddress, nwkaddrofinterest: networkAddress };
|
|
295
295
|
await this.znp.request(Subsystem.ZDO, 'activeEpReq', payload, response.ID);
|
|
296
296
|
const activeEp = await response.start();
|
|
297
|
-
return { endpoints: activeEp.
|
|
297
|
+
return { endpoints: activeEp.endpointList };
|
|
298
298
|
}, networkAddress);
|
|
299
299
|
}
|
|
300
300
|
async simpleDescriptor(networkAddress, endpointID) {
|
|
301
|
-
return this.queue.execute(async () => {
|
|
301
|
+
return await this.queue.execute(async () => {
|
|
302
302
|
this.checkInterpanLock();
|
|
303
|
-
const
|
|
304
|
-
const response = this.waitForAreqZdo('simpleDescRsp', responsePayload);
|
|
303
|
+
const response = this.waitForAreqZdo('simpleDescRsp', { srcaddr: networkAddress });
|
|
305
304
|
const payload = { dstaddr: networkAddress, nwkaddrofinterest: networkAddress, endpoint: endpointID };
|
|
306
305
|
await this.znp.request(Subsystem.ZDO, 'simpleDescReq', payload, response.ID);
|
|
307
306
|
const descriptor = await response.start();
|
|
308
307
|
return {
|
|
309
|
-
profileID: descriptor.
|
|
310
|
-
endpointID: descriptor.
|
|
311
|
-
deviceID: descriptor.
|
|
312
|
-
inputClusters: descriptor.
|
|
313
|
-
outputClusters: descriptor.
|
|
308
|
+
profileID: descriptor.profileId,
|
|
309
|
+
endpointID: descriptor.endpoint,
|
|
310
|
+
deviceID: descriptor.deviceId,
|
|
311
|
+
inputClusters: descriptor.inClusterList,
|
|
312
|
+
outputClusters: descriptor.outClusterList,
|
|
314
313
|
};
|
|
315
314
|
}, networkAddress);
|
|
316
315
|
}
|
|
317
316
|
async sendZclFrameToEndpoint(ieeeAddr, networkAddress, endpoint, zclFrame, timeout, disableResponse, disableRecovery, sourceEndpoint) {
|
|
318
|
-
return this.queue.execute(async () => {
|
|
317
|
+
return await this.queue.execute(async () => {
|
|
319
318
|
this.checkInterpanLock();
|
|
320
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint || 1, zclFrame, timeout, disableResponse, disableRecovery, 0, 0, false, false, false, undefined);
|
|
319
|
+
return await this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint || 1, zclFrame, timeout, disableResponse, disableRecovery, 0, 0, false, false, false, undefined);
|
|
321
320
|
}, networkAddress);
|
|
322
321
|
}
|
|
323
322
|
async sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore) {
|
|
@@ -371,7 +370,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
371
370
|
* wait some time and retry.
|
|
372
371
|
*/
|
|
373
372
|
await (0, utils_1.Wait)(2000);
|
|
374
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt + 1, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
373
|
+
return await this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt + 1, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
375
374
|
}
|
|
376
375
|
else {
|
|
377
376
|
let doAssocRemove = false;
|
|
@@ -433,7 +432,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
433
432
|
logger_1.logger.debug('Wait 2000ms', NS);
|
|
434
433
|
await (0, utils_1.Wait)(2000);
|
|
435
434
|
}
|
|
436
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt + 1, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
435
|
+
return await this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt, dataRequestAttempt + 1, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
437
436
|
}
|
|
438
437
|
}
|
|
439
438
|
if (response !== null) {
|
|
@@ -466,7 +465,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
466
465
|
}
|
|
467
466
|
// No response could be of invalid route, e.g. when message is send to wrong parent of end device.
|
|
468
467
|
await this.discoverRoute(networkAddress);
|
|
469
|
-
return this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt + 1, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
468
|
+
return await this.sendZclFrameToEndpointInternal(ieeeAddr, networkAddress, endpoint, sourceEndpoint, zclFrame, timeout, disableResponse, disableRecovery, responseAttempt + 1, dataRequestAttempt, checkedNetworkAddress, discoveredRoute, assocRemove, assocRestore);
|
|
470
469
|
}
|
|
471
470
|
else {
|
|
472
471
|
throw error;
|
|
@@ -475,7 +474,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
475
474
|
}
|
|
476
475
|
}
|
|
477
476
|
async sendZclFrameToGroup(groupID, zclFrame, sourceEndpoint) {
|
|
478
|
-
return this.queue.execute(async () => {
|
|
477
|
+
return await this.queue.execute(async () => {
|
|
479
478
|
this.checkInterpanLock();
|
|
480
479
|
await this.dataRequestExtended(AddressMode.ADDR_GROUP, groupID, 0xff, 0, sourceEndpoint || 1, zclFrame.cluster.ID, Constants.AF.DEFAULT_RADIUS, zclFrame.toBuffer(), 3000, true);
|
|
481
480
|
/**
|
|
@@ -487,7 +486,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
487
486
|
});
|
|
488
487
|
}
|
|
489
488
|
async sendZclFrameToAll(endpoint, zclFrame, sourceEndpoint, destination) {
|
|
490
|
-
return this.queue.execute(async () => {
|
|
489
|
+
return await this.queue.execute(async () => {
|
|
491
490
|
this.checkInterpanLock();
|
|
492
491
|
await this.dataRequestExtended(AddressMode.ADDR_16BIT, destination, endpoint, 0, sourceEndpoint, zclFrame.cluster.ID, Constants.AF.DEFAULT_RADIUS, zclFrame.toBuffer(), 3000, false, 0);
|
|
493
492
|
/**
|
|
@@ -499,69 +498,65 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
499
498
|
});
|
|
500
499
|
}
|
|
501
500
|
async lqi(networkAddress) {
|
|
502
|
-
return this.queue.execute(async () => {
|
|
501
|
+
return await this.queue.execute(async () => {
|
|
503
502
|
this.checkInterpanLock();
|
|
504
503
|
const neighbors = [];
|
|
505
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
506
504
|
const request = async (startIndex) => {
|
|
507
505
|
const response = this.waitForAreqZdo('mgmtLqiRsp', { srcaddr: networkAddress });
|
|
508
506
|
await this.znp.request(Subsystem.ZDO, 'mgmtLqiReq', { dstaddr: networkAddress, startindex: startIndex }, response.ID);
|
|
509
507
|
const result = await response.start();
|
|
510
508
|
return result;
|
|
511
509
|
};
|
|
512
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
513
510
|
const add = (list) => {
|
|
514
511
|
for (const entry of list) {
|
|
515
512
|
neighbors.push({
|
|
516
513
|
linkquality: entry.lqi,
|
|
517
|
-
networkAddress: entry.
|
|
518
|
-
ieeeAddr: entry.
|
|
514
|
+
networkAddress: entry.nwkAddress,
|
|
515
|
+
ieeeAddr: entry.eui64,
|
|
519
516
|
relationship: entry.relationship,
|
|
520
517
|
depth: entry.depth,
|
|
521
518
|
});
|
|
522
519
|
}
|
|
523
520
|
};
|
|
524
521
|
let response = await request(0);
|
|
525
|
-
add(response.
|
|
526
|
-
const size = response.
|
|
527
|
-
let nextStartIndex = response.
|
|
522
|
+
add(response.entryList);
|
|
523
|
+
const size = response.neighborTableEntries;
|
|
524
|
+
let nextStartIndex = response.entryList.length;
|
|
528
525
|
while (neighbors.length < size) {
|
|
529
526
|
response = await request(nextStartIndex);
|
|
530
|
-
add(response.
|
|
531
|
-
nextStartIndex += response.
|
|
527
|
+
add(response.entryList);
|
|
528
|
+
nextStartIndex += response.entryList.length;
|
|
532
529
|
}
|
|
533
530
|
return { neighbors };
|
|
534
531
|
}, networkAddress);
|
|
535
532
|
}
|
|
536
533
|
async routingTable(networkAddress) {
|
|
537
|
-
return this.queue.execute(async () => {
|
|
534
|
+
return await this.queue.execute(async () => {
|
|
538
535
|
this.checkInterpanLock();
|
|
539
536
|
const table = [];
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
541
537
|
const request = async (startIndex) => {
|
|
542
538
|
const response = this.waitForAreqZdo('mgmtRtgRsp', { srcaddr: networkAddress });
|
|
543
539
|
await this.znp.request(Subsystem.ZDO, 'mgmtRtgReq', { dstaddr: networkAddress, startindex: startIndex }, response.ID);
|
|
544
540
|
const result = await response.start();
|
|
545
541
|
return result;
|
|
546
542
|
};
|
|
547
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
548
543
|
const add = (list) => {
|
|
549
544
|
for (const entry of list) {
|
|
550
545
|
table.push({
|
|
551
|
-
destinationAddress: entry.
|
|
552
|
-
status: entry.
|
|
553
|
-
nextHop: entry.
|
|
546
|
+
destinationAddress: entry.destinationAddress,
|
|
547
|
+
status: entry.status,
|
|
548
|
+
nextHop: entry.nextHopAddress,
|
|
554
549
|
});
|
|
555
550
|
}
|
|
556
551
|
};
|
|
557
552
|
let response = await request(0);
|
|
558
|
-
add(response.
|
|
559
|
-
const size = response.
|
|
560
|
-
let nextStartIndex = response.
|
|
553
|
+
add(response.entryList);
|
|
554
|
+
const size = response.routingTableEntries;
|
|
555
|
+
let nextStartIndex = response.entryList.length;
|
|
561
556
|
while (table.length < size) {
|
|
562
557
|
response = await request(nextStartIndex);
|
|
563
|
-
add(response.
|
|
564
|
-
nextStartIndex += response.
|
|
558
|
+
add(response.entryList);
|
|
559
|
+
nextStartIndex += response.entryList.length;
|
|
565
560
|
}
|
|
566
561
|
return { table };
|
|
567
562
|
}, networkAddress);
|
|
@@ -578,7 +573,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
578
573
|
await this.bindInternal('unbind', destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, type, destinationEndpoint);
|
|
579
574
|
}
|
|
580
575
|
async bindInternal(bindType, destinationNetworkAddress, sourceIeeeAddress, sourceEndpoint, clusterID, destinationAddressOrGroup, targetType, destinationEndpoint) {
|
|
581
|
-
return this.queue.execute(async () => {
|
|
576
|
+
return await this.queue.execute(async () => {
|
|
582
577
|
this.checkInterpanLock();
|
|
583
578
|
const response = this.waitForAreqZdo(`${bindType}Rsp`, { srcaddr: destinationNetworkAddress });
|
|
584
579
|
const payload = {
|
|
@@ -620,47 +615,55 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
620
615
|
return;
|
|
621
616
|
}
|
|
622
617
|
if (object.subsystem === Subsystem.ZDO) {
|
|
623
|
-
if (object.command === 'tcDeviceInd') {
|
|
618
|
+
if (object.command.name === 'tcDeviceInd') {
|
|
624
619
|
const payload = {
|
|
625
620
|
networkAddress: object.payload.nwkaddr,
|
|
626
621
|
ieeeAddr: object.payload.extaddr,
|
|
627
622
|
};
|
|
628
623
|
this.emit('deviceJoined', payload);
|
|
629
624
|
}
|
|
630
|
-
else if (object.command === 'endDeviceAnnceInd') {
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
if
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
//
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
625
|
+
else if (object.command.name === 'endDeviceAnnceInd') {
|
|
626
|
+
const zdoResult = object.parseZdoPayload();
|
|
627
|
+
/* istanbul ignore else */
|
|
628
|
+
if (Zdo.Buffalo.checkStatus(zdoResult)) {
|
|
629
|
+
const payload = {
|
|
630
|
+
networkAddress: zdoResult[1].nwkAddress,
|
|
631
|
+
ieeeAddr: zdoResult[1].eui64,
|
|
632
|
+
};
|
|
633
|
+
// Only discover routes to end devices, if bit 1 of capabilities === 0 it's an end device.
|
|
634
|
+
const isEndDevice = zdoResult[1].capabilities.deviceType === 0;
|
|
635
|
+
if (isEndDevice) {
|
|
636
|
+
if (!this.deviceAnnounceRouteDiscoveryDebouncers.has(payload.networkAddress)) {
|
|
637
|
+
// If a device announces multiple times in a very short time, it makes no sense
|
|
638
|
+
// to rediscover the route every time.
|
|
639
|
+
const debouncer = (0, debounce_1.default)(() => {
|
|
640
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
641
|
+
this.queue.execute(async () => {
|
|
642
|
+
/* istanbul ignore next */
|
|
643
|
+
this.discoverRoute(payload.networkAddress, false).catch(() => { });
|
|
644
|
+
}, payload.networkAddress);
|
|
645
|
+
}, 60 * 1000, { immediate: true });
|
|
646
|
+
this.deviceAnnounceRouteDiscoveryDebouncers.set(payload.networkAddress, debouncer);
|
|
647
|
+
}
|
|
648
|
+
const debouncer = this.deviceAnnounceRouteDiscoveryDebouncers.get(payload.networkAddress);
|
|
649
|
+
(0, assert_1.default)(debouncer);
|
|
650
|
+
debouncer();
|
|
649
651
|
}
|
|
650
|
-
|
|
651
|
-
(0, assert_1.default)(debouncer);
|
|
652
|
-
debouncer();
|
|
652
|
+
this.emit('deviceAnnounce', payload);
|
|
653
653
|
}
|
|
654
|
-
this.emit('deviceAnnounce', payload);
|
|
655
654
|
}
|
|
656
|
-
else if (object.command === 'nwkAddrRsp') {
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
655
|
+
else if (object.command.name === 'nwkAddrRsp') {
|
|
656
|
+
const zdoResult = object.parseZdoPayload();
|
|
657
|
+
/* istanbul ignore else */
|
|
658
|
+
if (Zdo.Buffalo.checkStatus(zdoResult)) {
|
|
659
|
+
const payload = {
|
|
660
|
+
networkAddress: zdoResult[1].nwkAddress,
|
|
661
|
+
ieeeAddr: zdoResult[1].eui64,
|
|
662
|
+
};
|
|
663
|
+
this.emit('networkAddress', payload);
|
|
664
|
+
}
|
|
662
665
|
}
|
|
663
|
-
else if (object.command === 'concentratorIndCb') {
|
|
666
|
+
else if (object.command.name === 'concentratorIndCb') {
|
|
664
667
|
// Some routers may change short addresses and the announcement
|
|
665
668
|
// is missed by the coordinator. This can happen when there are
|
|
666
669
|
// power outages or other interruptions in service. They may
|
|
@@ -679,7 +682,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
679
682
|
}
|
|
680
683
|
else {
|
|
681
684
|
/* istanbul ignore else */
|
|
682
|
-
if (object.command === 'leaveInd') {
|
|
685
|
+
if (object.command.name === 'leaveInd') {
|
|
683
686
|
if (object.payload.rejoin) {
|
|
684
687
|
logger_1.logger.debug(`Device leave: Got leave indication with rejoin=true, nothing to do`, NS);
|
|
685
688
|
}
|
|
@@ -697,7 +700,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
697
700
|
/* istanbul ignore else */
|
|
698
701
|
if (object.subsystem === Subsystem.AF) {
|
|
699
702
|
/* istanbul ignore else */
|
|
700
|
-
if (object.command === 'incomingMsg' || object.command === 'incomingMsgExt') {
|
|
703
|
+
if (object.command.name === 'incomingMsg' || object.command.name === 'incomingMsgExt') {
|
|
701
704
|
const payload = {
|
|
702
705
|
clusterID: object.payload.clusterid,
|
|
703
706
|
data: object.payload.data,
|
|
@@ -727,10 +730,10 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
727
730
|
return true;
|
|
728
731
|
}
|
|
729
732
|
async backup(ieeeAddressesInDatabase) {
|
|
730
|
-
return this.adapterManager.backup.createBackup(ieeeAddressesInDatabase);
|
|
733
|
+
return await this.adapterManager.backup.createBackup(ieeeAddressesInDatabase);
|
|
731
734
|
}
|
|
732
735
|
async setChannelInterPAN(channel) {
|
|
733
|
-
return this.queue.execute(async () => {
|
|
736
|
+
return await this.queue.execute(async () => {
|
|
734
737
|
this.interpanLock = true;
|
|
735
738
|
await this.znp.request(Subsystem.AF, 'interPanCtl', { cmd: 1, data: [channel] });
|
|
736
739
|
if (!this.interpanEndpointRegistered) {
|
|
@@ -741,12 +744,12 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
741
744
|
});
|
|
742
745
|
}
|
|
743
746
|
async sendZclFrameInterPANToIeeeAddr(zclFrame, ieeeAddr) {
|
|
744
|
-
return this.queue.execute(async () => {
|
|
747
|
+
return await this.queue.execute(async () => {
|
|
745
748
|
await this.dataRequestExtended(AddressMode.ADDR_64BIT, ieeeAddr, 0xfe, 0xffff, 12, zclFrame.cluster.ID, 30, zclFrame.toBuffer(), 10000, false);
|
|
746
749
|
});
|
|
747
750
|
}
|
|
748
751
|
async sendZclFrameInterPANBroadcast(zclFrame, timeout) {
|
|
749
|
-
return this.queue.execute(async () => {
|
|
752
|
+
return await this.queue.execute(async () => {
|
|
750
753
|
const command = zclFrame.command;
|
|
751
754
|
if (command.response == undefined) {
|
|
752
755
|
throw new Error(`Command '${command.name}' has no response, cannot wait for response`);
|
|
@@ -759,11 +762,11 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
759
762
|
response.cancel();
|
|
760
763
|
throw error;
|
|
761
764
|
}
|
|
762
|
-
return response.start().promise;
|
|
765
|
+
return await response.start().promise;
|
|
763
766
|
});
|
|
764
767
|
}
|
|
765
768
|
async restoreChannelInterPAN() {
|
|
766
|
-
return this.queue.execute(async () => {
|
|
769
|
+
return await this.queue.execute(async () => {
|
|
767
770
|
await this.znp.request(Subsystem.AF, 'interPanCtl', { cmd: 0, data: [] });
|
|
768
771
|
// Give adapter some time to restore, otherwise stuff crashes
|
|
769
772
|
await (0, utils_1.Wait)(3000);
|
|
@@ -771,7 +774,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
771
774
|
});
|
|
772
775
|
}
|
|
773
776
|
async changeChannel(newChannel) {
|
|
774
|
-
return this.queue.execute(async () => {
|
|
777
|
+
return await this.queue.execute(async () => {
|
|
775
778
|
this.checkInterpanLock();
|
|
776
779
|
const payload = {
|
|
777
780
|
dstaddr: 0xffff, // broadcast with sleepy
|
|
@@ -787,7 +790,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
787
790
|
});
|
|
788
791
|
}
|
|
789
792
|
async setTransmitPower(value) {
|
|
790
|
-
return this.queue.execute(async () => {
|
|
793
|
+
return await this.queue.execute(async () => {
|
|
791
794
|
await this.znp.request(Subsystem.SYS, 'stackTune', { operation: 0, value });
|
|
792
795
|
});
|
|
793
796
|
}
|
|
@@ -798,14 +801,12 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
798
801
|
return new Promise((resolve, reject) => {
|
|
799
802
|
startResult.promise
|
|
800
803
|
.then((response) => {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
if (code !== zdo_1.Status.SUCCESS) {
|
|
805
|
-
reject(new Error(`ZDO error: ${command.replace('Rsp', '')} failed with status '${zdo_1.Status[code]}' (${code})`));
|
|
804
|
+
const [status, payload] = response.parseZdoPayload();
|
|
805
|
+
if (status === Zdo.Status.SUCCESS) {
|
|
806
|
+
resolve(payload);
|
|
806
807
|
}
|
|
807
808
|
else {
|
|
808
|
-
|
|
809
|
+
reject(new Zdo.StatusError(status));
|
|
809
810
|
}
|
|
810
811
|
})
|
|
811
812
|
.catch(reject);
|
|
@@ -886,7 +887,7 @@ class ZStackAdapter extends adapter_1.default {
|
|
|
886
887
|
* Retry this command once after a cooling down period.
|
|
887
888
|
*/
|
|
888
889
|
await (0, utils_1.Wait)(2000);
|
|
889
|
-
return this.dataRequestExtended(addressMode, destinationAddressOrGroupID, destinationEndpoint, panID, sourceEndpoint, clusterID, radius, data, timeout, confirmation, attemptsLeft - 1);
|
|
890
|
+
return await this.dataRequestExtended(addressMode, destinationAddressOrGroupID, destinationEndpoint, panID, sourceEndpoint, clusterID, radius, data, timeout, confirmation, attemptsLeft - 1);
|
|
890
891
|
}
|
|
891
892
|
else {
|
|
892
893
|
throw new DataConfirmError(dataConfirm.payload.status);
|