'Sparkplug B and BIRTH topics
I am working on a Sparkplug B SCADA Host, and hoping to understand how the Sparkplug B SCADA Host keeps up-to-date with the Sparkplug B EoN Nodes and Devices that it is interested in. What I'm concerned with here is the metadata of EoN Nodes and Devices, as described by their NBIRTH and DBIRTH topics.
The scenario is:
Initially, an EoN Node has come online, and published its NBIRTH topic. The SCADA Host is offline, so it doesn’t see the NBIRTH.
The SCADA Host comes online. It has no knowledge of the the metrics on the EoN Node.
I haven't seen anything in the Sparkplug B specification that suggests how the SCADA Host can get the EoN Node to send its NBIRTH topic again. There is the Rebirth metric, which will request the BIRTH topic to be republished, but I am not sure that this is something that all implementations of Sparkplug B support.
It has been suggested to me that when the SCADA Host comes online it will publish a STATE topic to indicate that this has happened, and that the EoN Node will see this and Node publish its NBIRTH topic again. However, I don't see this behaviour mentioned in the Sparkplug B specification.
Solution 1:[1]
This is a really long topic.
First, there is a NBIRTH record. It has two counters, the bdseq and seq counters. The bdseq is a "random" number picked before each MQTT connect. It is included in the "Last Will and Testament" record as well, so when an MQTT disconnect happens, a NDEATH record will be generated and the bdseq can be correlated and only listened to if they match.
Next, the NBIRTH record starts a second 'seq' which is an unsigned byte and set it to 0.
On receiving an NDATA record, you need to first check that the bdseq matches your most recent NBIRTH value, and then check that the sequence is one greater that the last message received. If not, the message is out of sequence and it is time to issue a node control rebirth command.
You really need to delve into the specification to get the full details.
Solution 2:[2]
The primary application (what you call SCADA host) sends a NCMD message to tell the EON to republish its NBIRTH and DBIRTH(s), as detailed at https://www.eclipse.org/tahu/spec/Sparkplug%20Topic%20Namespace%20and%20State%20ManagementV2.2-with%20appendix%20B%20format%20-%20Eclipse.pdf page 66 section 17.5 . More details may be hidden elsewhere in that spec. You can test all this with a client, eg. our free Sparkplug lab https://mqttlab.iotsim.io/sparkplug
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | RobinMHolt |
Solution 2 | Gambit Support |