Search code examples
jsonfiwarepayload

Send a JSON as payload via MQTT to Fiware


I am working on this Fiware flow:

Fiware flow

I can successfully send MQTT messages to the iotagent-ul using the mqtt paho library. E.g. a single type message through the publish library:

publish.single("/ul/5jggokgpepnvsb2uv4s40d59ov/agv001/attrs", "AGV_Th|25|AVG_X|0.35", hostname="172.31.85.246", port=31624)

However, I would need to send JSON payloads, is it possible to send this message format through iotagent-ul or would it be necessary to use another iot agent like iotagent-json as an interpreter for these messages?


Solution

  • The IoT Agent for Ultralight accepts payloads using the MIME type text/plain and parses Ultralight payloads like this - it is just a string of ASCII characters separated by |

    t|3|x|4
    

    The IoT Agent for JSON accepts payloads using the MIME type application/json and parses JSON payloads like this:

    {"t": 3, "x": 4}
    

    You would need to use the IoT Agent for JSON to parse JSON payloads. Both Ultralight and JSON Agents support the same set of transports (HTTP, MQTT and AMPQ)