fix(commands): restore child.register handler (alias registerChild)

The P6.3 refactor dropped the case 'registerChild' branch from the
nodeClass switch. Restored as a canonical child.register descriptor
with the legacy registerChild alias.

Monster accepts measurement children — without this, inbound Port 2
handshakes from a child were silently ignored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-05-11 16:04:29 +02:00
parent 2a82b7d7dc
commit 2aa7f88f03
2 changed files with 18 additions and 0 deletions

View File

@@ -40,3 +40,15 @@ exports.setMode = (source, msg) => {
exports.setModelPrediction = (source, msg) => {
if (typeof source.setModelPrediction === 'function') source.setModelPrediction(msg.payload);
};
// Inbound child registration from a measurement (or other) child node.
// Ported from the legacy `case 'registerChild'` branch in nodeClass.
exports.childRegister = (source, msg, ctx) => {
const childId = msg.payload;
const childObj = ctx?.RED?.nodes?.getNode?.(childId);
if (!childObj?.source) {
(ctx?.logger || source.logger)?.warn?.(`child.register skipped: missing child/source for id=${childId}`);
return;
}
source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent, msg.distance);
};

View File

@@ -44,4 +44,10 @@ module.exports = [
payloadSchema: { type: 'any' },
handler: handlers.setModelPrediction,
},
{
topic: 'child.register',
aliases: ['registerChild'],
payloadSchema: { type: 'string' },
handler: handlers.childRegister,
},
];