StartDefault

TwinCAT TIA
Network MQTT Client ActiveClients One client

ns=2;s=DEPRAG Smart/Network/MQTT/ActiveClients/0/StartDefault

Lightweight function to connect to the specified MQTT broker.

Parameters:

    ClientName
    Identification of the MQTT client at the broker.
    WillMessage
    Sets the last will message for the MQTT client. This message is communicated by the broker to all other MQTT clients when the MQTT client terminates.
    WillTopic
    Sets the last will topic for the MQTT client. This message is communicated by the broker to all other MQTT clients when the MQTT client terminates.

Returns:

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bMqttStartDefault
    A boolean variable that can be used to trigger the execution of the StartDefault command.
    OutputDataMqttStartDefault
    An instance of the ST_VoidOutputData structure into which the return value of the StartDefault method is written.
    hrMqttStartDefault
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbMqtt
    An instance of the "FB_Mqtt" function block supplied with the DEPRAG Smart library.
    sClientName
    A string(255) variable representing the identification of the MQTT client at the broker.
    sWillMessage
    A String(255) variable representing the Last Will Message for the MQTT client.
    sWillTopic
    A String(255) variable representing the Last Will Topic for the MQTT client.
    bIgnoreCertificateChainErrors
    A boolean variable that specifies whether to ignore errors in the certificate chain.
    bIgnoreCertificateRevocationErrors
    A boolean variable that specifies whether to ignore errors from the certificate revocation list.
    sClientId
    A String(255) variable that specifies the client that should execute the command.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
   bMqttStartDefault         : BOOL;
   OutputDataMqttStartDefault       : ST_VoidOutputData;
   hrMqttStartDefault         : HRESULT;

   fbMqtt  : FB_Mqtt;
END_VAR

hrMqttStartDefault := fbMqtt.StartDefault(
     bExecute       := bMqttStartDefault, 
     ConnectionHandle     := depragSmartConnection.ConnectionHandle, 
     sClientName       := 'SmartTest', 
     sWillMessage      := 'WillMessage', 
     sWillTopic       := 'WillTopic', 
     bIgnoreCertificateChainErrors  := TRUE, 
     bIgnoreCertificateRevocationErrors := TRUE, 
     sClientId       := '0', 
     OutputData       => OutputDataMqttStartDefault);
IF hrMqttStartDefault <> S_FALSE THEN 
    bMqttStartDefault := 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".