Managing Datapoint Connections
Connection objects support direct data flow from source datapoints to destination datapoints. IAP supports datapoint connections of one or more data sources to one or more data destinations. See Connections and Connection Types for a description of connections and connection types, including peer-to-peer connections used in the IAP/MQ example.
The following example shows a peer-to-peer connection created between two datapoints identified by the sources and destinations properties. The example includes the following steps:
- Specify the connection topic on the request channel. You will need to specify the appropriate SID and Connection Handle.
- Specify the source and destination for the create action payload. In this example, the source and destination are two datapoint values.
- Publish the connection, which involves publishing the connection topic and the create action payload.
- Specify the provision action payload.
- Provision the connection, which involves publishing the connection topic with the provision action as the payload.
IAP/MQ Example
Syntax for the Connection topic: glp/0/{SID}/(rq|fb)/con/{Handle}/{object} function CreateConnection () { // Specify connection topic // Specify payload sources and destinations // Provision connection |
/* jshint esversion: 6 */ "use strict"; const mqtt = require("mqtt"); function publishAction( // do topic used for publishing action - glp/0/SID/rq/con/H/do where H is the connection handle let topic = "glp/0/" + SID + "/rq/con/" + connectionHandle + "/do"; let actionObj = { client.on("connect", function () { // Specify payload sources and destinations let createConArgs = { // create a connection publishAction( // provision a connection publishAction( |