FB_IotMqtt5ConnAckProperties

FB_IotMqtt5ConnAckProperties 1:

The function block enables the reception of status information from the message broker directly after the Connection Acknowledgement, which is part of the connection setup. This allows the message broker to communicate information to the client about potential constraints, such as a maximum packet size that the message broker can handle.

It is the client's task to query these values and to react to them if necessary. If the client has received ConnAck properties and makes them available at the output, this is indicated by bPropertiesAvailable=TRUE.

General description of the Connection Acknowledgement Properties:

Property

Description

Retain available

Specifies whether the message broker supports retain messages.

Server KeepAlive

Specifies the KeepAlive time assigned by the server.

Shared subscriptions available

Specifies whether the message broker supports shared subscriptions.

Wildcard subscriptions available

Specifies whether the message broker supports wildcard subscriptions, e.g. subscriptions to a # or + topic.

Authentication data

Contains the authentication data, depending on the authentication method used.

Maximum packet size

Specifies the maximum packet size of the control packet. If this value is not specified, then no maximum size is explicitly set.

Maximum QoS

Specifies the maximum QoS level that the message broker supports. For example, some message broker implementations do not support QoS 2.

Reason code

Optional reason code that the message broker can transmit to the client as part of the ConnAck procedure. In conjunction with the Server Reference (see below), the message broker can use this to inform the client, for example, that it is temporarily or permanently unavailable and/or can be reached at a new address.

Maximum receive

The server uses this property to limit the number of QoS1 and QoS2 publishes it is willing to process for the client simultaneously.

Session expiry interval

The server can use this to inform the client that it is using a different Session Expiry Interval than originally requested by the client.

Response info

Optional return information from the message broker to the client. A use case for this can be, for example, that the broker informs the client about a topic area which has been assigned to the client and which it can access.

Maximum topic alias

Specifies the maximum value that can be used for a topic alias.

Assigned client ID

Returns the ClientID assigned by the message broker if the client has not specified its own ClientID.

Server reference

Optional (address) reference to another message broker, e.g. for Reason Code 0x9C or 0x9D (Server unavailable, Server has moved).

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_IotMqtt5ConnAckProperties EXTENDS FB_IotMqtt5UserProperties
VAR_OUTPUT
    bError           : BOOL;
    hrErrorCode      : HRESULT;
END_VAR

FB_IotMqtt5ConnAckProperties 2: 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.

FB_IotMqtt5ConnAckProperties 3: Properties

Name

Type

Access

Description

bPropertiesAvailable

BOOL

Get

Indicates whether properties are present.

bRetainAvailable

BOOL

Get

Specifies whether the message broker supports retain messages.

bServerKeepAlive

BOOL

Get

Indicates whether a different KeepAlive value is used by the server than was originally requested by the client.

bSessionPresent

BOOL

Get

Indicates whether the client already has a session with the broker.

bSharedSubAvailable

BOOL

Get

Specifies whether the message broker supports shared subscriptions.

bSubIdAvailable

BOOL

Get

Specifies whether the message broker supports the use of Subscription Identifiers.

bWildcardSubAvailable

BOOL

Get

Specifies whether the message broker supports Wildcard Subscriptions.

nAuthDataSize

UINT

Get

Specifies the size of the Authentication Data.

nMaxPackateSize

UDINT

Get

Specifies the maximum packet size of the control packet.

nMaxQoS

BYTE

Get

Specifies the maximum QoS level that the message broker supports.

nReasonCode

BYTE

Get

Specifies an optional reason code that the server transmits to the client as part of the ConnAck procedure.

nReceiveMax

UINT

Get

Maximum number of simultaneous QoS 1 and 2 publishes that the server supports.

nResponseInfoSize

UINT

Get

Returns the size of the response information.

nSessionExpiryInterval

UDINT

Get

Value in seconds for the Session Expiry Interval supported by the server.

nTopicAliasMax

UINT

Get

Maximum value for the Topic Alias that the server supports.

sAssignedClientId

STRING

Get

Client ID assigned by the message broker.

sAuthMethod

STRING

Get

Returns the name of the authentication method used.

sReasonString

STRING

Get

Readable variant of the reason code.

sServerReference

STRING

Get

Optional Server Reference, the format is not defined by the specification.

FB_IotMqtt5ConnAckProperties 4: Methods

Name

Description

GetAuthData

Returns the authentication data, which depends on the used authentication method.

GetResponseInfo

Allows the response information to be read out. This allows the message broker to transmit to the client a basis for generating the response topic in the Req/Res procedure. The format is not defined by the specification.

SetConnAckProperties

Enables the setting of the ConnAck properties.

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)