Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZStack: fix request network address blocking all requests #1256

Merged
merged 6 commits into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to this "internal" function breaks proper typing, since that means it allows awaiting for response even though it shouldn't (doesn't have one for given cluster). The 2 overloads are not used anymore for the "internal" function.

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
Loading