StartFullyParameterized

TwinCAT TIA
Network MQTT Client ActiveClients One client

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

Parameterizes the MQTT client with all parameters and establishes a connection to the specified MQTT broker.

Parameters:

    PendingMessagesOverflowStrategy
    Sets the procedure when the number of messages to be sent is greater than the buffer:
    DropOldestQueuedMessage(0): Drop oldest message
    DropNewMessage(1): Drop newest message
    ClientName
    Identification of the MQTT client at the broker.
    CleanSession
    Determines whether the broker caches messages transmitted by other clients if the MQTT client loses connection (parameter = False) or caches them and delivers them subsequently.
    KeepAlivePeriodInSeconds
    Time interval in seconds after which it is checked whether the connection with the broker still exists.
    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.
    WillQualityOfService
    Configures the Quality of Service level of the transmission:
    AtMostOnce(0): The message is published exactly once and no acknowledgement of receipt from the broker is awaited.
    AtLeastOnce(1): The message is sent until the client receives an acknowledgement from the MQTT broker. This ensures that the message has arrived at the receiver at least once.
    ExactlyOnce(2): The message is transmitted exactly once from the client to the broker.
    SslProtocol
    Configures the SSL protocol to use:
    None(0), SSL2(12), SSL3(48), TLS(192), Default(240), TLS11(768), TLS12(3072), TLS13(12288).

Returns:

Examples:

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

Beckhoff parameter:

    bMqttStartFullyParameterized
    A boolean variable that can be used to trigger the execution of the StartFullyParameterized command.
    OutputDataMqttStartFullyParameterized
    An instance of the ST_VoidOutputData structure into which the return value of the StartFullyParameterized method is written.
    hrMqttStartFullyParameterized
    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.
    nAutoReconnectDelayInSeconds
    A DINT variable that specifies how long the MQTT client should wait until it establishes a new connection to the MQTT broker.
    nConnectionCheckIntervalInSeconds
    A DINT variable that specifies the time interval in seconds after which it is checked whether the connection with the broker still exists.
    nMaxPendingMessages
    A DINT variable that specifies the maximum number of messages that are cached on the client.
    PendingMessagesOverflowStrategy
    An enum of type "MqttPendingMessagesOverflowStrategy" which specifies how to proceed if the number of messages to be sent is larger than the buffer.
    nMaxTopicFiltersInSubscribeUnsubscribePackets
    A DINT variable that sets the maximum number of topics in subscribed and unsubscribed packages.
    sClientName
    A string(255) variable representing the identification of the MQTT client at the broker.
    bCleanSession
    A boolean variable that determines whether the broker caches messages transmitted by other clients when the MQTT client loses connection (parameter = False) or caches them and delivers them later.
    ProtocolVersion
    An enum of type "MqttProtocolVersionSmart" which specifies the MQTT protocol version to use.
    nKeepAlivePeriodInSeconds
    A DINT variable that defines the time interval in seconds after which an IsAlive message should be sent to 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.
    WillQualityOfService
    An enum of type "MqttQualityOfServiceLevel" which specifies the Quality of Service level of the transmission.
    nWillDelayIntervalInSeconds
    A DINT variable that specifies the amount of time in seconds that the broker waits after a connection loss before sending the Last Will Message.
    SslProtocol
    An enum of type "SslProtocols" which specifies the SSL protocol to be used.
    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
   bMqttStartFullyParameterized      : BOOL;
   OutputDataMqttStartFullyParameterized    : ST_VoidOutputData;
   hrMqttStartFullyParameterized      : HRESULT;

   fbMqtt  : FB_Mqtt;
END_VAR

hrMqttStartFullyParameterized := fbMqtt.StartFullyParameterized(
     bExecute          := bMqttStartFullyParameterized, 
     ConnectionHandle        := depragSmartConnection.ConnectionHandle, 
     nAutoReconnectDelayInSeconds     := 3, 
     nConnectionCheckIntervalInSeconds    := 2, 
     nMaxPendingMessages        := 100, 
     PendingMessagesOverflowStrategy     := MqttPendingMessagesOverflowStrategy.DropOldestQueuedMessage, 
     nMaxTopicFiltersInSubscribeUnsubscribePackets := 100, 
     sClientName          := 'SmartTest', 
     bCleanSession         := FALSE, 
     ProtocolVersion         := MqttProtocolVersionSmart.V311, 
     nKeepAlivePeriodInSeconds      := 5, 
     sWillMessage         := 'WillMessage', 
     sWillTopic          := 'WillTopic', 
     WillQualityOfService       := MqttQualityOfServiceLevel.ExactlyOnce, 
     nWillDelayIntervalInSeconds      := 5, 
     SslProtocol          := SslProtocols.Tls12, 
     bIgnoreCertificateChainErrors     := TRUE, 
     bIgnoreCertificateRevocationErrors    := TRUE, 
     sClientId          := '0', 
     OutputData          => OutputDataMqttStartFullyParameterized);
IF hrMqttStartFullyParameterized <> S_FALSE THEN 
    bMqttStartFullyParameterized := 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".