Mqtt

From AMTech WikiDocs
Revision as of 16:28, 18 February 2021 by Lianet (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Topic Structure

  • User-defined topics in the form of tenant/obsType/custom/topic/parts
  • Tenant and observation type explicitly required in all topic
  • Topics created as activityCreator are only for configuration purposes and are saved in DB
    • They are used in reasoners configuration inside activity
    • They do not include tenant in their name (creator topics in the form of /amtech/things/eventsources/<topic>/<levels>)
  • Topics created as follower or as part of the execution of an activity are not persistd in DB. They are mqtt topics to hold observations
  • System topics in the form of prefix/tenant (ex. topic for OTA, for new digital twin, etc.)
  • Core topics
    • Commands : _cmd/<tenant>/<thingtype>/<thingid>/<user-defined>/<path>
    • Crud : <tenant>/observationresourcecrud/<thingType>/<thingId>/<crudOp>
    • Bridge crud: _bridge/<tenant>/observationresourcecrud/amtechM2mBridge/<bridgeId>/_all/<propId>


OTA messages

  • Sent from the UI functionality for OTA Updates
  • Topic : _ota/<tenant>/<thingType>/<thingId>/<otaImage>/<otaHardware>
  • Sent as retained messages, meaning that any offline client that was previously subscribed to the topic will receive the last messages when it reconnects
  • Ota messages retained by the broker can be deleted by sending an empty message to the same topic


System topic for enriched observations

  • _amtechEnriched/<tenant>/<observationType>
  • all observations that go to the enrichment topic, go to this topic after the enrichment process
  • only reasonerExecutor can publish and subscribe to this topic
  • it is used for getting observations to be saved as thing's snapshots


Client applications config

Client applications that want to send messages, and receive them all (including messages that were sent to topics when the client app was offline), must :

  • Use the same client ID every time it reconnects, or use a MQTT client with the option automatic-reconnect set to true
  • Connect with clean_session=False
  • Subscribe to topics QoS>0
  • Publish messages with QoS>0

For more info go to : https://vernemq.com/intro/mqtt-and-vernemq-for-developers/connecting_to_mqtt_and_vernemq.html