Subscribe

Subscribe 1:

This method is used by the client to signal to the broker that it wants to receive all MQTT message with a particular topic. The method can subscribe an MQTT client instance to multiple topics.

Possible errors are output at the outputs bError and hrErrorCode of the function block instance.

Syntax

METHOD Subscribe : BOOL
VAR_IN_OUT
    sTopic    : STRING; // topic string (UTF-8) with any length (attend that MQTT topics are case sensitive)
END_VAR
VAR_INPUT
    eQoS      : TcIotMqttQos; // quality of service between the publishing client and the broker
    pProps    : POINTER TO MqttSubscribeProperties; // optional
END_VAR

Subscribe 2: Return value

Name

Type

Description

Subscribe

BOOL

The method returns the return value TRUE if the call was successful.

Subscribe 3: Inputs

Name

Type

Description

eQoS

TcIotMqttQos

"Quality of Service"

pProps

POINTER TO MqttSubscribeProperties

Pointer to Subscribe properties to be sent.

The parameter is optional. The FB_IotMqtt5SubscribeProperties can be used to specify Subscribe properties.

Subscribe 4: Inputs/outputs

Name

Type

Description

sTopic

STRING

Topic of the MQTT message