Skip to content

Commit

Permalink
fix: avoid calling assignReturnRoutes with controller as target
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 4, 2023
1 parent 715a0d4 commit 322766f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4175,7 +4175,7 @@ supported CCs: ${
}

// 2. re-create the SUC return route, just in case
node.hasSUCReturnRoute ||= await this.assignSUCReturnRoutes(nodeId);
node.hasSUCReturnRoute = await this.assignSUCReturnRoutes(nodeId);

// 3. delete all return routes to get rid of potential priority return routes
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
Expand All @@ -4199,7 +4199,7 @@ supported CCs: ${
}
}

// 4. Assign return routes to all association destinations.
// 4. Assign return routes to all association destinations...
let associatedNodes: number[] = [];
try {
associatedNodes = distinct(
Expand All @@ -4208,14 +4208,14 @@ supported CCs: ${
(assocs: AssociationAddress[]) =>
assocs.map((a) => a.nodeId),
),
).sort();
)
// ...except the controller itself, which was handled by step 2
.filter((id) => id !== this._ownNodeId!)
.sort();
} catch {
/* ignore */
}
// One of those should probably be the controller. Not sure if the SUC return route is enough.
if (!associatedNodes.includes(this._ownNodeId!)) {
associatedNodes.unshift(this._ownNodeId!);
}

this.driver.controllerLog.logNode(nodeId, {
message: `assigning return routes to the following nodes:
${associatedNodes.join(", ")}`,
Expand Down Expand Up @@ -5244,7 +5244,11 @@ ${associatedNodes.join(", ")}`,
// Except to the controller itself - this route is already known
).filter((id) => id !== this.ownNodeId);
for (const id of destinationNodeIDs) {
await this.assignReturnRoutes(source.nodeId, id);
if (id === this._ownNodeId) {
await this.assignSUCReturnRoutes(source.nodeId);
} else {
await this.assignReturnRoutes(source.nodeId, id);
}
}
}

Expand Down

0 comments on commit 322766f

Please sign in to comment.