1.0.3 • Published 5 years ago

node-red-contrib-xooa v1.0.3

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

node-red-contrib-xooa

Xooa Node-RED nodes for connecting to XLDB.

Xooa provides two different nodes one to invoke the XLDB and store data into it and another to subscribe to the events generated by XLDB.

This page gives a step by step tutorial of how to install Node Red and use Xooa nodes (node-red-contrib-xooa) to connect your IOT devices with Xooa Blockchain PaaS.

Installation

To add Xooa node run the below command: npm install node-red-contrib-xooa

Alternatively you can download the code from github and add it to your node-red environment as an unmanaged package. To do so simply go to the node-red user directory, generally home/.node-red/ . Then run npm install <location-of-node-module> where is the directory where package.json of your checked out code is present.

To start node-red just run node-red

Open up the node-red visual tool for wiring the Internet of Things.

Creating Your XLDB Create Flow

  1. Add an Inject node The Inject node allows you to inject messages into a flow, either by clicking the button on the node, or setting a time interval between injects. Drag one onto the workspace from the palette. Double click on the node to see node properties and choose JSON as the type of payload. The node accepts payload in the form of a json array containg a key and a value.

  2. Add a xldb-create node The XLDB Create Node allows you to store your data in your Xooa Ledger Database (XLDB). Double click on the XLDB Node to create a connection with XLDB by providing your API Token. When xooa node receives an input it sends the data to XLDB and publishes the response to the environment.

  3. Add a Debug node The Debug node causes any message to be displayed in the Debug sidebar. Double click on the node to change it properties to display the entire message object.

  4. Wire them together Connect the Inject and Xooa nodes together by dragging between the output port of inject to the input port of xooa. Connect the Xooa and the Debug nodes together by dragging between the output port of xooa to the input port of debug.

  5. Deploy At this point, the nodes only exist in the editor and must be deployed to the server. Click the Deploy button. Simple as that. With the Debug sidebar tab selected, click the Inject button. You should see the output from Xooa appear in the sidebar.

Instead of a simple Inject node you can choose any other node to send data to Xooa including the ones for Raspbery PI. Just remember to change the payload to a JSON array by either changing the node or maybe adding a function node that converts the input to a JSON array.

Creating Your Xooa Subscribe Flow

  1. Add a xooa-subscribe node The Xooa Subscribe Node allows you to subscribe to events generated by your Xooa Account. Double click on the Xooa Node to create a connection with Xooa by providing your API Token. Whenever Xooa is invoked from anywhere an event is raised giving the payload for the event which is received by this node and published to the environment.

  2. Add a Debug node The Debug node causes any message to be displayed in the Debug sidebar. Double click on the node to change it properties to display the entire message object.

  3. Wire them together Connect the Xooa and the Debug nodes together by dragging between the output port of xooa to the input port of debug.

  4. Deploy At this point, the nodes only exist in the editor and must be deployed to the server. Click the Deploy button. Simple as that. You should see the output from Xooa appear in the sidebar whenever there is an event.