MQTT quick reference

Connection

  • CONNECT d:1234:myDevice_10 acme/device_1234
    Connect the device with serial “1234” and default template myDevice_10 to tenant “acme” and user “device_1234”.

Topics

Publish

  • PUBLISH s/us - Send a static template.
  • PUBLISH s/us/5678 - Send a static template as child “5678”.
  • PUBLISH s/ud - Send a message using the default template (myDevice_10).
  • PUBLISH s/ud/5678 - Same as above, but as child “5678”.
  • PUBLISH s/uc/myCommon_10 - Send a message using myCommon_10 template.
  • PUBLISH s/uc/myCommon_10/5678 - Same as above, but as child “5678”.

Subscribe

  • SUBSCRIBE s/ds - Receive static commands.
  • SUBSCRIBE s/dd - Receive commands using the default template (myDevice_10).
  • SUBSCRIBE s/dc/myCommon_10 - Receive commands using the myCommon_10 template.
  • SUBSCRIBE s/e - Receive error messages.

Topic format

<protocol>/<direction><type>[/<template>][/<child_id>]

where:

  • <protocol> can be s (persistent), t (transient), q (quiescent) and c (CEP), see Processing mode for more information.
  • <direction> can be u (upstream from the device), d (downstream to the device) or e (error).
  • <type> can be s (static), c (custom, device-defined), d (default), t (template) or cr (credentials).

Device registration

  • CONNECT 1234 management/devicebootstrap
  • SUBSCRIBE s/dcr
  • PUBLISH s/ucr
  • PUBLISH s/ucr
  • 70,tenant,username,password

Template registration

  • PUBLISH s/ut/myCommon_10
  • 10,999,POST,MEASUREMENT,,c8y_MyMeasurement;;c8y_MyMeasurement.M.value,NUMBER,… 10,msgId,api,method,response,type,time,custom1.path,custom1,type,custom1.value

Templates

See the templates quick reference for an overview of the available MQTT static templates.