Mqtt

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

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

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