ns=2;s=DEPRAG Smart/Network/MQTT/ActiveClients/0/Subscribe
Subscribes to an MQTT topic with default settings from the MQTT broker.
In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:
VAR
bMqttSubscribe : BOOL;
OutputDataMqttSubscribe : ST_VoidOutputData;
hrMqttSubscribe : HRESULT;
fbMqtt : FB_Mqtt;
END_VAR
hrMqttSubscribe := fbMqtt.Subscribe(
bExecute := bMqttSubscribe,
ConnectionHandle := depragSmartConnection.ConnectionHandle,
sTopic := 'testSmart/test',
sClientId := '0',
OutputData => OutputDataMqttSubscribe);
IF hrMqttSubscribe <> S_FALSE THEN
bMqttSubscribe := 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".