From 09eb767ddfa8dd4322a98b268e38cd728281a34d Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sat, 14 Dec 2024 14:32:19 +0100 Subject: [PATCH] fix: ZStack: fix request network address blocking requests (#1256) --- src/adapter/z-stack/adapter/zStackAdapter.ts | 34 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/adapter/z-stack/adapter/zStackAdapter.ts b/src/adapter/z-stack/adapter/zStackAdapter.ts index 0f8564f704..f174ce2882 100644 --- a/src/adapter/z-stack/adapter/zStackAdapter.ts +++ b/src/adapter/z-stack/adapter/zStackAdapter.ts @@ -250,7 +250,7 @@ class ZStackAdapter extends Adapter { const clusterId = Zdo.ClusterId.NETWORK_ADDRESS_REQUEST; const zdoPayload = Zdo.Buffalo.buildRequest(this.hasZdoMessageOverhead, clusterId, ieeeAddr as EUI64, false, 0); - const result = await this.sendZdo(ieeeAddr, ZSpec.NULL_NODE_ID, clusterId, zdoPayload, false); + const result = await this.sendZdoInternal(ieeeAddr, ZSpec.NULL_NODE_ID, clusterId, zdoPayload, false, true); /* istanbul ignore else */ if (Zdo.Buffalo.checkStatus(result)) { @@ -300,7 +300,34 @@ class ZStackAdapter extends Adapter { payload: Buffer, disableResponse: boolean, ): Promise { - return await this.queue.execute(async () => { + return await this.sendZdoInternal(ieeeAddress, networkAddress, clusterId, payload, disableResponse, false); + } + + private async sendZdoInternal( + ieeeAddress: string, + networkAddress: number, + clusterId: Zdo.ClusterId, + payload: Buffer, + disableResponse: boolean, + skipQueue: boolean, + ): Promise; + private async sendZdoInternal( + ieeeAddress: string, + networkAddress: number, + clusterId: K, + payload: Buffer, + disableResponse: false, + skipQueue: boolean, + ): Promise; + private async sendZdoInternal( + ieeeAddress: string, + networkAddress: number, + clusterId: K, + payload: Buffer, + disableResponse: boolean, + skipQueue: boolean, + ): Promise { + const func = async (): Promise => { this.checkInterpanLock(); // stack-specific requirements @@ -396,7 +423,8 @@ class ZStackAdapter extends Adapter { return response.payload.zdo; } - }, networkAddress); + }; + return skipQueue ? await func() : await this.queue.execute(func, networkAddress); } public async sendZclFrameToEndpoint(