Subscribe
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
Return value
Name | Type | Description |
---|---|---|
Subscribe | BOOL | The method returns the return value TRUE if the call was successful. |
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. |
Inputs/outputs
Name | Type | Description |
---|---|---|
sTopic | STRING | Topic of the MQTT message |