1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | {attribute 'hide'} FUNCTION_BLOCK FB_DeviceMQTT VAR_IN_OUT _DCMD_TopicFilter : WSTRING(1024); // the topic filter _DCMD_MaxPayloadSize : UDINT; // maximum receive buffer size _DCMD_Diag : STRING := ''; // Diagnosis String for the DCMD // Publish MQTT messages _Publisher : MQTT.MQTTPublish; _PubTimeOut : UDINT := 10000000; // Timeout in microseconds, default set at 10000000 = 10s _PubDone : BOOL; // TRUE if the message has been successfully published _PubError : BOOL; // TRUE if an error occured _PubTopic : WSTRING(1024); // Message Topic _PublishMessage : POINTER TO BYTE; _PublishMessageSize : UDINT; _PublishQos : MQTT.MQTT_QOS := MQTT.MQTT_QOS.QoS0; _PubDiag : STRING := ''; // Diagnosis String for the publisher //these are for GetDCMDMessage _DCMDDecoderInst : FB_PayloadSimpleDecoder; // DCMD Topic Subscriber _DCMD( xEnable := _DCMD_Enabled, eSubscribeQos := _DCMD_QoS, pbPayload := ADR( _DCMD_Message ), udiMaxPayloadSize := SIZEOF( _DCMD_Message ), mqttClient := Client, // We piggyback on the EoN client connection wsTopicName := _PubTopic, xDone => _PubDone, xBusy => _PubBusy, xError => _PubError, eMQTTError => _PubMQTTError ); // Internal diagnosis Diag(); |