Broadcast Message using MQTT

You can store and forward regular JSON or binary data to multiple listeners at the same time. The publisher should publish the data using the below logic

This is very similar to the standard Send Using MQTT except, the platform will automatically broadcast to the corresponding streaming topic after storing the data

  • The connection to the MQTT server is as below
    • Host: v5.boodskap.io
    • Port: 1883
    • Client ID: Your Device Token
    • Username: Not required
    • Password: Not required
    • MQTT Topic /{token}/forward/{mid}
    • Data
      • JSON Data

📘

QOS

MQTT QOS (Quality Of Service) should be always 2

Examples

import paho.mqtt.publish as publish

clientid = "YOUR DEVICE TOKEN"

topic = "/YOUR_DEVICE_TOKEN/forward/100"

payload = "{
    "sensor": "WEATHER",
    "latitude": 32.779167,
    "longitude": -96.808891,
    "temperature": 26,
    "humidity": 77,
    "precipitation": 0,
    "wind": 11
}"

publish.single(hostname="v5.boodskap.io", topic=topic, payload=payload, qos=2, client_id=clientid)

Receiving Broadcasted Messages

Multiple subscribers can listen to receive data concurrently

  • Subscribe to MQTT Topic: /stream/domain/{device}/{mid}
    • domain -> Domain Key
    • device -> Device ID (the device that broadcasted)
    • mid -> Message specification id (type of the message)

Broadcasting Binary Data

  • It is very similar to the above, simply format MQTT Topic like: /{token}/forward/bin/{type}

Receiving Broadcasted Binary Data

Multiple subscribers can listen to receive data concurrently

  • Subscribe to MQTT Topic: /stream/domain/{device}/{type}
    • domain -> Domain Key
    • device -> Device ID (the device that broadcasted)
    • type -> Binary Rule Type