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

[ember] Fixed OTA response matching. #928

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions src/adapter/ember/adapter/emberAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ import {
GP_ENDPOINT,
EMBER_ALL_802_15_4_CHANNELS_MASK,
ZIGBEE_PROFILE_INTEROPERABILITY_LINK_KEY,
HA_PROFILE_ID,
} from "../consts";
import {EmberRequestQueue} from "./requestQueue";
import {FIXED_ENDPOINTS} from "./endpoints";
Expand Down Expand Up @@ -2995,19 +2994,21 @@ export class EmberAdapter extends Adapter {
/** WARNING: Adapter impl. Starts timer immediately upon returning */
public waitFor(networkAddress: number, endpoint: number, frameType: FrameType, direction: Direction, transactionSequenceNumber: number,
clusterID: number, commandIdentifier: number, timeout: number): {promise: Promise<ZclDataPayload>; cancel: () => void;} {
const sourceEndpointInfo = FIXED_ENDPOINTS[0];
const waiter = this.oneWaitress.waitFor<ZclDataPayload>({
target: networkAddress,
apsFrame: {
clusterId: clusterID,
profileId: HA_PROFILE_ID,// XXX: ok? only used by OTA upstream
profileId: sourceEndpointInfo.profileId,// XXX: only used by OTA upstream
sequence: 0,// set by stack
sourceEndpoint: endpoint,
destinationEndpoint: 0,
sourceEndpoint: sourceEndpointInfo.endpoint,
destinationEndpoint: endpoint,
groupId: 0,
options: EmberApsOption.NONE,
},
zclSequence: transactionSequenceNumber,
}, timeout || DEFAULT_ZCL_REQUEST_TIMEOUT * 3);// XXX: since this is used by OTA..?
commandIdentifier,
}, timeout || DEFAULT_ZCL_REQUEST_TIMEOUT * 3);// XXX: since this is used by OTA...

return {
cancel: (): void => this.oneWaitress.remove(waiter.id),
Expand Down Expand Up @@ -3652,6 +3653,7 @@ export class EmberAdapter extends Adapter {
target: networkAddress,
apsFrame,
zclSequence: zclFrame.Header.transactionSequenceNumber,
commandIdentifier: commandResponseId,
}, timeout || DEFAULT_ZCL_REQUEST_TIMEOUT));

resolve(result);
Expand Down Expand Up @@ -3903,6 +3905,7 @@ export class EmberAdapter extends Adapter {
target: null,
apsFrame: apsFrame,
zclSequence: zclFrame.Header.transactionSequenceNumber,
commandIdentifier: command.response,
}, timeout || DEFAULT_ZCL_REQUEST_TIMEOUT * 2));// XXX: touchlink timeout?

resolve(result);
Expand Down
8 changes: 6 additions & 2 deletions src/adapter/ember/adapter/oneWaitress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ type OneWaitressMatcher = {
*/
target?: EmberNodeId,
apsFrame: EmberApsFrame,
/** Cluster ID for when the response doesn't match the request. Takes priority over apsFrame.clusterId. */
/** Cluster ID for when the response doesn't match the request. Takes priority over apsFrame.clusterId. Should be mostly for ZDO requests. */
responseClusterId?: number,
zclSequence?: number;
/** ZCL frame transaction sequence number */
zclSequence?: number,
/** Expected command ID for ZCL commands */
commandIdentifier?: number,
};

type OneWaitressEventMatcher = {
Expand Down Expand Up @@ -142,6 +145,7 @@ export class EmberOneWaitress {
// no target in touchlink, also no APS sequence, but use the ZCL one instead
if (((waiter.matcher.apsFrame.profileId === TOUCHLINK_PROFILE_ID) || (payload.address === waiter.matcher.target))
&& (!waiter.matcher.zclSequence || (payload.frame.Header.transactionSequenceNumber === waiter.matcher.zclSequence))
&& (!waiter.matcher.commandIdentifier || (payload.frame.Header.commandIdentifier === waiter.matcher.commandIdentifier))
&& (payload.frame.Cluster.ID === waiter.matcher.apsFrame.clusterId)
&& (payload.endpoint === waiter.matcher.apsFrame.destinationEndpoint)) {
clearTimeout(waiter.timer);
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/ember/ezsp/ezsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4554,7 +4554,7 @@ export class Ezsp extends EventEmitter {
break;
}
default: {
console.log(`<=== [ZDO clusterId=${apsFrame.clusterId}] Support not implemented`);
console.log(`<=== [ZDO clusterId=${apsFrame.clusterId}] Support not implemented upstream.`);
break;
}
}
Expand Down