Skip to content

Commit

Permalink
fix(ignore): Allow to disable assoc get
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Feb 2, 2024
1 parent 5bb789a commit 5c242c8
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/adapter/z-stack/adapter/zStackAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,16 @@ class ZStackAdapter extends Adapter {
let doAssocRemove = false;
if (!assocRemove && dataConfirmResult === ZnpCommandStatus.MAC_TRANSACTION_EXPIRED &&
dataRequestAttempt >= 1 && this.supportsAssocRemove()) {
const match = await this.znp.request(
Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress}
);

if (match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation !== 255) {
doAssocRemove = true;
assocRestore =
{ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation};
if (!process.env['DISABLE_ASSOC_GET']) {
const match = await this.znp.request(
Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress}
);

if (match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation !== 255) {
doAssocRemove = true;
assocRestore =
{ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation};
}
}

assocRemove = true;
Expand Down Expand Up @@ -504,20 +506,23 @@ class ZStackAdapter extends Adapter {
// No response could be because the radio of the end device is turned off:
// Sometimes the coordinator does not properly set the PENDING flag.
// Try to rewrite the device entry in the association table, this fixes it sometimes.
const match = await this.znp.request(
Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress}
);
debug(`Response timeout recovery: Node relation ${
match.payload.noderelation} (${ieeeAddr} / ${match.payload.nwkaddr})`);
if (this.supportsAssocAdd() && this.supportsAssocRemove() &&
match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation == 1
) {
debug(`Response timeout recovery: Rewrite association table entry (${ieeeAddr})`);
await this.znp.request(Subsystem.UTIL, 'assocRemove', {ieeeadr: ieeeAddr});
await this.znp.request(Subsystem.UTIL, 'assocAdd',
{ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation}
if (!process.env['DISABLE_ASSOC_GET']) {
const match = await this.znp.request(
Subsystem.UTIL, 'assocGetWithAddress',{extaddr: ieeeAddr, nwkaddr: networkAddress}
);
debug(`Response timeout recovery: Node relation ${
match.payload.noderelation} (${ieeeAddr} / ${match.payload.nwkaddr})`);
if (this.supportsAssocAdd() && this.supportsAssocRemove() &&
match.payload.nwkaddr !== 0xFFFE && match.payload.noderelation == 1
) {
debug(`Response timeout recovery: Rewrite association table entry (${ieeeAddr})`);
await this.znp.request(Subsystem.UTIL, 'assocRemove', {ieeeadr: ieeeAddr});
await this.znp.request(Subsystem.UTIL, 'assocAdd',
{ieeeadr: ieeeAddr, nwkaddr: networkAddress, noderelation: match.payload.noderelation}
);
}
}

// No response could be of invalid route, e.g. when message is send to wrong parent of end device.
await this.discoverRoute(networkAddress);
return this.sendZclFrameToEndpointInternal(
Expand Down

0 comments on commit 5c242c8

Please sign in to comment.