diff --git a/src/commands/handlers.js b/src/commands/handlers.js index 5391b11..cf7781e 100644 --- a/src/commands/handlers.js +++ b/src/commands/handlers.js @@ -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); +}; diff --git a/src/commands/index.js b/src/commands/index.js index 6e264eb..3fdea33 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -44,4 +44,10 @@ module.exports = [ payloadSchema: { type: 'any' }, handler: handlers.setModelPrediction, }, + { + topic: 'child.register', + aliases: ['registerChild'], + payloadSchema: { type: 'string' }, + handler: handlers.childRegister, + }, ];