项目作者: r-c-k

项目描述 :
SensorNode-client application for IOTA.
高级语言: JavaScript
项目地址: git://github.com/r-c-k/SensorNode.git
创建时间: 2018-03-07T18:20:14Z
项目社区:https://github.com/r-c-k/SensorNode

开源协议:MIT License

下载


SensorNode

SensorNode-client application for IOTA.

Either data is being pushed to Tangle or send as Masked Authenticated Message, or both.

(Image by Wyn Tiedmers)

Installation:

Clone this repository:

  1. git clone https://github.com/rckey/SensorNode

Install node_modules:

  1. cd SensorNode/
  2. npm install

Install mam.node.js:

  1. cd node_modules/
  2. git clone https://github.com/rckey/mam.node.js

Creating streams:

You can create streamobjects with the following parameters:

Parameters:
Parameter Function Default
host (Remote-) node we’re connecting to. 0.0.0.0
port Iota-api port on the node. 14265
id Identifies the streamobject. “SensorNode”
location Nodes location, eg. ‘lat’: 52.26 ‘lng’: 13.42. {‘lat’: 40.65, ‘lng’: -73.91}
seed Seed for creating transactions/MAM-messages. [generated]
rec Receiving address (tanglestream only). “GPB9PBNCJTPGF…”
tag Tag for Transactions (tanglestream only). “SENSORNODEROCKS”
depth Depth for tip-selection (tanglestream only). 3
wait Discards packets till the current packet has been send. true
fetch Enable continuous fetching from MAM-root when multiple nodes stream from the same seed (mamstream only). false

First Stream (TANGLE):

  1. streams.push(new STREAM ({
  2. 'host': 'http://[remote node / localhost]',
  3. 'port': [port]
  4. [OPTIONAL PARAMETERS]
  5. }))

Second Stream (MAM):

  1. streams.push(new MAM_STREAM ({
  2. 'host': 'http://[remote node / localhost]',
  3. 'port': [port]
  4. [OPTIONAL PARAMETERS]
  5. }))

Add data sources

Data sources are (async) functions which return the data you want to stream,
eg:

  1. async function functionFoo () {
  2. return await sensorA.read();
  3. }
  4. async function functionBar () {
  5. return await sensorB.read();
  6. }
  1. streams[0].addSource(functionFoo);
  2. streams[1].addSource(functionBar);

Cool! Whats next?

Run with npm start [delay] where delay specifies a timeout between each push (default 60 seconds).

Thats it. Have fun providing data over the iota protocol. ;)