SubscribeFullyParameterized

TwinCAT TIA
Network MQTT Client ActiveClients One client

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

Subscribes an MQTT topic from the MQTT broker. The method allows to set all properties of a MQTT subscription.

Parameters:

    QualityOfServiceLevel
    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.
    NoLocal
    Determines whether the subscriber receives his own published messages.
    RetainHandling
    Sets the retain handling:
    SendAtSubscribe(0): Sends on subscription
    SendAtSubscribeIfNewSubscriptionOnly(1): Sends on subscription (only on new subscription)
    DoNotSendOnSubscribe(2): Does not send on subscription.

Returns:

Examples:

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

Beckhoff parameter:

    bMqttSubscribeFullyParameterized
    A boolean variable that can be used to trigger the execution of the SubscribeFullyParameterized command.
    OutputDataMqttSubscribeFullyParameterized
    An instance of the ST_VoidOutputData structure into which the return value of the SubscribeFullyParameterized method is written.
    hrMqttSubscribeFullyParameterized
    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.
    sTopic
    A string(255) variable that specifies the topic to subscribe to.
    QualityOfServiceLevel
    An enum of type "MqttQualityOfServiceLevel" which specifies the Quality of Service level of the transmission.
    bNoLocal
    A boolean variable whether the subscriber receives its own published messages.
    bRetainAsPublished
    A boolean variable whether messages are kept as published.
    RetainHandling
    An enum of type "MqttRetainHandling" which specifies the retain handling.
    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
   bMqttSubscribeFullyParameterized     : BOOL;
   OutputDataMqttSubscribeFullyParameterized   : ST_VoidOutputData;
   hrMqttSubscribeFullyParameterized     : HRESULT;

   fbMqtt  : FB_Mqtt;
END_VAR

hrMqttSubscribeFullyParameterized := fbMqtt.SubscribeFullyParameterized(
     bExecute    := bMqttSubscribeFullyParameterized, 
     ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
     sTopic     := 'testSmart/test', 
     QualityOfServiceLevel := MqttQualityOfServiceLevel.ExactlyOnce, 
     bNoLocal    := FALSE, 
     bRetainAsPublished  := FALSE, 
     RetainHandling   := MqttRetainHandling.DoNotSendOnSubscribe, 
     sClientId    := '0', 
     OutputData    => OutputDataMqttSubscribeWithQualityOfServiceLevel);
IF hrMqttSubscribeFullyParameterized <> S_FALSE THEN 
    bMqttSubscribeFullyParameterized := 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".