From 4ed739bc1a45d58207607feeb06fb1f3d530a1e5 Mon Sep 17 00:00:00 2001 From: koenkk Date: Sun, 25 Feb 2024 14:41:50 +0100 Subject: [PATCH] fix(ignore): Remove DISABLE_ASSOC_GET --- src/adapter/z-stack/adapter/zStackAdapter.ts | 47 +++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/adapter/z-stack/adapter/zStackAdapter.ts b/src/adapter/z-stack/adapter/zStackAdapter.ts index f3161aaf82..ebe14e0b0c 100644 --- a/src/adapter/z-stack/adapter/zStackAdapter.ts +++ b/src/adapter/z-stack/adapter/zStackAdapter.ts @@ -437,17 +437,14 @@ class ZStackAdapter extends Adapter { let doAssocRemove = false; if (!assocRemove && dataConfirmResult === ZnpCommandStatus.MAC_TRANSACTION_EXPIRED && dataRequestAttempt >= 1 && this.supportsAssocRemove()) { - /* istanbul ignore else */ - if (!process.env['DISABLE_ASSOC_GET']) { - const match = await this.znp.request( - Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress} - ); - - if (match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation !== 255) { - doAssocRemove = true; - assocRestore = - {ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation}; - } + const match = await this.znp.request( + Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress} + ); + + if (match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation !== 255) { + doAssocRemove = true; + assocRestore = + {ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation}; } assocRemove = true; @@ -507,24 +504,20 @@ class ZStackAdapter extends Adapter { // No response could be because the radio of the end device is turned off: // Sometimes the coordinator does not properly set the PENDING flag. // Try to rewrite the device entry in the association table, this fixes it sometimes. - /* istanbul ignore else */ - if (!process.env['DISABLE_ASSOC_GET']) { - const match = await this.znp.request( - Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress} + const match = await this.znp.request( + Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress} + ); + debug(`Response timeout recovery: Node relation ${ + match.payload.noderelation} (${ieeeAddr} / ${match.payload.nwkaddr})`); + if (this.supportsAssocAdd() && this.supportsAssocRemove() && + match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation == 1 + ) { + debug(`Response timeout recovery: Rewrite association table entry (${ieeeAddr})`); + await this.znp.request(Subsystem.UTIL, 'assocRemove', {ieeeadr: ieeeAddr}); + await this.znp.request(Subsystem.UTIL, 'assocAdd', + {ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation} ); - debug(`Response timeout recovery: Node relation ${ - match.payload.noderelation} (${ieeeAddr} / ${match.payload.nwkaddr})`); - if (this.supportsAssocAdd() && this.supportsAssocRemove() && - match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation == 1 - ) { - debug(`Response timeout recovery: Rewrite association table entry (${ieeeAddr})`); - await this.znp.request(Subsystem.UTIL, 'assocRemove', {ieeeadr: ieeeAddr}); - await this.znp.request(Subsystem.UTIL, 'assocAdd', - {ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation} - ); - } } - // No response could be of invalid route, e.g. when message is send to wrong parent of end device. await this.discoverRoute(networkAddress); return this.sendZclFrameToEndpointInternal(