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

Fix unhandled error on sendZclFrameToEndpointInternal. #1218

Merged
merged 1 commit into from
Oct 21, 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
47 changes: 30 additions & 17 deletions src/adapter/zboss/adapter/zbossAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export class ZBOSSAdapter extends Adapter {
let response = null;
const command = zclFrame.command;
if (command.response && disableResponse === false) {
response = this.waitFor(
response = this.waitForInternal(
networkAddress,
endpoint,
zclFrame.header.transactionSequenceNumber,
Expand All @@ -363,7 +363,7 @@ export class ZBOSSAdapter extends Adapter {
timeout,
);
} else if (!zclFrame.header.frameControl.disableDefaultResponse) {
response = this.waitFor(
response = this.waitForInternal(
networkAddress,
endpoint,
zclFrame.header.transactionSequenceNumber,
Expand Down Expand Up @@ -470,28 +470,41 @@ export class ZBOSSAdapter extends Adapter {
return;
}

public waitFor(
private waitForInternal(
networkAddress: number,
endpoint: number,
// frameType: Zcl.FrameType,
// direction: Zcl.Direction,
transactionSequenceNumber: number,
transactionSequenceNumber: number | undefined,
clusterID: number,
commandIdentifier: number,
timeout: number,
): {promise: Promise<ZclPayload>; cancel: () => void; start: () => {promise: Promise<ZclPayload>}} {
const payload = {
address: networkAddress,
endpoint,
clusterID,
commandIdentifier,
transactionSequenceNumber,
};

const waiter = this.waitress.waitFor(payload, timeout);
): {start: () => {promise: Promise<ZclPayload>}; cancel: () => void} {
const waiter = this.waitress.waitFor(
{
address: networkAddress,
endpoint,
clusterID,
commandIdentifier,
transactionSequenceNumber,
},
timeout,
);
const cancel = (): void => this.waitress.remove(waiter.ID);
return {start: waiter.start, cancel};
}

public waitFor(
networkAddress: number,
endpoint: number,
frameType: Zcl.FrameType,
direction: Zcl.Direction,
transactionSequenceNumber: number | undefined,
clusterID: number,
commandIdentifier: number,
timeout: number,
): {promise: Promise<ZclPayload>; cancel: () => void} {
const waiter = this.waitForInternal(networkAddress, endpoint, transactionSequenceNumber, clusterID, commandIdentifier, timeout);

return {cancel: cancel, promise: waiter.start().promise, start: waiter.start};
return {cancel: waiter.cancel, promise: waiter.start().promise};
}

private waitressTimeoutFormatter(matcher: WaitressMatcher, timeout: number): string {
Expand Down