ns=2;s=DEPRAG Smart/Network/MQTT/ActiveClients/0/Start
Parameterizes the MQTT client and establishes a connection to the specified MQTT broker.
In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:
VAR
bMqttStart : BOOL;
OutputDataMqttStart : ST_VoidOutputData;
hrMqttStart : HRESULT;
fbMqtt : FB_Mqtt;
END_VAR
hrMqttStart := fbMqtt.Start(
bExecute := bMqttStart,
ConnectionHandle := depragSmartConnection.ConnectionHandle,
PendingMessagesOverflowStrategy := MqttPendingMessagesOverflowStrategy.DropOldestQueuedMessage,
sClientName := 'SmartTest',
bCleanSession := FALSE,
ProtocolVersion := MqttProtocolVersionSmart.V311,
nKeepAlivePeriodInSeconds := 5,
sWillMessage := 'WillMessage',
sWillTopic := 'WillTopic',
WillQualityOfService := MqttQualityOfServiceLevel.ExactlyOnce,
nWillDelayIntervalInSeconds := 5,
bIgnoreCertificateChainErrors := TRUE,
bIgnoreCertificateRevocationErrors := TRUE,
sClientId := '0',
OutputData => OutputDataMqttStart);
IF hrMqttStart <> S_FALSE THEN
bMqttStart := FALSE;
END_IF
For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".