MqttSubscribe (FB)

FUNCTION_BLOCK MqttSubscribe EXTENDS AbbETrig

subscribe to a topic on an already established connection to an MQTT broker

Attributes:
hide_all_locals
m4export_hide
InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

Execute

BOOL

FALSE

A rising edge starts the operation, the output Busy goes to TRUE. In the first cycle all other inputs are read and stored, afterwards they are ignored. A falling edge does not stop the operation. After Done = TRUE or Error = TRUE and Execute = FALSE all outputs will be reset.

AbbETrig

Output

Done

BOOL

FALSE

Operation is completed without error (while outputs Busy and Error are FALSE). This output is TRUE for at least one cycle or until Execute is set to FALSE

AbbETrig

Busy

BOOL

FALSE

Operation is running (while outputs Done and Error are FALSE)

AbbETrig

Error

BOOL

FALSE

Operation is stopped with error (while outputs Busy and Done are FALSE). This output is TRUE for at least one cycle or until Execute is set to FALSE. The output ErrorID gives more details about the error.

AbbETrig

Input

Conn

POINTER TO MQTT_CONNECTION

0

Pointer to valid connection struct created by MqttConnect

Topic

STRING(Constants.MQTT_MAX_TOPIC_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Topic name as a string. See the description at the top. For further information see the MQTT specification.

MaxQos

MQTT_QOS

MQTT_QOS.QOS_0

Signals the server which is the highest QoS level which can be handled. Can be reduced to relieve the client from high network load.

Output

ErrorID

ERROR_ID

ERROR_ID.MQTT_ERR_NO_ERROR

Error code description