From ffb93df4714dbaf5ad74edd7fbf3542f14fae0df Mon Sep 17 00:00:00 2001 From: asgothian <45667167+asgothian@users.noreply.github.com> Date: Sat, 2 Nov 2024 23:29:21 +0100 Subject: [PATCH 1/2] Update zigbeecontroller.js Fix channel scan --- lib/zigbeecontroller.js | 61 ++++++++--------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/lib/zigbeecontroller.js b/lib/zigbeecontroller.js index 3020a144..710c2c74 100644 --- a/lib/zigbeecontroller.js +++ b/lib/zigbeecontroller.js @@ -1007,63 +1007,24 @@ class ZigbeeController extends EventEmitter { } async getChannelsEnergy() { - /* - const BLANK_EUI64 = "0xFFFFFFFFFFFFFFFF"; - const SLEEPY = 0xffff; - let clusterId = ZDO.ClusterId.NWK_UPDATE_REQUEST; - - //for (let i=26;i>0;i--) - { + const result = {}; try { - let result = {}; - let payload = ZDO.Buffalo.buildRequest(false, clusterId, [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26], 0x05, undefined, 0, undefined); - this.warn(`Payload is [${JSON.stringify(payload)}]`); - result = await this.herdsman.adapter.sendZdo(0x0, 0x0, clusterId , payload, false); - this.warn(`result is ${JSON.stringify(result)}`) - //await this.Wait(5000); - - //let payload1 = ZDO.Buffalo.buildRequest(true, clusterId, [16,17,18,19,20], 0x5, undefined, 0, undefined); - //result = await this.herdsman.adapter.sendZdo(0x0, 0x0, clusterId , payload1, false); - //this.warn(`result 2 is ${JSON.stringify(result)}`) - //await this.Wait(5000); - - - //let payload2 = ZDO.Buffalo.buildRequest(true, clusterId, [21,22,23,24,25], 0x5, undefined, 0, undefined); - //result = await this.herdsman.adapter.sendZdo(0x0, 0x0, clusterId , payload2, false); - //this.warn(`result 3 is ${JSON.stringify(result)}`) - /* const payload = { - dstaddr: 0x0, - dstaddrmode: 0x02, - channelmask: 0x07FFF800, - scanduration: 0x5, - scancount: 1, - nwkmanageraddr: 0x0000 - }; - const energyScan = this.herdsman.adapter.znp.waitFor( - 2, // unpi_1.Constants.Type.AREQ, - 5, // Subsystem.ZDO, - 'mgmtNwkUpdateNotify' - ); - await this.herdsman.adapter.znp.request( - 0x5, // Subsystem.ZDO - 'mgmtNwkUpdateReq', - payload, - energyScan.ID - ); - const result = await energyScan.start().promise; - - - //return result.payload; - } + let payload = ZDO.Buffalo.buildRequest(false, clusterId, [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26], 0x05, 1, 0, undefined); + const scanresult = await this.herdsman.adapter.sendZdo(0x0, 0x0, clusterId , payload, false); + this.debug(`scanresult is ${JSON.stringify(scanresult)}`) + result.energyvalues = scanresult[1].entryList; + this.debug(`result is ${JSON.stringify(result)}`) + } catch (error) { this.sendError(error); - this.error(`Failed to touchlinkReset ${error.stack}`); + this.error(`Failed to scan channels ${error.stack}`); + result.error = error; } - } - */ + return result; + } } From 20998566f2612c37f0afdf2b61ec8493b0bc4865 Mon Sep 17 00:00:00 2001 From: asgothian <45667167+asgothian@users.noreply.github.com> Date: Sat, 2 Nov 2024 23:33:41 +0100 Subject: [PATCH 2/2] Update admin.js --- admin/admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/admin.js b/admin/admin.js index d1d666bd..0ff0c4bd 100644 --- a/admin/admin.js +++ b/admin/admin.js @@ -2552,7 +2552,7 @@ function showChannels() { } } }); - showWaitingDialog('Scanning channels - not working yet', 10); + showWaitingDialog('Scanning channels', 10); } function onlyOne(devs) {