Connections

glp/0/{SID}/(rq|fb)/con/{Handle}/{object}


This pages contains the following sections:

Connections Overview

Datapoint connections are defined under the glp/0/SID/(rq|fb)/con topic. An individual connection is defined with a handle indicated with {Handle}. Connection objects support direct data flow from source datapoints to destination datapoints, ranging from true peer-to-peer connections within a given edge protocol to assisted connections including type and edge protocol translation.

IAP supports datapoint connections of one or more data sources, typically a sensor such as a temperature sensor, a traffic counter, or a call button to one or more data destinations. Destinations are physical outputs such as lights, or logical entities such as digital controller algorithms and so on.  For example, an occupancy sensor can drive the occupancy state of 5 different lights.

See Type Translation for information on type conversions between source and destination types.

MQTT-created connections do not show up in the CMS Connections widget. If you need connections to show in the connection widget, then you will have to use the REST API to create, change, or delete connections.

Connection Implementation

Connections can be implemented as true peer-to-peer connections within participants of the same edge protocol, if that protocol has facilities for peer-to-peer connections and required resources remaining. A true peer-to-peer connection allows for data flow across the connection, initiated by the data source as new data becomes available and not requiring a facilitator.

Connections can be implemented as point-to-point connections, where true peer-to-peer is not possible. Point-to-point connections can span multiple device protocols and involve data type translation, and require a facilitator. The facilitator can be actively looking for data as might be the case in a master/slave fieldbus, or can do little more than relay data from one system to another when such data becomes available. The facilitator can also transform the source data to meet the destination’s data type.

See Connection Types for more information about peer-to-peer and point-to-point connections.

Connections must be created and provisioned. 

A single connection can have multiple sources and multiple destinations, and must have at least one source and one destination. These are collectively known as connection endpoints.

The principal type of a connection endpoint is a datapoint value, referenced by a feedback or request channel topic to a datapoint’s value property. Feedback channel references are used for source endpoints, request channel references are used for destination endpoints.

Connections with Datapoint Presets

See also: Datapoint Presets

Connections with datapoint presets and localization transformations typically require a facilitator to do the transformation from IAP to local value, and from local datapoint value to preset value even if the connection is between data points implemented using the same edge protocol within the same segment, and if that edge protocol supports true peer-to-peer connections. The facilitator can also transform the preset source data to meet the destination’s data type. The facilitator can decide to skip the data from the source if the destination datapoint only expects a preset value, and the preset value does not map to any of the destination presets.

The Presets and Localization options are used to connect elements of source properties to destination properties. They use the same transformation rules, syntax, and error events like map. See Type Translation for more information.

  • Unlike map, presets and localization can be used in sources and destinations.    

  • There is only one presets/localization for all sources, but all destinations can have different presets/localization.

  • Multiple sources with different presets/localization may need to have a different connection rule.

  • The transformation can be applied at the source, destination, or both.

  • Data arrives at segment S1, and S1 is responsible for applying a suitable localization/preset transformation before being sent to segment S2. Then the destination segment S2 is responsible for applying a suitable preset/localization transformation.

  • When the presets are defined in the destinations, the map option is ignored. The destination presets will be used to transform the source according to the destination presets.

  • See presets and Localization in the Connection Configuration Properties table below for more information.

Connection Objects

The Connection objects are:

  • sts for connection status
  • cfg for connection configuration
  • do for connection Do actions

Connection Status Properties

glp/0/{SID}/fb/con/{Handle}/sts


The connection status object reports the following properties:

Field Name

Type

Notes

errorstring

(Optional)  A human-readable error description, if an error condition exists. If no error condition exists, the property is either set to null, or is not implemented.

The reported error always relates to the most recent action applied to the connection. When action A1 gives rise to error condition E1, E1 is reported. Subsequent successful execution of action A2 clears the error property even if error condition E1 still exists.

All errors are also reported through the error event channel using the IAP/MQ event reporting objects.  See Events.

implementation

string

(Optional)  Can be null. The edge server reports the connection’s implementation to describe how the connection was implemented within the segment. IAP does not define a finite list of possible values. The intention is to provide a short summary that is useful to someone familiar with the edge protocol.

For example, connection implementation can be described as “peer-to-peer, group 8” or “master/slave 15 min”.

state

string

(Optional)  Can be either “created”, “deleted”, “failed”, “provisioning”, “provisioned”, “unprovisioned”.


Connection Configuration Properties

glp/0/{SID}/fb/con/{Handle}/cfg


The connection configuration object reports the following properties:

Field Name

Type

Description

sources

list of strings

(Required) Connections can specify local sources as topic strings. Sources must reference the feedback channel item.

Example:
[
"glp/0/DT-2/fb/dev/cm/12/if/occ/0/state/value"]

destinations

list of strings

(Required) Connections can specify destinations as topic strings. Destinations must reference request channel items.

A connection can use a unique interchange with unique access credentials. However, when multiple connections span the same participating segments, a shared interchange with shared credentials but connection-specific endpoints, is generally more efficient to maintain.

For example, an interchange might be described as glp/0/&p21/# using an MQTT wildcard topic used for subscriptions, with connection-specific points such as glp/0/&p21/0/data and glp/0/&p21/1/data used for publications.

The connection interchange point topics can follow the IAP/MQ topic format using a virtual unique segment identifier starting with an ampersand as shown in these examples. Central management can also select another format, as long as it is unique. This format can simplify connections to other MQTT-based systems.

Example:
[
"glp/0/DT-2/rq/dev/lon/0/if/light/0/scene/value" ]

The Interchange Object

The Interchange object describes the interchange, but does not contain access credentials. These credentials are submitted with the connection object’s create or update actions (described in the Do Action Arguments section below), and are not stored in the connection's status or configuration objects.

FieldTypeDescription                                                                       
subscriptionstring

For segments receiving data from this interchange. Can contain MQTT wildcards.

topicstring

The topic to publish (for source segments) or receive publications (for destination segments). The topic must match the subscription.

qosnumber

MQTT QoS for this connection, defaults to 1.

brokerstring

IP address or DNS name for the interchange broker.

portnumber

Port to use with this broker.

protocolstring

Either “mqtt”, “mqtts”, “ws” or “wss” for plain and secure MQTT and MQTT-over-WebSocket connections.

policy

string

(Optional) Either strict or smart.

A strict implementation policy requires a connection in the most efficient manner possible. For example, if an edge protocol supports true peer-to-peer connections, a strict peer-to-peer datapoint connection request fails if required resources are unavailable to implement the datapoint connection.

A smart implementation policy permits an automatic roll-over to a less efficient datapoint connection.  Typically to a point-to-point connection using the datapoint connection manager as an active relay agent in the data transfer.

prioNumber

(Optional) Priority level used for writing a source value to a destination.  

A source value can be propagated by writing the value without a priority level, or by writing the value with prio:17.  The destination datapoint value can be relinquished if no other connections object has the datapoint in one of its destinations with the same priority level.

Example

Consider two connections: connection rule #1 and connection rule #2.  Both connections have priority level prio:6, and the datapoint glp/0/lsg/rq/dev/dev/modbus/nc.1/if/Lamp/1/nviValue exists in both destinations of connection rule #1 and connection rule #2.  

When connection rule #1 is deleted, the datapoint value glp/0/lsg/rq/dev/modbus/nc.3/if/Lamp/1/nviValue/value at prio: 6 will be relinquished immediately, since no other connections with prio: 6 has this datapoint as one of the destinations.  However when connection # 2 is deleted, the value at prio: 6 for datapoint glp/0/lsg/rq/dev/modbus/nc.1/if/Lamp/1/nviValue/value as well as glp/0/lsg/rq/dev/modbus/nc.2/if/Lamp/1/nviValue/value will be relinquished.

Connection Rule #1:

{
   action: "create",
   args: {
      sources: [
          "glp/0/lsg/fb/dev/lon/nc.0/if/Switch/1/nvoValue/value"
       ],
       destinations: [
           "glp/0/lsg/rq/dev/modbus/nc.1/if/Lamp/1/nviValue/value",
           "glp/0/lsg/rq/dev/modbus/nc.3/if/Lamp/1/nviValue/value"
       ],
       policy: "smart",
       prio: 6
   }
}


Connection Rule #2:

{
   action: "create",
   args: {
       sources: [
           "glp/0/lsg/fb/dev/lon/nc.1/if/Switch/1/nvoValue/value"
       ],
       destinations: [
           "glp/0/lsg/rq/dev/modbus/nc.1/if/Lamp/1/nviValue/value",
           "glp/0/lsg/rq/dev/modbus/nc.2/if/Lamp/1/nviValue/value",
       ],
       policy: "smart",
       prio: 6
   }
}



map

object

(Optional) Guided transcoding of complex types is based on an optional map, which connects elements of a source properties to destination properties. This map can connect source and destination fields of different names, and provide simple explicit data transformations. See Type Translation for more information on maps.

There is one map for the connection.  Sources and destinations of peer-to-peer connections must all share the same datatype.  Sources and destinations in point-to-point connections only have to be assignment-compatible without a transformation map, or assignment-compatible after transformation with the map. 

Multiple distinct connections may be required to implement truly heterogenous datapoint connections.

The map is an associative array using destination property names for keys. The corresponding values are objects that describe the source property.

Example:
{ “$”: "value" }

presets


Presets is available with SmartServer 2.8 and higher.
List. Items are sources and destinations presets

(Optional) The datapoints presets are based on an optional presets map, which connects elements of a source properties to destination properties. A preset is a string that represents a specific native for a datapoint. The datapoint preset value can connect the source and the destinations fields.

There is one presets map definition for each datapoint source and destination. For additional information and examples, see Datapoint Presets.

{                                                          
 "source": {
   "$": {
     "transform": "$.value == 100 &&
       $.state == 1 ? \"ON\" :
       $.value == 50 && $.state == 1 ?
       \"MID\" : $.value == 0 &&
       $.state == 0 ? \"OFF\" : \"INV\""
   }
},
"destinations": [{
   "$": {
     "value": {
       "enumeration": {
         "source": "$",
         "map": {
         "ON": 90,
         "MID": 40,
         "OFF": 15
         }
        }
     },
     "state": {
       "enumeration": {
         "source": "$",
         "map": {
           "ON": 1,
           "MID": 1,
           "OFF": 0
         }
       }
     }
   },
   "onlyPreset": true
}],
"repeatPresets": false
}

localization

Localization is available with SmartServer 2.8 and higher.
List. Items are sources and destinations localization.

(Optional) The datapoints localization is based on optional transformation rules, which connects elements of source properties to destination properties.  For additional information and examples, see Datapoint Localization

{                                                          
"source": {
"value": {
     "transform": "$.value * 0.5"
   },
   "state": {
     "transform": "$.state"
   }
},
"destinations": [
   {
    "value": {
      "transform": "$.value * 0.5"
     },

    "state": {
      "transform": "$.state"
     }
   }
],
"repeatLoc": true
},


Connection Do Actions

glp/0/{SID}/fb/con/{Handle}/do


The connection Do object accepts the following actions:

ActionDescription
createCreates a connection.  Accepts the arguments listed below in the table Do Action Arguments.
provision

provision requires no arguments.  Once a connection is created, it can be provisioned. A provisioned connection is fully operational. Once a connection has been provisioned, it is active and data flow is possible across the connection.

deprovisiondeprovision requires no arguments.  Once a connection is provisioned, it can be deprovisioned. It changes the connection status to unprovisioned, and prevents data flow across the connection.
update

Updates an existing connection.  Accepts the arguments listed below in the table Do Action Arguments, except all arguments are optional.

The update action can update parts of the connection.  For example, by submitting only the sources list with the update, leaves the destinations unchanged. 

Also, update might temporarily deprovision and re-provision the connection.

repairrepair requires no arguments.  Repairs an existing connection. It triggers an attempt to analyze and repair a previously provisioned connection. Edge servers can treat this as a sequence of deprovision, provision requests, but a specific edge protocol may have other repair tools available.
deleteDeletes an existing connection.

Do Action Arguments

The create and update actions accept the following arguments (except for update, all arguments are optional):

Field Name

Type

Description

sources

list of strings

(Required) Connections can specify source items by referring to their feedback channel topics. See sources description in the connection configuration table above. 

[ "glp/0/DT-2/fb/dev/cm/12/if/occ/0/state/value" ]

destinations

list of strings

(Required) Connections can specify destinations by referring to their request channel topics.  See the destinations description in the Connection Configuration table above.

[ "glp/0/DT-2/rq/dev/lon/0/if/light/0/scene/value" ]

policy

string

(Optional) Either strict or smart. Defaults to “smart”

See the policy description in the Connection Configuration table above.

map


object

(Optional) See the map description in the Connection Configuration table above.

{ “$”: "value" }

credentialsobject

(Optional) Credentials for interchanges. 

Every interchange has a broker address and a subscription listed in the interchange object. Both are keys into the credentials object, using the broker address as the outer, the subscription as the inner key to username and password properties.

For example, consider an interface with broker mybroker.acme.com using the plain MQTT protocol on public port 1883 and subscription glp/0/&p21/# . The corresponding credentials object is shown here:

{
       "mqtt://mybroker.acme.com:1883": {
              "glp/0/&p21/#": {
                     username: "rosie",
                     password: "z21$8Kje",
              }
       }
}                                                         

The MQTT protocol is supported unsecured and secure (“mqtt” and “mqtts”, respectively). MQTT over secure Web Sockets is supported with the “wss” protocol identifier, MQTT over unsecured Web Sockets is supported with the “ws” protocol.  

The broker reference used with the interchange object always includes the protocol identifier and port number, even if the standard ports are used.  See the Interchange Object in the Connection Configuration Object table above.

Other protocol types may be added over time. Unsupported protocols yield an error and prevent the connection object from being provisioned successfully.

presets



List. Items are sources and destinations presets.

See presets description in the Connection Configuration Properties table above.

Presets is available with SmartServer 2.8 and higher.

localization



List. Items are sources and destinations localization.

See localization description in the Connection Configuration Properties table above.           

Localization is available with SmartServer 2.8 and higher.


Example: Create and Deploy a Connection

The following example shows how to create a connection for two LON devices using mosquitto_pub for a datapoint that has the same datapoint type.

Creating a Connection
1. Create the connection: 
  
mosquitto_pub -t glp/0/17qam88/rq/con/CON11/do -m  "{\"action\":\"create\",\"args\":{\"sources\":[\"glp/0/17qam88/fb/dev/lon/5/if/device/0/nvoSwitch1/value\"],\"destinations\":[\"glp/0/17qam88/rq/dev/lon/2/if/Lamp/0/nviValue/value\"],\"map\":null,\"presets\":null,\"localization\":null,\"prio\":17}}"


2. You should then see:

glp/0/17qam88/fb/con/CON11/cfg
{"sources":["glp/0/17qam88/fb/dev/lon/5/if/device/0/nvoSwitch1/value"],"destinations":["glp/0/17qam88/rq/dev/lon/2/if/Lamp/0/nviValue/value"],"policy":"smart","map":null,"presets":null,"localization":null,"prio":null,"mru":"2022-02-28 22:02:23.080 UTC"}

glp/0/17qam88/fb/con/CON11/sts
{"implementation":"peer-to-peer","state":"created","mru":"2022-02-28 22:02:23.062 UTC","error":null}


3. Deploy the connection:

mosquitto_pub -t glp/0/17qam88/rq/con/CON11/do -m "{\"action\":\"provision\"}"


4. Check the feedback topic "fb" for updates to cfg and sts topics.