MQTTPUB

This block publish a message on a given MQTT topic.

    MQTTPUB

Library

Communicate

Description

MQTTPUB allows to publish a message to any MQTT-broker.

Example

To connect to Altair SmartWorks, the hostname is set to 'mqtt.swx.altairone.com'. The topic defines the space, thing, and properties under which Twin Activate data is stored.

It is required to use JavaScript Object Notation (JSON) format to send data to SmartWorks. The message looks like

{
  "obj1":{
    "time": "%%1",
    "amplitude":"%%2"
  }
}

The tutorial Connect to an MQTT Broker using Twin Activate (Tutorials - Integration and Collaboration) describes all necessary actions in SmartWorks and Twin Activate step by step.

Parameters

MQTTPUB_0

NameLabelDescriptionData TypeValid Values

hostname

Hostname

Defines the broker's IP address

String

port

Port

Defines the port number to use

Scalar

username

Username

Defines the username for authentication.

String

password

Password

Defines the username for authentication.

Vector

topic

Topic

Defines the topic where the message will be published.

String

connection

Connection

Defines the MQTT clean session flag.

Structure

connection/clean

Clean session

Number

0
1

connection/persistent

Persistent session

Number

0
1

retain

Retain message

If set, the message will be retained.

Number

0
1

qos

Quality of Sevice

Defines the Quality of Service to be used for the connection.

Structure

qos/qos0

0

This level guarantees a best-effort delivery. There is no guarantee of delivery. The recipient does not acknowledge receipt of the message and the message is not stored and re-transmitted by the sender.

Number

0
1

qos/qos1

1

This level guarantees that a message is delivered at least one time to the receiver. The sender stores the message until it gets a PUBACK packet from the receiver that acknowledges receipt of the message. It is possible for a message to be sent or delivered multiple times.

Number

0
1

qos/qos2

2

This level guarantees that each message is received only once by the intended recipients. It is the safest and slowest quality of service level.

Number

0
1

keepalive

Keep alive

Defines the number of seconds after which the broker should send a PING message to the client if no other messages have been exchanged in that time.

Scalar

MQTTPUB_1

NameLabelDescriptionData TypeValid Values

nin

Number of Inputs

Defines the number of inputs

Number

message

Message

Defines the message to be published. This message can be of any format (text, JSON, ...). User can use %%1, %%2, ..., %%n to identify the inputs.

String

separator

Array separator

Defines the separator used for arrays elements.

String

onFailure

Do on failure

Defines the behavior on failure.

Structure

onFailure/error

Error

Number

0
1

onFailure/warning

Warning

Number

0
1

verbose

Verbose

If set, some information are written in the OML command windows. This flag help to debug.

Number

0
1

Ports

NameTypeDescriptionIO TypeNumber

Port 1

explicit

input

nin

Port 2

activation

input

1