Skip to content

Commit

Permalink
fix: ZStack: fix request network address blocking requests (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk authored Dec 14, 2024
1 parent 018243e commit 09eb767
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/adapter/z-stack/adapter/zStackAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -300,7 +300,34 @@ class ZStackAdapter extends Adapter {
payload: Buffer,
disableResponse: boolean,
): Promise<ZdoTypes.RequestToResponseMap[K] | void> {
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<void>;
private async sendZdoInternal<K extends keyof ZdoTypes.RequestToResponseMap>(
ieeeAddress: string,
networkAddress: number,
clusterId: K,
payload: Buffer,
disableResponse: false,
skipQueue: boolean,
): Promise<ZdoTypes.RequestToResponseMap[K]>;
private async sendZdoInternal<K extends keyof ZdoTypes.RequestToResponseMap>(
ieeeAddress: string,
networkAddress: number,
clusterId: K,
payload: Buffer,
disableResponse: boolean,
skipQueue: boolean,
): Promise<ZdoTypes.RequestToResponseMap[K] | void> {
const func = async (): Promise<ZdoTypes.RequestToResponseMap[K] | void> => {
this.checkInterpanLock();

// stack-specific requirements
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 09eb767

Please sign in to comment.