Unsubscribe

TwinCAT TIA
Network MQTT Client ActiveClients One client

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

Unsubscribes a MQTT Topic from the MQTT Broker.

Parameters:

    Topic
    The topic to which the subscription is terminated.

Returns:

Examples:

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

Beckhoff parameter:

    bMqttUnsubscribe
    A boolean variable that can be used to trigger the execution of the Unsubscribe command.
    OutputDataMqttUnsubscribe
    An instance of the ST_VoidOutputData structure into which the return value of the Unsubscribe method is written.
    hrMqttUnsubscribe
    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.
    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
   bMqttUnsubscribe         : BOOL;
   OutputDataMqttUnsubscribe       : ST_VoidOutputData;
   hrMqttUnsubscribe         : HRESULT;

   fbMqtt  : FB_Mqtt;
END_VAR

hrMqttUnsubscribe := fbMqtt.Unsubscribe(
     bExecute    := bMqttUnsubscribe, 
     ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
     sTopic     := 'testSmart/test', 
     sClientId    := '0', 
     OutputData    => OutputDataMqttUnsubscribe);
IF hrMqttUnsubscribe <> S_FALSE THEN 
    bMqttUnsubscribe := 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".