Skip to content

Commit

Permalink
Fix unhandled error on sendZclFrameToEndpointInternal in case of requ…
Browse files Browse the repository at this point in the history
…est execute time more than timeout.
  • Loading branch information
andryblack committed Oct 19, 2024
1 parent 425e58e commit 3e3a358
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 3e3a358

Please sign in to comment.