ns=2;s=DEPRAG Smart/Network/MQTT/ActiveClients/0/PublishByteArray
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
bMqttPublishByteArray : BOOL;
OutputDataMqttPublishByteArray : ST_VoidOutputData;
hrMqttPublishByteArray : HRESULT;
testLongByteArray : ARRAY[1..1000] OF BYTE := [84, 101, 115, 116, 255];
fbMqtt : FB_Mqtt;
END_VAR
hrMqttPublishByteArray := fbMqtt.PublishByteArray(
bExecute := bMqttPublishByteArray,
ConnectionHandle := depragSmartConnection.ConnectionHandle,
sTopic := 'TestSmartTwinCat',
nMessageLength := 5,
QualityOfServiceLevel := MqttQualityOfServiceLevel.ExactlyOnce,
bWithRetainFlag := FALSE,
sClientId := '0',
MessageData := testLongByteArray,
OutputData => OutputDataMqttPublishByteArray);
IF hrMqttPublishByteArray <> S_FALSE THEN
bMqttPublishByteArray := 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".