SparkplugB MQTT Topic and Payload Definition Library Documentation

Company: | Code5 Automation
Title: | SparkplugB MQTT Topic and Payload Definition
Version: | 1.0.0.0
Categories: | SparkplugB|Sparkplug B MQTT Topic and Payload Definition
Namespace: | SparkplugB
Author: | H-Hermsen and I-Campbell
Placeholder: | Sparkplug B MQTT

Description [1]

Follows the SparkplugB v2.2 Specification

Sparkplug™ provides an open and freely available specification for how Edge of Network (EoN) gateways or native MQTT enabled end devices and MQTT Applications communicate bi-directionally within an MQTT Infrastructure.

Sparkplug™ and the Sparkplug™ logo are trademarks of the Eclipse Foundation Copyright © 10/11/19 Eclipse Foundation, Inc. https://www.eclipse.org/legal/efsl.php

Contents:

  • GlobalTextList (Text List)
  • Library Information
    • GetLibVersion (FUN)
    • GetLibVersionNumber (FUN)
    • IsLibReleased (FUN)
  • Project Information
    • GetBooleanProperty (FUN)
    • GetCompany (FUN)
    • GetNumberProperty (FUN)
    • GetTextProperty (FUN)
    • GetTextProperty2 (FUN)
    • GetTitle (FUN)
    • GetVersion (FUN)
    • GetVersionProperty (FUN)
  • SparkplugB
    • Enums
    • Function Blocks
    • GlobalConstants
    • GlobalVariables
    • Types

Indices and tables

  • File and Project Information
  • Library Reference
[1]
Based on mqttsparkplugb.library, last modified 31.10.2020, 00:51:13. LibDoc 3.5.16.10
The content file mqttsparkplugb.clean.json was generated with CODESYS V3.5 SP16 Patch 2 on 31.10.2020, 01:50:14.


GlobalTextList (Text List)


Library Information

  • GetLibVersion (FUN)
  • GetLibVersionNumber (FUN)
  • IsLibReleased (FUN)


GetLibVersion (FUN)

FUNCTION GetLibVersion : VERSION

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetLibVersion | VERSION


GetLibVersionNumber (FUN)

FUNCTION GetLibVersionNumber : DWORD

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetLibVersionNumber | DWORD


IsLibReleased (FUN)

FUNCTION IsLibReleased : BOOL

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | IsLibReleased | BOOL


Project Information

  • GetBooleanProperty (FUN)
  • GetCompany (FUN)
  • GetNumberProperty (FUN)
  • GetTextProperty (FUN)
  • GetTextProperty2 (FUN)
  • GetTitle (FUN)
  • GetVersion (FUN)
  • GetVersionProperty (FUN)


GetBooleanProperty (FUN)

FUNCTION GetBooleanProperty : BOOL

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetBooleanProperty | BOOL
Input | stKey | WSTRING


GetCompany (FUN)

FUNCTION GetCompany : WSTRING

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetCompany | WSTRING


GetNumberProperty (FUN)

FUNCTION GetNumberProperty : DINT

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetNumberProperty | DINT
Input | stKey | WSTRING


GetTextProperty (FUN)

FUNCTION GetTextProperty : WSTRING

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetTextProperty | WSTRING
Input | stKey | WSTRING


GetTextProperty2 (FUN)

FUNCTION GetTextProperty2 : POINTER TO WSTRING

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetTextProperty2 | POINTER TO WSTRING
Input | stKey | WSTRING


GetTitle (FUN)

FUNCTION GetTitle : WSTRING

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetTitle | WSTRING


GetVersion (FUN)

FUNCTION GetVersion : VERSION

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetVersion | VERSION


GetVersionProperty (FUN)

FUNCTION GetVersionProperty : VERSION

This function has been automatically generated from the project information.

InOut:
Scope | Name | Type
Return | GetVersionProperty | VERSION
Input | stKey | WSTRING


SparkplugB

  • Enums
    • ERROR (ENUM)
    • EoNStateType (ENUM)
    • GetCertState (ENUM)
    • MetricDataType (ENUM)
    • SparkplugSessionStateType (ENUM)
    • SparkplugVerboseType (ENUM)
  • Function Blocks
    • FB_Edge_Of_Network_Node
      • FB_Edge_Of_Network_Node (FB)
        • FB_Edge_Of_Network_Node.FB_Init (METH)
    • SimpleValues
      • FB_SparkplugBoolean (FB)
        • FB_SparkplugBoolean.Name (PROP)
        • FB_SparkplugBoolean.Value (PROP)
      • FB_SparkplugDateTime (FB)
        • FB_SparkplugDateTime.Name (PROP)
        • FB_SparkplugDateTime.Value (PROP)
      • FB_SparkplugDouble (FB)
        • FB_SparkplugDouble.Name (PROP)
        • FB_SparkplugDouble.Value (PROP)
      • FB_SparkplugFloat (FB)
        • FB_SparkplugFloat.Name (PROP)
        • FB_SparkplugFloat.Value (PROP)
      • FB_SparkplugInt16 (FB)
        • FB_SparkplugInt16.Name (PROP)
        • FB_SparkplugInt16.Value (PROP)
      • FB_SparkplugInt32 (FB)
        • FB_SparkplugInt32.Name (PROP)
        • FB_SparkplugInt32.Value (PROP)
      • FB_SparkplugInt64 (FB)
        • FB_SparkplugInt64.Name (PROP)
        • FB_SparkplugInt64.Value (PROP)
      • FB_SparkplugInt8 (FB)
        • FB_SparkplugInt8.Name (PROP)
        • FB_SparkplugInt8.Value (PROP)
      • FB_SparkplugString (FB)
        • FB_SparkplugString.Name (PROP)
        • FB_SparkplugString.Value (PROP)
      • FB_SparkplugText (FB)
        • FB_SparkplugText.Name (PROP)
        • FB_SparkplugText.Value (PROP)
      • FB_SparkplugUInt16 (FB)
        • FB_SparkplugUInt16.Name (PROP)
        • FB_SparkplugUInt16.Value (PROP)
      • FB_SparkplugUInt32 (FB)
        • FB_SparkplugUInt32.Name (PROP)
        • FB_SparkplugUInt32.Value (PROP)
      • FB_SparkplugUInt64 (FB)
        • FB_SparkplugUInt64.Name (PROP)
        • FB_SparkplugUInt64.Value (PROP)
      • FB_SparkplugUInt8 (FB)
        • FB_SparkplugUInt8.Name (PROP)
        • FB_SparkplugUInt8.Value (PROP)
      • FB_SparkplugUUID (FB)
        • FB_SparkplugUUID.Name (PROP)
        • FB_SparkplugUUID.Value (PROP)
    • TLSHelpers
      • AddTrustedCert (FB)
      • GetClientCert (FB)
  • GlobalConstants
    • Constants (GVL)
  • GlobalVariables
    • GVL_sparkplugB (GVL)
  • Types
    • T_DateTime (ALIAS)


Enums

  • ERROR (ENUM)
  • EoNStateType (ENUM)
  • GetCertState (ENUM)
  • MetricDataType (ENUM)
  • SparkplugSessionStateType (ENUM)
  • SparkplugVerboseType (ENUM)


ERROR (ENUM)

TYPE ERROR :

Attributes:
qualified_only
InOut:
Name Comment

NO_ERROR

TIME_OUT

PayloadFound00

 If you get this error, and know what to do with protobufs when you get a 00, let me know

PayloadFoundExtensions

PayloadMetricBusyButMultiCycleNotYetImplemented

PayloadNotEnoughBodyPool

PayloadYouCantDoBothAtOnce

PayloadNotEnoughProtobufBlob

PayloadEncodeVarIntFieldNumberOver15NotImplemented

PayloadEncodeStringFieldNumberOver15NotImplemented

NotImplemented

InvalidReference

PayloadNotEnoughMetricsPool

PayloadNotEnoughKeysPool

PayloadNotEnoughPropertySetValuesPool

PayloadNotEnoughPropertySetsPool

PayloadNotEnoughDataSetColumnsPool

PayloadNotEnoughDataSetTypesPool

PayloadNotEnoughRowsPool

PayloadNotEnoughElementsPool

PayloadNotEnoughParametersPool

PayloadShouldHaveCalledSetValueToPropertySetListEmpty

PayloadDecodeErrorAddingMetrics

PayloadNotACollectionOfStorage

PayloadNotRightSimpleValue

MQTTNoServerConfigured

OhMy_ThatShouldNotHaveHappened


EoNStateType (ENUM)

TYPE EoNStateType :

Enumerates session awareness of the MQTT EoN and the MQTT Server

Attributes:
qualified_only
InOut:
Name Initial Comment

OFFLINE

 0 Correlates with SparkplugSessionStateType.OFFLINE

INIT

 100 Initialises the EoN

CONNECTING

 200 Establishes a MQTT connection to the broker

PUBLISH_NBIRTH

 300 publish NBIRTH,

PUBLISH_DBIRTH

 400 publish DBIRTH

SUBSCRIBE_NCMD

 500 subscribe NCMD,

SUBSCRIBE_DCMD

 600 subscribe DCMD,

ONLINE

 1 Correlates with SparkplugSessionStateType.ONLINE

DISCONNECTING

 700 Disconnection started

DISABLE_PUBLISHER

 800 Disable the Publisher

UNSUBSCRIBE_DCMD

 900 Unsubscribe DCMD

UNSUBSCRIBE_NCMD

 1000 Unsubscribe NCMD

DISCONNECT_MQTT

 1100 Disconnects the MQTT current connection from the broker

EXITING

 1200 De-initialises EoN

ERROR

 2 Entered when an MQTT client error is encountered

RECONNECTING

 1300 Entered after the MQTT client error is reset


GetCertState (ENUM)

TYPE GetCertState :

Attributes:
qualified_only
InOut:
Name Initial

idle

 0

GethStore

 10

CreateCertFilter

 20

RegisterComponent

 30

TryGethCert

 40

CreateCSR

 4010

CreateSelfSigned

 4020

InstallCertFromBase64

 4030

GetCertString

 50

HashCertAndsCert

 60


MetricDataType (ENUM)

TYPE MetricDataType :

Attributes:
qualified_only
InOut:
Name Initial Comment

Unknown

 0

Int8

 1

Int16

 2

Int32

 3

Int64

 4

UInt8

 5

UInt16

 6

UInt32

 7

UInt64

 8

Float

 9

Double

 10

Boolean

 11

String_

 12

DateTime

 13 milliseconds since epoch (Jan 1, 1970) SHOULD be UTC

Text

 14

UUID

 15

DataSet

 16

Bytes

 17

File

 18

Template

 19


SparkplugSessionStateType (ENUM)

TYPE SparkplugSessionStateType :

Attributes:
qualified_only
InOut:
Name Initial

OFFLINE

 0

ONLINE

 1


SparkplugVerboseType (ENUM)

TYPE SparkplugVerboseType :

Enumerates session awareness of the MQTT EoN and the MQTT Server

Attributes:
qualified_only
InOut:
Name Initial Comment

NONE

 0 Logging Disabled

ERR

 1 Errors Only

ERR_WRN

 2 Errors and Warnings

ERR_WRN_INF

 3 Errors, Warnings or Info


Function Blocks

  • FB_Edge_Of_Network_Node
    • FB_Edge_Of_Network_Node (FB)
      • FB_Edge_Of_Network_Node.FB_Init (METH)
  • SimpleValues
    • FB_SparkplugBoolean (FB)
      • FB_SparkplugBoolean.Name (PROP)
      • FB_SparkplugBoolean.Value (PROP)
    • FB_SparkplugDateTime (FB)
      • FB_SparkplugDateTime.Name (PROP)
      • FB_SparkplugDateTime.Value (PROP)
    • FB_SparkplugDouble (FB)
      • FB_SparkplugDouble.Name (PROP)
      • FB_SparkplugDouble.Value (PROP)
    • FB_SparkplugFloat (FB)
      • FB_SparkplugFloat.Name (PROP)
      • FB_SparkplugFloat.Value (PROP)
    • FB_SparkplugInt16 (FB)
      • FB_SparkplugInt16.Name (PROP)
      • FB_SparkplugInt16.Value (PROP)
    • FB_SparkplugInt32 (FB)
      • FB_SparkplugInt32.Name (PROP)
      • FB_SparkplugInt32.Value (PROP)
    • FB_SparkplugInt64 (FB)
      • FB_SparkplugInt64.Name (PROP)
      • FB_SparkplugInt64.Value (PROP)
    • FB_SparkplugInt8 (FB)
      • FB_SparkplugInt8.Name (PROP)
      • FB_SparkplugInt8.Value (PROP)
    • FB_SparkplugString (FB)
      • FB_SparkplugString.Name (PROP)
      • FB_SparkplugString.Value (PROP)
    • FB_SparkplugText (FB)
      • FB_SparkplugText.Name (PROP)
      • FB_SparkplugText.Value (PROP)
    • FB_SparkplugUInt16 (FB)
      • FB_SparkplugUInt16.Name (PROP)
      • FB_SparkplugUInt16.Value (PROP)
    • FB_SparkplugUInt32 (FB)
      • FB_SparkplugUInt32.Name (PROP)
      • FB_SparkplugUInt32.Value (PROP)
    • FB_SparkplugUInt64 (FB)
      • FB_SparkplugUInt64.Name (PROP)
      • FB_SparkplugUInt64.Value (PROP)
    • FB_SparkplugUInt8 (FB)
      • FB_SparkplugUInt8.Name (PROP)
      • FB_SparkplugUInt8.Value (PROP)
    • FB_SparkplugUUID (FB)
      • FB_SparkplugUUID.Name (PROP)
      • FB_SparkplugUUID.Value (PROP)
  • TLSHelpers
    • AddTrustedCert (FB)
    • GetClientCert (FB)


FB_Edge_Of_Network_Node

  • FB_Edge_Of_Network_Node (FB)
    • FB_Edge_Of_Network_Node.FB_Init (METH)


FB_Edge_Of_Network_Node (FB)

FUNCTION_BLOCK PUBLIC FB_Edge_Of_Network_Node

Edge of Network Node Binds together FB_MQTT_PubSub and FB_Sparkplug via a state machine in ST

InOut:
Scope | Name | Type | Initial | Comment
Input | ServerUrl | STRING | eg:’test.mosquitto.org’;
ServerPort | UINT | 1883 | eg: 1883
KeepAlive | UINT | 60 | eg: 60 (Value is in seconds)
CleanSession BOOL FALSE

Persistent Session (FALSE = DEFAULT) The client must get all messages FROM a certain topic, even IF it is offline. You want the broker to queue the messages for the client and deliver them as soon as the client is back online. The client has limited resources. You want the broker to store the subscription information of the client and restore the interrupted communication quickly. The client needs to resume all QoS 1 and 2 publish messages after a reconnect.

Clean session (TRUE) * The client needs only to publish messages to topics, the client does not need to subscribe to topics. * You don’t want the broker to store session information or retry transmission of QoS 1 and 2 messages. * The client does not need to get messages that it misses offline.
Username WSTRING “” specify a username if any (optional)
Password WSTRING “” specify the password for the username (optional)
UseTLS | BOOL | Enables usage of the TLS encryption (optional)
hCert | SysTypes.RTS_IEC_HANDLE | Handle to the client certificate (optional) and only used if UseTLS is TRUE
GroupId | WSTRING | eg: “SparkplugBDevice”
NodeName | WSTRING | eg: “EoN1”
DeviceName | WSTRING | eg: “EmulatedDevice”
publishPeriod | UINT | eg: 5000 (Value is in milliseconds)
Output | ConnectionState | SparkplugSessionStateType
Input | arSparkplugBoolean | POINTER TO FB_SparkplugBoolean
arSparkplugDateTime | POINTER TO FB_SparkplugDateTime
arSparkplugFloat | POINTER TO FB_SparkplugFloat
arSparkplugDouble | POINTER TO FB_SparkplugDouble
arSparkplugInt8 | POINTER TO FB_SparkplugInt8
arSparkplugInt16 | POINTER TO FB_SparkplugInt16
arSparkplugInt32 | POINTER TO FB_SparkplugInt32
arSparkplugInt64 | POINTER TO FB_SparkplugInt64
arSparkplugUInt8 | POINTER TO FB_SparkplugUInt8
arSparkplugUInt16 | POINTER TO FB_SparkplugUInt16
arSparkplugUInt32 | POINTER TO FB_SparkplugUInt32
arSparkplugUInt64 | POINTER TO FB_SparkplugUInt64
arSparkplugUUID | POINTER TO FB_SparkplugUUID
arSparkplugText | POINTER TO FB_SparkplugText
arSparkplugString | POINTER TO FB_SparkplugString
  • FB_Edge_Of_Network_Node.FB_Init (METH)


FB_Edge_Of_Network_Node.FB_Init (METH)

METHOD FB_Init : BOOL

FB_Init is always available implicitly and it is used primarily for initialization. The return value is not evaluated. For a specific influence, you can also declare the methods explicitly and provide additional code there with the standard initialization code. You can evaluate the return value.

InOut:
Scope | Name | Type | Comment
Return | FB_Init | BOOL
Input | bInitRetains | BOOL | TRUE: the retain variables are initialized (reset warm / reset cold)
bInCopyCode | BOOL | TRUE: the instance will be copied to the copy code afterward (online change)


SimpleValues

  • FB_SparkplugBoolean (FB)
    • FB_SparkplugBoolean.Name (PROP)
    • FB_SparkplugBoolean.Value (PROP)
  • FB_SparkplugDateTime (FB)
    • FB_SparkplugDateTime.Name (PROP)
    • FB_SparkplugDateTime.Value (PROP)
  • FB_SparkplugDouble (FB)
    • FB_SparkplugDouble.Name (PROP)
    • FB_SparkplugDouble.Value (PROP)
  • FB_SparkplugFloat (FB)
    • FB_SparkplugFloat.Name (PROP)
    • FB_SparkplugFloat.Value (PROP)
  • FB_SparkplugInt16 (FB)
    • FB_SparkplugInt16.Name (PROP)
    • FB_SparkplugInt16.Value (PROP)
  • FB_SparkplugInt32 (FB)
    • FB_SparkplugInt32.Name (PROP)
    • FB_SparkplugInt32.Value (PROP)
  • FB_SparkplugInt64 (FB)
    • FB_SparkplugInt64.Name (PROP)
    • FB_SparkplugInt64.Value (PROP)
  • FB_SparkplugInt8 (FB)
    • FB_SparkplugInt8.Name (PROP)
    • FB_SparkplugInt8.Value (PROP)
  • FB_SparkplugString (FB)
    • FB_SparkplugString.Name (PROP)
    • FB_SparkplugString.Value (PROP)
  • FB_SparkplugText (FB)
    • FB_SparkplugText.Name (PROP)
    • FB_SparkplugText.Value (PROP)
  • FB_SparkplugUInt16 (FB)
    • FB_SparkplugUInt16.Name (PROP)
    • FB_SparkplugUInt16.Value (PROP)
  • FB_SparkplugUInt32 (FB)
    • FB_SparkplugUInt32.Name (PROP)
    • FB_SparkplugUInt32.Value (PROP)
  • FB_SparkplugUInt64 (FB)
    • FB_SparkplugUInt64.Name (PROP)
    • FB_SparkplugUInt64.Value (PROP)
  • FB_SparkplugUInt8 (FB)
    • FB_SparkplugUInt8.Name (PROP)
    • FB_SparkplugUInt8.Value (PROP)
  • FB_SparkplugUUID (FB)
    • FB_SparkplugUUID.Name (PROP)
    • FB_SparkplugUUID.Value (PROP)


FB_SparkplugBoolean (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugBoolean IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugBoolean.Name (PROP)
  • FB_SparkplugBoolean.Value (PROP)


FB_SparkplugBoolean.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugBoolean.Value (PROP)

PROPERTY Value : BOOL


FB_SparkplugDateTime (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugDateTime IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugDateTime.Name (PROP)
  • FB_SparkplugDateTime.Value (PROP)


FB_SparkplugDateTime.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugDateTime.Value (PROP)

PROPERTY Value : ULINT


FB_SparkplugDouble (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugDouble IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugDouble.Name (PROP)
  • FB_SparkplugDouble.Value (PROP)


FB_SparkplugDouble.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugDouble.Value (PROP)

PROPERTY Value : LREAL


FB_SparkplugFloat (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugFloat IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugFloat.Name (PROP)
  • FB_SparkplugFloat.Value (PROP)


FB_SparkplugFloat.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugFloat.Value (PROP)

PROPERTY Value : REAL


FB_SparkplugInt16 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugInt16 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugInt16.Name (PROP)
  • FB_SparkplugInt16.Value (PROP)


FB_SparkplugInt16.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugInt16.Value (PROP)

PROPERTY Value : INT


FB_SparkplugInt32 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugInt32 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugInt32.Name (PROP)
  • FB_SparkplugInt32.Value (PROP)


FB_SparkplugInt32.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugInt32.Value (PROP)

PROPERTY Value : DINT


FB_SparkplugInt64 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugInt64 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugInt64.Name (PROP)
  • FB_SparkplugInt64.Value (PROP)


FB_SparkplugInt64.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugInt64.Value (PROP)

PROPERTY Value : LINT


FB_SparkplugInt8 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugInt8 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugInt8.Name (PROP)
  • FB_SparkplugInt8.Value (PROP)


FB_SparkplugInt8.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugInt8.Value (PROP)

PROPERTY Value : SINT


FB_SparkplugString (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugString IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugString.Name (PROP)
  • FB_SparkplugString.Value (PROP)


FB_SparkplugString.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugString.Value (PROP)

PROPERTY Value : WSTRING


FB_SparkplugText (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugText IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugText.Name (PROP)
  • FB_SparkplugText.Value (PROP)


FB_SparkplugText.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugText.Value (PROP)

PROPERTY Value : WSTRING


FB_SparkplugUInt16 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugUInt16 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugUInt16.Name (PROP)
  • FB_SparkplugUInt16.Value (PROP)


FB_SparkplugUInt16.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugUInt16.Value (PROP)

PROPERTY Value : UINT


FB_SparkplugUInt32 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugUInt32 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugUInt32.Name (PROP)
  • FB_SparkplugUInt32.Value (PROP)


FB_SparkplugUInt32.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugUInt32.Value (PROP)

PROPERTY Value : UDINT


FB_SparkplugUInt64 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugUInt64 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugUInt64.Name (PROP)
  • FB_SparkplugUInt64.Value (PROP)


FB_SparkplugUInt64.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugUInt64.Value (PROP)

PROPERTY Value : ULINT


FB_SparkplugUInt8 (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugUInt8 IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugUInt8.Name (PROP)
  • FB_SparkplugUInt8.Value (PROP)


FB_SparkplugUInt8.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugUInt8.Value (PROP)

PROPERTY Value : USINT


FB_SparkplugUUID (FB)

FUNCTION_BLOCK PUBLIC FB_SparkplugUUID IMPLEMENTS ISimpleSparkplug

  • FB_SparkplugUUID.Name (PROP)
  • FB_SparkplugUUID.Value (PROP)


FB_SparkplugUUID.Name (PROP)

PROPERTY Name : WSTRING


FB_SparkplugUUID.Value (PROP)

PROPERTY Value : WSTRING


TLSHelpers

  • AddTrustedCert (FB)
  • GetClientCert (FB)


AddTrustedCert (FB)

FUNCTION_BLOCK PUBLIC AddTrustedCert

This might be used to install a Server Certificate to allow you to connect to a TLS server
This might be used to install a CA Root Certificate to allow you to verify a Server Certificate
To use, just pop a trusted certificate in PEM80 BASE64-encoded format to the input sTrustedCert, then set xEnable to true.
You should not have a private key
InOut:
Scope | Name | Type | Comment
Input | xEnable | BOOL | on rising edge, it installs the certificate
sTrustedCert | STRING(2048) | if you want to install a PEM80 BASE64 encoded certificate Should be in the format —–BEGIN CERTIFICATE—– VGhpcyBzaG91bGQgYmUgeW91ciBhY3R1YWwgY2xpZW50IGNlcnRpZmljYXRl —–END CERTIFICATE—–
Output | xDone | BOOL
xError | BOOL


GetClientCert (FB)

FUNCTION_BLOCK PUBLIC GetClientCert

** IF YOUR ENCRYPTION DOES NOT REQUIRE CLIENT CERTIFICATES, DO NOT USE THIS FB, OR DON’T SET xUseCertStore AND USE THE DEFAULT OUTPUT OF hCert.
TIP: if not using client certificates, you may need to run cert-gendhparams from the PLC Shell Tab of the Device Editor **
This funciton block is designed for installing and/or getting the client certificate for a TLS connection
Once the output xProvideCertificate is TRUE, the output hCert can be used as the hCert input to, for example, MQTT.MQTTClient.hCert or MQTT.WebClientNBS.TCP_Client.hCert
See the image GetClientCert_StateMachine for the statemachine
If you want to use the store, there are a few options. For all of them you must:
* Enter the certificate details in sCommonName, sCountry, sOrganization (You must use all of these. If you need a different set, you will have to edit the FB)
* Set xUseCertStore to TRUE
And then you have Options 1 through 4
1. Use already installed certificate (eg. installed through Security Agent, or already previously installed with this FB)
1a. The FB will automatically use the installed certificate that matches sCommonName, sCountry, sOrganization.
2. Create a SelfSigned Certificate and use it
2a. Set xCreateSelfSigned to TRUE
3. Create a CSR and install it using this FB
3a. Set xCreateCSR to TRUE
3b. Copy the text from sCSRorClientCertOut and send to be signed. You might need to remove $N and ‘’ from the copied text
3c. Once singed, copy and paste the text from the PEM80 BASE64-encoded signed certificate to sClientCert
3d. Set xInstallCertFromString to TRUE
4. Create a CSR and install it some other way (eg. through Security Agent)
4a. Set xCreateCSR to TRUE
4b. Copy the text from sCSRorClientCertOut and send to be signed. You might need to remove $N and ‘’ from the copied text
4c. Install the signed certificate to the Own Certificates Store, for example using Security Agent

Tip: Install the Server Certificate to Trusted Certificates using, for example, Security Agent, or the accompanying FB AddTrustedCert
InOut:
Scope | Name | Type | Initial | Comment
Input | xUseCertStore | BOOL | Set to true to work with the cert store.
xCreateSelfSigned | BOOL | on rising edge generate a self signed certificate (and private key)
xCreateCSR | BOOL | on rising edge generate a CSR (and private key)
xInstallCertFromString | BOOL | on rising edge adds the cert from sClientCert to the store. Note that private keys cannot be added this way
sCommonName | STRING | ‘myMQTT’ | adjust to your organization
sCountry | STRING | ‘DE’ | adjust to your country
sOrganization | STRING | ‘actually_this_is_just_an_example’ | adjust to your organization
uliValidity | ULINT | (((((10 * 365) * 24) * 60) * 60) * 1000) | milliseconds the certificate is valid for. default ten years. used for generating self signed
sClientCert | STRING(2048) | ‘—–BEGIN CERTIFICATE—–$NMIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCR0Ix$NFzAVBgNVBAgMDlVuaXRlZCBLaW5nZG9tMQ4wDAYDVQQHDAVEZXJieTESMBAGA1UE$NCgwJTW9zcXVpdHRvMQswCQYDVQQLDAJDQTEWMBQGA1UEAwwNbW9zcXVpdHRvLm9y$NZzEfMB0GCSqGSIb3DQEJARYQcm9nZXJAYXRjaG9vLm9yZzAeFw0yMDA5MjUxOTIw$NMTVaFw0yMDEyMjQxOTIwMTVaMDQxCzAJBgNVBAYTAkRFMRMwEQYDVQQKDAppLWNh$NbXBiZWxsMRAwDgYDVQQDDAdjbGllbnQ1MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A$NMIIBCgKCAQEAw+wYkuhSK8os/6liPDB5+BUqSgCyzmI7xpt0OipM2VrymU/pJIN0$NeOO24AvXNBWo8VHI43JZrA6jUpaJtmH+FPVOUu3xxagbOBJIH/5leKqBYQZfO6D3$N+JFTb+eUJlKqNybzXH0DjnwyqXFUBFyHIn3NIZmKmLrMM4RXcqPHGhJTXXheRw6r$NsUjS5/xNqDvavGjq4fJmxB9YFDoLp6kpJ4wfLBe+46TTaGNt/LixV+oMP/wQxzqi$NK+wy9p+bhwFw09p/S8SqvEe4z/sc4sIXiGLbYTSriz9veUaA4Vv43ggr45qELqpF$NgHpeUfsI9GUDvsX9AVmKcYuSSIerhwU7AQIDAQABoxowGDAJBgNVHRMEAjAAMAsG$NA1UdDwQEAwIF4DANBgkqhkiG9w0BAQsFAAOCAQEAwAQqXEpGpvEWybB/GcQJ6R9l$Ne0Q9yvkHsKosd+IN35bMIIfRxfp/XoWHZJepRVAdZXuS+Ugp2OsV5DiVdTz42wZP$Nvec0M9zrIigtpRZ1O/SsX4WDH/wuc5uD9KSN7/MjhLDAnvyrg4j7v/I2kCH+Eemd$NswuGFhIIuqYjejP/qOPdSAOHzioTW/Lo5+3RAmyTIrfVUDroevrxMTN44oyxmLJ7$N5y+yxlvHelF4L/FWHBgGKhGrMK2RRxZlYS3fKPwCYsMpnjjLbHKnjtOKzaLTXRqP$NT13m9E6OY9oU+X1E7XITCZOragfFlo6LPLZf9MAh8G35WrTwEWpKWLWmqYnbig==$N—–END CERTIFICATE—–$N’ | optional parameter, if you want to install a PEM80 BASE64 encoded client certificate without private key. The private key must already be installed in the cert store, usually by using xCreateCSR —–BEGIN CERTIFICATE—– VGhpcyBzaG91bGQgYmUgeW91ciBhY3R1YWwgY2xpZW50IGNlcnRpZmljYXRl —–END CERTIFICATE—–
Output | xProvideCertificate | BOOL | When TRUE, the hCert is ready to use. Note it may take more than one cycle to reach this state
hCert | SysTypes.RTS_IEC_HANDLE | SysTypes.RTS_INVALID_HANDLE | use this for the input to MQTTClient.hCert. If you don’t need a client cert, you can just use the default value straight away, which is SysTypes.RTS_INVALID_HANDLE
sCSRorClientCertOut | STRING(2048) | Send to your signing authority for signing. eg. Copy this string to test.mosquitto.org/ssl/, replacing any $N with new lines, and removing the opening ‘’


GlobalConstants

  • Constants (GVL)


Constants (GVL)

{attribute ‘conditionalshow’}
{attribute ‘conditionalshow’ := ‘SomeText’}
{attribute ‘hide’}

Attributes:
qualified_only
InOut:
Scope Name Type Initial
Constant

supported_string_lengths

 DINT 80


GlobalVariables

  • GVL_sparkplugB (GVL)


GVL_sparkplugB (GVL)

Attributes:
qualified_only
InOut:
Name Type Initial Comment

VerboseLevel

 SparkplugVerboseType SparkplugVerboseType.ERR_WRN_INF Sets the verboselevel for the devicelog


Types

  • T_DateTime (ALIAS)


T_DateTime (ALIAS)

TYPE T_DateTime :ULINT


File and Project Information

Scope | Name | Type | Content
FileHeader | companyName | string | 3S-Smart Software Solutions GmbH
 | contentFile |  | mqttsparkplugb.clean.json
 | libraryFile |  | mqttsparkplugb.library
 | productProfile |  | CODESYS V3.5 SP16 Patch 2
 | productName |  | CODESYS
 | version | version | 2.0.0.0
 | primaryProject | string | True
 | creationDateTime | date | 31.10.2020, 01:50:14
ProjectInformation | LastModificationDateTime |  | 31.10.2020, 00:51:13
 | Description | string | See: Description
 | DocFormat |  | reStructuredText
 | Author |  | H-Hermsen and I-Campbell
 | AutoResolveUnbound | bool | True
 | LanguageModelAttribute | string | qualified-access-only
 | Company |  | Code5 Automation
 | Placeholder |  | Sparkplug B MQTT
 | SourceLibrary | bool | False
 | Project | string | mqttsparkplugb
 | DefaultNamespace |  | SparkplugB
 | Version | version | 1.0.0.0
 | UnitTestingDefine | string | unittest
 | Title |  | SparkplugB MQTT Topic and Payload Definition
 | Released | bool | False
 | LibraryCategories | library-category-list | SparkplugB|Sparkplug B MQTT Topic and Payload Definition
 | CompiledLibraryCompatibilityVersion | string | CODESYS V3.5 SP16 Patch 1
 | IsEndUserLibrary | bool | False


Library Reference

This is a dictionary of all referenced libraries and their name spaces.

CmpCrypto

Library Identification

Placeholder: CmpCrypto
Default Resolution: CmpCrypto, * (System)
Namespace: CmpCrypto

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: CmpCrypto
  • SystemLibrary: False
  • Optional: False

CmpIecTask

Library Identification

Name: CmpIecTask
Version: 3.5.14.0
Company: System
Namespace: CmpIecTask

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: CmpIecTask, 3.5.14.0 (System)
  • SystemLibrary: False
  • Optional: False

CmpLog

Library Identification

Placeholder: CmpLog
Default Resolution: CmpLog, * (System)
Namespace: CmpLog

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: CmpLog
  • SystemLibrary: False
  • Optional: False

CmpX509Cert

Library Identification

Placeholder: CmpX509Cert
Default Resolution: CmpX509Cert, * (System)
Namespace: CmpX509Cert

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: CmpX509Cert
  • SystemLibrary: False
  • Optional: False

Component Manager

Library Identification

Placeholder: Component Manager
Default Resolution: Component Manager, * (System)
Namespace: Component_Manager

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: Component Manager
  • SystemLibrary: False
  • Optional: False

MQTT Client SL

Library Identification

Placeholder: MQTT_Client_SL
Default Resolution: MQTT Client SL, * (3S - Smart Software Solutions GmbH)
Namespace: MQTT

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: True
  • Key: MQTT_Client_SL
  • SystemLibrary: False
  • Optional: False

Library Parameter

Parameter: G_UIMAXTOPICLEVEL = 10
Parameter: G_UDIMAXPAYLOADSIZE = 4096
Parameter: G_UDIMAXPUBLISHERSANDSUBSCRIBERS = 20
Parameter: G_UDIMAXPACKETSIZE = 6000
Parameter: G_UDIMAXQUEUEDPACKETS = 1000

Memory

Library Identification

Name: Memory
Version: 3.5.7.0
Company: 3S - Smart Software Solutions GmbH
Namespace: Memory

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: Memory, 3.5.7.0 (3S - Smart Software Solutions GmbH)
  • SystemLibrary: False
  • Optional: False

MemoryUtils

Library Identification

Placeholder: MemoryUtils
Default Resolution: MemoryUtils, * (3S - Smart Software Solutions GmbH)
Namespace: MEMUtils

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: True
  • Key: MemoryUtils
  • SystemLibrary: False
  • Optional: False

Standard

Library Identification

Placeholder: Standard
Default Resolution: Standard, * (System)
Namespace: Standard

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: Standard
  • SystemLibrary: False
  • Optional: False

Standard64

Library Identification

Placeholder: Standard64
Default Resolution: Standard64, * (System)
Namespace: Standard64

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: Standard64
  • SystemLibrary: False
  • Optional: False

StringUtils

Library Identification

Placeholder: StringUtils
Default Resolution: StringUtils, * (System)
Namespace: Stu

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: StringUtils
  • SystemLibrary: False
  • Optional: False

SysTimeRtc

Library Identification

Placeholder: SysTimeRtc
Default Resolution: SysTimeRtc, * (System)
Namespace: SysTimeRtc

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: SysTimeRtc
  • SystemLibrary: False
  • Optional: False

SysTypes2 Interfaces

Library Identification

Name: SysTypes2 Interfaces
Version: newest
Company: System
Namespace: SysTypes

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: SysTypes2 Interfaces, * (System)
  • SystemLibrary: False
  • Optional: False

VisuDialogs

Library Identification

Placeholder: VisuDialogs
Default Resolution: VisuDialogs, * (System)
Namespace: VisuDialogs

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: VisuDialogs
  • SystemLibrary: False
  • Optional: False

VisuElem3DPath

Library Identification

Placeholder: System_VisuElem3DPath
Default Resolution: VisuElem3DPath, 3.5.16.0 (System)
Namespace: VisuElem3DPath

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElem3DPath
  • SystemLibrary: True
  • Optional: False

Library Parameter

Parameter: GC_POINTS_PER_POLYGON = 100

VisuElemCamDisplayer

Library Identification

Placeholder: System_VisuElemCamDisplayer
Default Resolution: VisuElemCamDisplayer, 3.5.16.0 (System)
Namespace: VisuElemCamDisplayer

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemCamDisplayer
  • SystemLibrary: True
  • Optional: False

Library Parameter

Parameter: GC_POINTS_PER_CAM = 100

VisuElemMeter

Library Identification

Placeholder: System_VisuElemMeter
Default Resolution: VisuElemMeter, 3.5.16.0 (System)
Namespace: VisuElemMeter

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemMeter
  • SystemLibrary: True
  • Optional: False

VisuElemTextEditor

Library Identification

Placeholder: System_VisuElemTextEditor
Default Resolution: VisuElemTextEditor, 3.5.16.0 (System)
Namespace: VisuElemTextEditor

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemTextEditor
  • SystemLibrary: True
  • Optional: False

VisuElemTrace

Library Identification

Placeholder: System_VisuElemTrace
Default Resolution: VisuElemTrace, 3.5.16.0 (System)
Namespace: VisuElemTrace

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemTrace
  • SystemLibrary: True
  • Optional: False

VisuElemXYChart

Library Identification

Placeholder: System_VisuElemXYChart
Default Resolution: VisuElemXYChart, 3.5.16.0 (System)
Namespace: VisuElemXYChart

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemXYChart
  • SystemLibrary: True
  • Optional: False

VisuElems

Library Identification

Placeholder: System_VisuElems
Default Resolution: VisuElems, * (System)
Namespace: VisuElems

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElems
  • SystemLibrary: True
  • Optional: False

VisuElemsAlarm

Library Identification

Placeholder: System_VisuElemsAlarm
Default Resolution: VisuElemsAlarm, 3.5.16.0 (System)
Namespace: VisuElemsAlarm

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemsAlarm
  • SystemLibrary: True
  • Optional: False

VisuElemsDateTime

Library Identification

Placeholder: System_VisuElemsDateTime
Default Resolution: VisuElemsDateTime, 3.5.16.0 (System)
Namespace: VisuElemsDateTime

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemsDateTime
  • SystemLibrary: True
  • Optional: False

VisuElemsSpecialControls

Library Identification

Placeholder: System_VisuElemsSpecialControls
Default Resolution: VisuElemsSpecialControls, 3.5.16.0 (System)
Namespace: VisuElemsSpecialControls

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemsSpecialControls
  • SystemLibrary: True
  • Optional: False

VisuElemsWinControls

Library Identification

Placeholder: System_VisuElemsWinControls
Default Resolution: VisuElemsWinControls, 3.5.16.0 (System)
Namespace: VisuElemsWinControls

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuElemsWinControls
  • SystemLibrary: True
  • Optional: False

VisuInputs

Library Identification

Placeholder: system_visuinputs
Default Resolution: VisuInputs, 3.5.16.0 (System)
Namespace: visuinputs

Library Properties

  • LinkAllContent: False
  • Optional: False
  • QualifiedOnly: False
  • Key: system_visuinputs
  • SystemLibrary: True
  • PublishSymbolsInContainer: True

VisuNativeControl

Library Identification

Placeholder: System_VisuNativeControl
Default Resolution: VisuNativeControl, 3.5.16.0 (System)
Namespace: VisuNativeControl

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: False
  • Key: System_VisuNativeControl
  • SystemLibrary: True
  • Optional: False

VisuSymbols

Library Identification

Name: VisuSymbols
Version: 3.5.10.0
Company: System
Namespace: VisuSymbols

Library Properties

  • LinkAllContent: False
  • QualifiedOnly: True
  • Key: VisuSymbols, 3.5.10.0 (System)
  • SystemLibrary: False
  • Optional: False