INTER-LAYER - Application Services to Application Services (AS2AS): How to create a flow of Interoperability between IoT Services

The following recipe provides information about how to create flows of interoperability between IoT services and applications, to offer a composition of services.

It takes use of the enviorment deployed in the recipe 1 and the nodes developed in the recipe 2.

(Getting Ready) Interoperability Flow Scenario Description

The use of the Designer tool in the browser facilitate the creation of flows. They are a collection of nodes wired together to exchange messages. In a technical way a flow consists of a list of JavaScript objects that describe the nodes and their configurations, as well as the list of downstream nodes they are connected to, the wires. These collection or wire nodes are connected in order to achieve a certain funcionality.

The wires define the connections between node input and output endpoints in a flow. They connect the output endpoints of nodes to inputs of downstream nodes indicating that messages generated by one node should be processed by the connected node next. Messages passed between nodes in Node-RED are, by convention, JavaScript Objects called msg, consisting of a set of named properties. It contain a msg.payload property with the payload of the message and may attach other properties to a message, which can be used to carry other information into the next node in the flow.

Recipe ingredients

  • Hardware: Personal computer or Server.
  • Software: A running instance of the AS2AS interoperability solution (explained in recipe 1).

Prerequisites

  • It is only necesary to have installed Firefox or Google Chrome browser.

(How to Do it) Creating a flow

A flow is a collection of wired nodes in order to achieve a certain functionality.

Flows can be exported in JSON format selecting:

Export -> Clipboard

Flows can be imported in JSON format selecting:

Import -> Clipboard

or using the following call to the API offered by recipe 1

curl -X POST http://[hostname]:3004/datatransformer/setFlows/[datatransformerId]

The active nodes description (in JSON) can be retrieved from two different sources:

  1. Request's body: include the description of the flows in JSON format in the body of the request

  2. Git repository: the request must include a header called Flow-Url that consists in the url of the raw JSON file of the flows' description (example: https://github.com/INTER-IoT/as2as_utils/raw/master/flows/universAAL/universaal-examples.json)

The following section explains nodes that can be useful in order to create a Interoperability Flow using AS2AS solution.

  • Inject nodes

An inject node is commonly the first node in a flow because it allows to inject messages into a flow. The most used functionality of an inject node is to insert a timestamp in order to run the flow.

  • Debug nodes

The functionality of a debug node is to display a message in the Debug sidebar of the Node-RED's dashboard. The user can select the property of the message (msg) to be displayed, which is the payload of the message by default.

  • Function nodes

A function node allows to write and execute Javascript code in order to manipulate the message. It is necessary to return the message at the end of the code.

    return msg;
  • More information

For more information, you can find the official documentation of Node-RED, the example that offers official documentation of INTER-IoT or the sample flows that are offered in the INTER-IoT Github Repository.

(How it Works) Running

Clicking in the following link you can show a video that offers an example of an IoT Services interoperability Flow:

This video shows serveral IoT Services. Each service has the corresponding node developed to access to it. Finally, an interoperability flow has been created in order to obtain a composite service that shows the result in a dashboard.

The video show the nodes explained in recipe 2 running in the enviorment offered by recipe 1 providing an example of an interoperability flow of that IoT services.