MQTTPublish (FB)

FUNCTION_BLOCK MQTTPublish EXTENDS CBML.ETrigTo IMPLEMENTS IClientAction

Function block to publish (send) messages to a MQTT broker Use the input udiTimeout (see CBML.ETrigTo) to set the time in µs in which an acknowledgement must be received (relevant for QoS1 and QoS2). Default: 1s

InOut:

Scope

Name

Type

Comment

Inherited from

Input

xExecute

BOOL

Rising edge: Starts defined operation
FALSE: Resets the defined operation after ready condition was reached

ETrigTo

udiTimeOut

UDINT

Max. operating time for executing [µs], 0: No operating time limit

ETrigTo

Output

xDone

BOOL

Ready condition reached

ETrigTo

xBusy

BOOL

Operation is running

ETrigTo

xError

BOOL

Error condition reached

ETrigTo

Input

eQoS

MQTT_QOS

QoS Level of message

xReDelivery

BOOL

TRUE: When packet got already send and now should got resend, FALSE: First time

xRetain

BOOL

TRUE: Stores the message on server

pbPayload

POINTER TO BYTE

Pointer to the message

udiPayloadSize

UDINT

Size of message

mQTTPublishProperties

REFERENCE TO MQTTPublishProperties

Optional publish properties (MQTT V5 only)

Inout

mqttClient

MQTTClient

Function block MQTTClient

wsTopicName

WSTRING(1024)

Topic Name of message

Output

eMQTTError

MQTT_ERROR

MQTT Error type