diff --git a/src/SparkplugNet/Core/Node/SparkplugNodeBase.cs b/src/SparkplugNet/Core/Node/SparkplugNodeBase.cs index 27df22d..5b50c56 100644 --- a/src/SparkplugNet/Core/Node/SparkplugNodeBase.cs +++ b/src/SparkplugNet/Core/Node/SparkplugNodeBase.cs @@ -86,7 +86,12 @@ public async Task Start(SparkplugNodeOptions nodeOptions, KnownMetricStorage? kn // Connect, subscribe to incoming messages and send a state message. await this.ConnectInternal(); await this.SubscribeInternal(); - await this.PublishNodeAndDeviceBirthsInternal(); + + // When a primary host is defined, wait before sending NBIRTH and DBIRTH + if (string.IsNullOrEmpty(this.Options.ScadaHostIdentifier)) + { + await this.PublishNodeAndDeviceBirthsInternal(); + } } /// @@ -124,14 +129,11 @@ public async Task PublishMetrics(IEnumerable metrics } /// - /// Does a node rebirth. + /// Does a node birth. /// /// The new metrics. - public async Task Rebirth(IEnumerable metrics) + public async Task Birth(IEnumerable metrics) { - // Send node death first. - await this.SendNodeDeathMessage(); - // Reset the known metrics. this.knownMetrics = new KnownMetricStorage(metrics); @@ -139,6 +141,18 @@ public async Task Rebirth(IEnumerable metrics) await this.PublishNodeAndDeviceBirthsInternal(); } + /// + /// Does a node rebirth. + /// + /// The new metrics. + public async Task Rebirth(IEnumerable metrics) + { + // Send node death first. + await this.SendNodeDeathMessage(); + + await this.Birth(metrics); + } + /// /// Publishes metrics for a node. ///