thomassorensen2650 / node-red-contrib-mqtt-sparkplug-plus

A node that makes it simple to implement MQTT Sparkplug in Node-Red
21 stars 6 forks source link

bdSeq missing for NDEATH message #22

Closed nordfonn closed 1 year ago

nordfonn commented 1 year ago

It seems like the NDEATH message coming from the node does not include a bdSeq number (whereas NBIRTH does). This is making it hard to relate the NDEATH to the corresponding NBIRTH, as required by the Sparkplug B v 3.0.0 standard:

• [tck-id-payloads-ndeath-bdseq] The NDEATH message MUST include the same bdSeq number value that will be used in the associated NBIRTH message

The bdSeq number is used to correlate an NBIRTH with a NDEATH. Because the NDEATH is included in the MQTT CONNECT packet, its timestamp (if included) is not useful to Sparkplug Host Applications. Instead, a bdSeq number must be included as a metric in the payload of the NDEATH. The same bdSeq number metric value must also be included in the NBIRTH message published immediately after the MQTT CONNECT. This allows Host Applications to know that a NDEATH matches a specific NBIRTH message. This is required because timing with Will Messages may result in NDEATH messages arriving after a new/next NBIRTH message. The bdSeq number allows Host Applications to know when it must consider the Edge Node offline.

Here's how the messages look at the SCADA end:

2023-04-18T07:27:55.087722 spBv1.0/[group_name]/NBIRTH/[eon_name] {'timestamp': '1681802847025', 'metrics': [{'name': 'Node Control/Rebirth', 'datatype': 11, 'booleanValue': False, 'value': False}, {'name': 'bdSeq', 'datatype': 1, 'intValue': 0, 'value': 0}], 'seq': '0'}

2023-04-18T07:28:02.729686 spBv1.0/[group_name]/NDEATH/[eon_name] {'timestamp': '1681802846724'}

thomassorensen2650 commented 1 year ago

I have fixed the issue (and a few other issues related to bdSeq). I will see if I can release then update this weekend or early next week.

thomassorensen2650 commented 1 year ago

fixed in V1.4.1.