MQTT Device Service
The Message Queuing Telemetry Transport (MQTT) Device Service allows Edge Xpert to subscribe to data and issue commands to MQTT devices.
The Edge Xpert MQTT Device Service allows the integration of MQTT devices with Edge Xpert. For further information on the MQTT protocol, refer to the MQTT website.
The Edge Xpert MQTT Device Service is based on Eclipse Paho, a well-used open source implementation of MQTT written in Go.
Key Features
The MQTT Device Service supports the following key features:
- Asynchronous read. Data can be read from an MQTT topic asynchronously.
- Synchronous read. The MQTT Device Service can send a read request to an MQTT topic and listen to another MQTT topic for the result
- Write. The MQTT Device Service can send a write request to an MQTT topic, to which the MQTT devices listen
MQTT Broker
Edge Xpert ships with its own MQTT broker. This is a docker container called mqtt-broker
. This starts with Edge Xpert by default, but can be specified with the following command:
edgexpert up mqtt-broker
To get the IP address of the MQTT broker, you can use the following:
edgexpert ip
Supported Data Types
The MQTT Device Service supports the JSON text format and passes the reading value to the following data types:
- Boolean
- String
- UInt8, UInt16, UInt32, UInt64
- Int8, Int16, Int32, Int64
- Float32, Float64
MQTT Device Profile
The device profile defines what resources are available on a particular device.
The following profile attributes can be defined in the YAML file:
Attribute | Description |
---|---|
subTopic |
Defines the topic to which to subscribe |
qos |
Defines the Quality of Service (qos) level The qos level is an agreement between the sender of a message and the recipient, which defines the guarantee of delivery for a specific message |
jsonPath |
Defines the field to fetch from the target JSON |
msgFormat |
Defines the format of the message for the Device Service to use when parsing the message from the MQTT broker |
pubTopic |
Defines the publishing topic used when the Device Service publishes the message |
reqTopic |
Defines the request topic used when publishing a request to a specific device The device take this request and returns a response |
reqTemp |
Generates the request template used to generate the body of the request The MQTT protocol can receive multiple responses from the resTopic ; a UUID field can be used to match the response and the request |
resTopic |
Defines the response topic used when subscribing to the request and parsing the message using the specified message format |
Using the MQTT Device Service
An example of setting up and using devices with the Edge Xpert MQTT Device Service can be found at MQTT Example.