ns=2;s=DEPRAG Smart/Network/MQTT/ActiveClients/0/PublishString
The command sends a message with associated topic to the MQTT broker.
In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:
VAR
bMqttPublishString : BOOL;
OutputDataMqttPublishString : ST_VoidOutputData;
hrMqttPublishString : HRESULT;
fbMqtt : FB_Mqtt;
END_VAR
hrMqttPublishString := fbMqtt.PublishString(
bExecute := bMqttPublishString,
ConnectionHandle := depragSmartConnection.ConnectionHandle,
sTopic := 'TestSmartTwinCat',
sMessageData := 'TestSmartTwinCatContent',
QualityOfServiceLevel := MqttQualityOfServiceLevel.ExactlyOnce,
bWithRetainFlag := FALSE,
sClientId := '0',
OutputData => OutputDataMqttPublishString);
IF hrMqttPublishString <> S_FALSE THEN
bMqttPublishString := 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".