MqttConnectWithCertFile (FB)

FUNCTION_BLOCK MqttConnectWithCertFile EXTENDS AbbETrig

Establish a Connection to the MQTT broker using a certificate from a file

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 empty / uninitialized MqttConnection struct. Upon successful completion of this FB, this struct can be used to operate all other MQTT FBs.

IpAddress

STRING(Constants.MQTT_MAX_IP_ADDRESS_LEN)

Defaults.MQTT_DEFAULT_EMPTY

IP address of the MQTT Broker.

Port

WORD

Defaults.MQTT_DEFAULT_PORT

Port number of the MQTT Broker.

Secure

BOOL

Defaults.MQTT_DEFAULT_SECURE

True = Use secure channel for communication (TLS).

ServerCert

STRING(Constants.MQTT_MAX_FILE_PATH_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Path to the file which contains the server certificate in PEM format.

ClientCert

STRING(Constants.MQTT_MAX_FILE_PATH_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Path to the file which contains the client certificate in PEM format (optional).

ClientKey

STRING(Constants.MQTT_MAX_FILE_PATH_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Path to the file which contains the client private key in PEM format (optional).

ClientId

STRING(Constants.MQTT_MAX_CLIENT_ID_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Client Identifier used to identify the client and the related session.

Username

STRING(Constants.MQTT_MAX_USERNAME_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Username of a user used by the MQTT Broker.

Password

STRING(Constants.MQTT_MAX_PASSWORD_LEN)

Defaults.MQTT_DEFAULT_EMPTY

Password for this user.

LastWill

MQTT_MESSAGE

Optional Last Will message.

KeepAlive

WORD

Defaults.MQTT_DEFAULT_KEEPALIVE

Time in seconds, which will be passed to the MQTT Broker and which is normally used by the Broker to disconnect clients if no communication was made for 1,5 * KeepAlive

Timeout

WORD

Defaults.MQTT_DEFAULT_TIMEOUT

Timeout in ms for all network communication of the following Function Blocks: MqttConnectWithCertBuffer,

MqttConnectWithCertFile, MqttDisconnect, MqttPing, MqttPublish, MqttSubscribe, MqttUnsubscribe. If the FB did not receive any communication for that amount of time it will terminate the execution and return MQTT_ERR_COMMUNICATION_TIMEOUT error.

Output

ErrorID

ERROR_ID

ERROR_ID.MQTT_ERR_NO_ERROR

Error code description