FB_IotMqtt5PublishProperties

The function block allows the definition of various properties that can be set when sending a message. This allows additional metadata to be attached to a message during transmission. The following metadata can be defined:
General description of the Publish Properties:
Property | Description |
---|---|
Content Type | Can be used by applications to convey a content description of the payload. |
Topic Alias | A Topic Alias can be used to represent a topic e.g. by an integer value instead of a (potentially long) string. |
Subscription Identifier | An ID to be able to identify a subscription. |
Message Expiry Interval | Specifies the lifetime of a message until it can be discarded by the message broker. |
Payload UTF-8 Indicator | Indicates whether the transmitted message is in UTF-8 format. |
User Properties | User Properties are key/value pairs that can be attached to the PublishProperties. This is done by means of the function block FB_IotMqtt5UserProperties. The meaning of the UserProperties is not part of the MQTT5 specification and therefore application specific. |
Syntax
Definition:
FUNCTION_BLOCK FB_IotMqtt5PublishProperties EXTENDS FB_IotMqtt5UserProperties
VAR_OUTPUT
bError : BOOL;
hrErrorCode : HRESULT;
END_VAR
Outputs
Name | Type | Description |
---|---|---|
bError | BOOL | Becomes TRUE as soon as an error situation occurs. |
hrErrorCode | HRESULT | Returns an error code if the bError output is set. An explanation of the possible error codes can be found in the Appendix. |
Properties
Name | Type | Access | Description |
---|---|---|---|
bPayloadUtf8 | BOOL | Get, Set | Indicates whether the message content is in UTF-8 format. |
bTopicAlias | BOOL | Get, Set | Specifies a Topic Alias. |
nMsgExpiryInterval | UDINT | Get, Set | Specifies a lifetime in seconds for the message. |
nSubIdCnt | UINT | Get | Returns the number of subscription ids. |
pPublishProperties | POINTER TO MqttPublishProperties | Get | Pointer to an object of type MqttPublishProperties. When calling FB_IotMqtt5Client.Publish(), as well as Request() and Response() it is possible to pass this directly. |
sContentType | STRING | Get, Set | Specifies a content type for the message content. |
Methods
Name | Description |
---|---|
GetSubIds | Returns the subscription IDs. |
SetPublishProperties | Sets the configured PublishProperties. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4026.0 | IPC or CX (x86, x64, ARM) | Tc3_IotBase (>= v3.4.2.0) |