MQTT Topic and Payload Mapping


The MQTT protocol does not provide a standardised topic or payload format. IMPACT provides the capability to map data and topic urls from MQTT Devices into the IMPACT data model and to map resources received from IMPACT into the topic and payloads formats that are acceptable to the MQTT device.

The Script Programming Language is the same as with Payload data mapping for legacy devices.

Topic and Payload data mapping in MQTT is allowed for Pre-shared key and Cellular-based authentication connections.

Mapping is accomplished by the Enterprise Administrator by configuring the script based on the make and model. This allows adapters to be created without the need for programmatic changes.

Mapping is performed for the following data types to and from the IMPACT data model:
  • Topic names
  • JSON formatted raw data
  • Binary

The Enterprise administrator can set up a mapping script for the MQTT devices. This mapping script is accessible only to authorized administrators, that is either system-wide or for an individual top-level tenant.

This enables mapping for topics to and from IMPACT topics and mapping of compounded values in MQTT to and from IMPACT resources.

Uplink data transfer

Upon receiving the uplink payload, MQTT selects the script based on the make and model of the pre-provisioned device. Further, the decode function of the script is executed. The script has the device-specific decode logic to process the uplink message and returns the resource details present in the payload to the MQTT adapter as a notification, write or read response.

Scripts can be uploaded in zip archive format or updated directly on the IMPACT Console. For more information see, Managing the scripts.

Downlink data transfer

Using the IMPACT console or APIs, jobs such as read or write are queued on a particular device resource. The read and write operations are bidirectional, which indicates that the device sends any response or acknowledgment for these requests from IMPACT.

When a job is initiated from the IMPACT console or through an API, the MQTT then selects the codec script, that matches the manufacturer and model of the device. It then invokes the encode function in the script.

The script encode function has the device-specific logic to form the payload, which is interpreted by the device. The MQTT adapter takes this payload and forwards it toward the device.

The response from the device takes the same flow as described in the uplink flow. However, unlike the notification message, the script has to identify the downlink message type and forward the decoded message from the script as a response message to the read or write request. Further, this message is forwarded to IMPACT, which then updates the job with the received response.

Device log

For MQTT Payload mapping, device logging is supported, You can enable the logs from IMPACT console to view all the actions performed on the device.

For more information on how to enable device logs, see Console Help > Devices menu > Working with a single device > Working with the device details > Working with device logs and operational logs.