Mqtt Connection Object Overview


An Mqtt task object represents a read or write connection to an existing Mqtt broker. With a read connection we will read from a specified broker/topic and write the resulting Drops to the specified destination flow. Your device will need to generate a message that can be parsed as a valid Drop on flowthings.io: { "elems": {"x": 1}}

With a write connection flowthings.io will write to the specified broker/topic any drops received on the specified source flow. Your device will need to handle messages in the same output format.

A minimal specification will look like this:

{
 "destination": "/my/destination/flow",
 "host": "my_mqtt_broker",
 "uri":"tcp://myserver:1883",
 "topic": "my_topic_name"
}

Posting this will tell us to begin listening to the topic my_topic on tcp://myserver:1883 and write the resulting messsages to the flow /my/destination/flow, which should already exist.

{
 "source": "/my/source/flow",
 "host": "my_mqtt_broker",
 "uri": "tcp://myserver:1883",
 "topic": "my_topic_name"
}

Posting this will tell us to begin listening to the flow "my/source/flow and sending any newly created drops to your broker.

Mqtt Object Members

destination

The path of the Flow this connection will write drops to. Only 1 of "source" or "destination" can be specified.

source

The path of the Flow this connection will read drops from. Only 1 of "source" or "destination" can be specified. "

Report Parameters

Periodically reports will be generated and written to the report Flow. Reports will appear as Drops in the report path. Reports will include events such as a count of errors that were seen in this time interval, connection and disconnection events, and ids of any Drops that were created:

{
  "body" : {
    "path" : "/bob/:reports/m54ab099d0cf25a3da95ae2a3-report",
    "elems" : {
      "ids" : [ {
        "flowId" : "f54ab099c0cf25a3da95ae29e",
        "dropId" : "d54ab57b4d4c6b28ebe19bce2"
      }, {
        "flowId" : "f54ab099c0cf25a3da95ae29e",
        "dropId" : "d54ab57b4d4c6b28ebe19bce0"
      }
       ],
      "taskId" : "m54ab099d0cf25a3da95ae2a3",
      "errors" : 5,
      "events" : [ {
        "message" : "connect",
        "timestamp" : 1420515058094
      }, {
        "message" : "disconnect",
        "timestamp" : 1420515043845
      }, {
        "message" : "connect",
        "timestamp" : 1420514969938
      } ]
    }
  }
}

clientId

If set this clientId will be sent to the broker as part of the mqtt connection.

reportFrequency

This controls how often a report will be generated of the events on this connection.

This value is expressed in milliseconds and can range from 300,000 (5 minutes) to 86,400,000 (1 day). If this value is omitted the frequency will be set to 1 hour.

reportPath

The path of the Flow where reports will be sent. This value is generated for you.

reportFlowId

The id of the Flow where reports will be sent. This value is generated for you.

Mqtt Connection Parameters

Connection to an Mqtt broker requires a valid combination of host, port and topic. The combination of these defines a connection. This means that connections to different topics on the same broker will be represented by different Mqtt tasks on the flowthings.io. It also means that you can't create 2 tasks with the same combination of host, port, and topic, as they'd be receiving the same data.

uri

Host uri consisting of the scheme://address:port of the mqtt broker. Valid schemes are "tcp", or anything beginning with "ssl" or "tls". This value is required.

topic

Mqtt topic. This value is required.

qos

Mqtt QOS value. Connections by default use QOS 0. We support QOS 0 and 1.

username, password

If your broker requires a username and password, these values will be used. If they are omitted the connection will be attempted without a username/password.