SparkplugNet icon indicating copy to clipboard operation
SparkplugNet copied to clipboard

SparkPlugB 3.0 Specification primary host STATE message Payload and Topic

Open shouidar opened this issue 1 year ago • 5 comments

Just wanted to share some of my findings while trying to implement a Primary Host compliant with 3.0 Specification:

  1. In the current version of the code The payload returned by GetSparkPlugStateMessage defaults to UtcNow, while in the 3.0 Specification, The application may need to send different timestamp in the State message mainly when republishing the Primary Host BIRTH message:
private static string GetSparkplugStateMessage(bool online)
    {
        return JsonSerializer.Serialize(new StateMessage
        {
            Online = online,
            Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
        });
    }
  1. The sparkPlugB topic for the WILL/DEATH/BIRTH state message should be spBv1.0/STATE/Host_Id instead of STATE/Host_Id
  2. Should the current version of the library maintain backward compatibility with previous SparkPlug B specification (1.2.1 and below) as an option?

shouidar avatar Feb 10 '24 11:02 shouidar

  1. I need to check this.
  2. Ok, need to check this as well.
  3. I honestly would avoid this unless someone really needs it...

SeppPenner avatar Feb 10 '24 15:02 SeppPenner

For (3) I actually meant Spec version 2.2 and below. The current implementation of GetSparkplugStateMessageB returns the STATE payload in JSON format as specified in 3.0. This breaks compatibility with 2.2 and below which uses UTF8 string "ONLINE" or "OFLINE" for STATE message in addition the state topics being different.

shouidar avatar Feb 10 '24 17:02 shouidar

For (3) I actually meant Spec version 2.2 and below. The current implementation of GetSparkplugStateMessageB returns the STATE payload in JSON format as specified in 3.0. This breaks compatibility with 2.2 and below which uses UTF8 string "ONLINE" or "OFLINE" for STATE message in addition the state topics being different.

I will include this soon. Seems like a legit thing to do so. Especially, as it's not a big thing as only the state message has changed (For now).

SeppPenner avatar Feb 13 '24 08:02 SeppPenner

Issue 3 is done, 1 and 2 need still to be checked.

SeppPenner avatar Feb 20 '24 07:02 SeppPenner

2 and 3 are done, need to check 1.

SeppPenner avatar Feb 23 '24 09:02 SeppPenner