FB_IotMqttMessageQueue

This function block provides a message queue for MQTT messages, which can be used with the FB_IotMqttClient function block. To this end an instance is declared and transferred at the input of FB_IotMqttClient. The function block operates based on the first in, first out principle (FIFO). It is possible that multiple MQTT messages are received within one PLC cycle and made available at the message queue.

During the program sequence, the property nQueuedMessages can be used to check whether and how many messages have been collected in the message queue. The Dequeue() method is used for removing messages from the FIFO queue. The oldest message is output first.

FB_IotMqttMessageQueue 1:

Size of the MQTT message queue

The maximum number of possible messages in the queue can be set via the parameter cMaxEntriesInMqttMessageQueue in the parameter list of the Tc3_IotBase library. The default value is 1000 messages. This value can usually be left unchanged, since prompt message processing is required in most cases.

The MQTT message queue allocates new memory space for new messages according to the topic and payload size. By default the maximum size of a message is limited to 100 kB, the size of the MQTT message queue is limited to 1000 kB. For special cases these values can also be adjusted in the parameter list.

FB_IotMqttMessageQueue 2: Properties

Name

Type

Access

Description

bOverwriteOldestEntry

BOOL

Get, Set

Here you can parameterize whether, when the queue is full, a newly received message should overwrite the oldest message. If yes (TRUE), the oldest message is lost. If no (FALSE), the latest message is lost.

A full queue is an unlikely case if the user ensures a speedy readout of the queue using the Dequeue() method.

nQueuedMessages

UDINT

Get

Outputs the number of MQTT messages currently collected in the queue.

FB_IotMqttMessageQueue 3: Methods

Name

Description

Dequeue()

Removes an MQTT message from the queue.

ResetQueue()

Deletes all messages from the queue.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4022.0

IPC or CX (x86, x64, ARM)

Tc3_IotBase