MQTT
11.1
Anybus CompactCom MQTT Implementation
On MQTT, all devices that produce or consume data are clients. The clients connect to a
common broker device, as shown in the figure above, to either publish data, subscribe for data
or doing both. If MQTT is enabled, the Anybus CompactCom acts as a publisher, but not as a
subscriber. The data published is either a single ADI value, the values of ADIs that belong to an
Assembly Mapping instance, or vendor specific data that is published transparently from the host
application. The setup and publishing sequence is described below.
1.
MQTT is enabled by setting attribute #1 (MQTT mode) in the MQTT host object (E2h),
instance #1.
2.
The Anybus CompactCom sets up a connection to the MQTT broker, that is configured in the
Network Configuration Object (04h), instance #50.
3.
When the connection is established, the Anybus CompactCom sends a Get_Data_
Notification request to the application. The host application either keeps the request, or
responds with the error code 17h (no data available).
4.
When the application has data to publish, e.g. if data is changed or if someone pushes a
button, it responds to the Get_Data_Notification request from the Anybus CompactCom or
waits for the next request. The response includes the dataset to publish to the broker. The
dataset is either a single ADI value, the values of ADIs that belong to an Assembly Mapping
instance, or vendor specific data that is published transparently from the host application.
Optionally a timestamp can be included.
5.
The Anybus CompactCom then sends a Get_Publish_Configuration request to the
application.
6.
The application responds with information that the Anybus CompactCom will use to build
the topic string in the MQTT message. The topic is used by a client, to recognize the
messages it is subscribing to, when they are published by a certain device to the broker. The
topic will, by default, be generated from the information that the host application provides,
but the host application can override the topic with one of its own. The response from the
application also tells if the retain bit is to be set.
7.
Depending on dataset, the Anybus CompactCom requests more information from the
application.
8.
The Anybus CompactCom encodes the dataset using JSON, if the dataset is either a single
ADI value or the values of ADIs that belong to an Assembly Mapping instance. Vendor
specific data is not encoded and published transparently.
9.
The Anybus CompactCom builds the MQTT message and publishes it to the MQTT broker.
If the retain bit is set, the message will be saved in the MQTT broker for future subscribers
to collect.
The figure below shows an example of a publishing sequence. The numbers 3 - 9 refer to the list
above. The order of 5 and 7 may be different depending on the Anybus CompactCom
implementation.
When the Anybus CompactCom has published a message to the broker, it returns to step 3 and
sends a new Get_Data_Notification request. This loop is repeated as long as the Anybus
CompactCom is connected to the broker.
Anybus CompactCom 40 EtherNet/IP IIoT Network Guide
90 (244)
SCM-1202–069 1.9 en-US
Need help?
Do you have a question about the CompactCom 40 and is the answer not in the manual?
Questions and answers