Skip to content

Commit

Permalink
fix: ZBOSS: Fix unhandled error on sendZclFrameToEndpointInternal in …
Browse files Browse the repository at this point in the history
…case of request execute time more than timeout. (#1218)
  • Loading branch information
andryblack authored Oct 21, 2024
1 parent 5f11842 commit 346b3be
Showing 1 changed file with 30 additions and 17 deletions.
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

0 comments on commit 346b3be

Please sign in to comment.