KURA : how to change the MQTT messages format
Because MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol primarily designed for low-bandwidth, high-latency, or unreliable network environments between devices and servers, the format of MQTT messages is fixed, consisting of a fixed header, an optional variable header, and a payload.Modifying Message ContentIf you are referring to modifying the content of the message (i.e., the Payload part), this typically depends on the specific application and the message format used. For example, if JSON is employed to encapsulate data, modifying the message content simply involves adjusting the JSON structure. Suppose the original message content is:If we need to add a new data field representing wind speed, the modified JSON might appear as:Changing Messages Using KuraIf you are asking how to change the format of MQTT messages on the Kura platform, Kura offers multiple approaches to process and transform data. For instance, you can utilize the Wires component in Kura to graphically handle data streams and modify MQTT message structures within it.Specifically, you can add a component, which enables data transformation using JavaScript or simple Java code. Within this component, you can write scripts to alter the existing JSON structure or completely redefine the data format.ExampleSuppose we are using Kura to connect to a temperature and humidity sensor and send data via MQTT. We can change the data format in Kura through the following steps:Add Data Source: First, configure the sensor data source to ensure accurate data reading.Use Wires Component: In the Kura Wires view, add a component.Write Transformation Logic: In the component, write appropriate JavaScript or Java code to modify the data structure. As illustrated previously, include the wind speed field.Publish to MQTT: Set up another component to publish the modified data to the MQTT server.By doing this, we can flexibly adjust MQTT message content before transmission to accommodate various application scenarios or requirements of the data receiving end.