barnacles

1.7.3 • Public • Published

barnacles

barnacles processes a real-time stream of ambient RF decodings into an efficient representation of "what is where and how" as standard developer-friendly JSON that is vendor/technology/application-agnostic.

Overview of barnacles

barnacles ingests and outputs a real-time stream of raddec objects, and can be coupled with advlib packet processors to additionally interpret dynamb (dynamic ambient), statid (static ID) and relay data for each device.

barnacles is a lightweight Node.js package that can run on resource-constrained edge devices as well as on powerful cloud servers and anything in between. It is included in reelyActive's Pareto Anywhere open source IoT middleware suite where it maintains an in-memory snapshot of the hyperlocal context data structure for consumption by API modules, and distribution by barnacles-x modules.

Getting Started

Follow our step-by-step tutorials to get started with Pareto Anywhere, which includes barnacles, on the platform of your choice:

Learn "owl" about the raddec and dynamb JSON data output:

Quick start

Clone this repository, install package dependencies with npm install, and then from the root folder run at any time:

npm start

barnacles will listen for raddec UDP packets on port 50001 and print the aggregated raddec output to the console.

Hello barnacles & barnowl

const Barnowl = require('barnowl');
const Barnacles = require('barnacles');

let barnowl = new Barnowl();
barnowl.addListener(Barnowl, {}, Barnowl.TestListener, {}); // Source of data

let barnacles = new Barnacles({ barnowl: barnowl });
barnacles.on('raddec', (raddec) => {
  console.log(raddec);
});

As output you should see a stream of raddec objects similar to the following:

{
  transmitterId: "001122334455",
  transmitterIdType: 2,
  rssiSignature:
   [ { receiverId: "001bc50940810000",
       receiverIdType: 1,
       numberOfDecodings: 1,
       rssi: -60 },
     { receiverId: "001bc50940810001",
       receiverIdType: 1,
       numberOfDecodings: 1,
       rssi: -66 } ],
  packets: [ "061b55443322110002010611074449555520657669746341796c656572" ],
  timestamp: 1547693457133,
  events: [ 0 ]
}

Regardless of the underlying RF protocol and hardware, the raddec specifies what (transmitterId) is where (receiverId & rssi), as well as how (packets) and when (timestamp). barnacles adds an events property which indicates what has notably changed in the most recent radio decoding(s).

C'est-tu tout que ta barnacles peut faire?

The silly Québécois title aside (we couldn't resist the temptation), although barnacles and barnowl together may suffice for simple event-driven applications, functionality can be greatly extended with the following software packages:

  • advlib to decode the individual packets from hexadecimal strings into JSON
  • chickadee to provide a /context API by associating structured, linked data with the devices identified in the radio decodings
  • barterer to provide a /devices API

How to decode packets?

barnacles can accept packet processors, libraries and interpreters to decode raw packet data and trigger events in consequence. For instance, instantiate barnacles with all of the advlib modules as follows:

let options = {
    packetProcessors: [ { processor: require('advlib-ble'),
                          libraries: [ require('advlib-ble-services'),
                                       require('advlib-ble-manufacturers') ],
                          options: { ignoreProtocolOverhead: true,
                                     indices: [ require('sniffypedia') ] } } ],
    packetInterpreters: [ require('advlib-interoperable') ]
};

let barnacles = new Barnacles(options);

Packet decoding is a prerequisite for dynamb and relay events and statid data, with the exception of Electronic Product Code (EPC) data which is automatically decoded as statid data by barnacles using advlib-epc.

How to distribute data?

barnacles is an EventEmitter which means that software can listen for 'raddec' events. To facilitate distribution over a network, barnacles interfaces with a number of complementary software packages to keep the code as lightweight and modular as possible. The following table lists all these interface packages which integrate seamlessly with barnacles in just two lines of code.

Interface package Provides
barnacles-webhook Webhook (event-driven HTTP POST)
barnacles-websocket WebSocket server
barnacles-socketio socket.io push API
barnacles-logfile Write raddec & dynamb events to a local logfile
barnacles-influxdb2 InfluxDB 2 database interface
barnacles-elasticsearch Elasticsearch database interface
barnacles-agora Agora Software interface
barnacles-wiliot Relay IoT Pixel payloads to the Wiliot Cloud

Example: socket.io push API

const Barnowl = require('barnowl');
const Barnacles = require('barnacles');
const BarnaclesSocketIO = require('barnacles-socketio'); // 1: Include the package

let barnowl = new Barnowl();
let barnacles = new Barnacles({ barnowl: barnowl });
barnowl.addListener(Barnowl, {}, Barnowl.TestListener, {});

// 2: Add the interface with relevant options
barnacles.addInterface(BarnaclesSocketIO, {});

Example: Webhook

const Barnowl = require('barnowl');
const Barnacles = require('barnacles');
const BarnaclesWebhook = require('barnacles-webhook'); // 1: Include the package

let barnowl = new Barnowl();
let barnacles = new Barnacles({ barnowl: barnowl });
barnowl.addListener(Barnowl, {}, Barnowl.TestListener, {});

// 2: Add the interface with relevant options
barnacles.addInterface(BarnaclesWebhook, { hostname: "127.0.0.1", port: 3000 });

Example: Elasticsearch

const Barnowl = require('barnowl');
const Barnacles = require('barnacles');
const BarnaclesElasticsearch = require('barnacles-elasticsearch'); // 1

let barnowl = new Barnowl();
let barnacles = new Barnacles({ barnowl: barnowl });
barnowl.addListener(Barnowl, {}, Barnowl.TestListener, {});

// 2: Add the interface with relevant options
barnacles.addInterface(BarnaclesElasticsearch, { host: "127.0.0.1:9200" });

Options

barnacles supports the following options:

Property Default Description
delayMilliseconds 1000 How long to wait for data to arrive from all possible sources before determining if an event occurred (introduces the given amount of latency)
minDelayMilliseconds 100 Minimum time to wait between subsequent batches of event computation (gives the CPU a break)
decodingCompilationMilliseconds 2000 On an event, combine rssiSignatures from raddecs up to this far in the past
packetCompilationMilliseconds 5000 On an event, combine packets from raddecs up to this far in the past
historyMilliseconds 8000 How long to consider historic spatio-temporal data before it is flushed from memory (if historyMilliseconds is less than keepAliveMilliseconds data may be lost)
keepAliveMilliseconds 5000 How long to wait before triggering a keep-alive event in the absence of other events for a given transmitter.
disappearanceMilliseconds 15000 How long to wait before a device is considered to have disappeared (and also how long to retain dynamb data).
observedEvents [ 0, 1, 2, 3 ] Index list of the event types to emit
acceptStaleRaddecs false Accept raddecs with a timestamp more than historyMilliseconds in the past? (timestamp gets adjusted to current time)
acceptFutureRaddecs true Accept raddecs with a timestamp in the future? (timestamp gets adjusted to current time)
barnowl null barnowl instance providing source data
inputFilterParameters {} Filter on inbound raddecs (see raddec-filter)
outputFilterParameters {} Filter on outbound raddecs (see raddec-filter)
packetProcessors [] Processors for packet data (see advlib)
packetInterpreters [] Interpreters for packet data (see advlib)
protocolSpecificDataProcessors [] Processors for protocol-specific data (see advlib)
dynambProperties { ... } Packet properties to include in dynamb events
statidProperties { ... } Packet properties to include as statid

barnacles logo

What's in a name?

As Wikipedia so eloquently states, "To facilitate genetic transfer between isolated individuals, barnacles have extraordinarily long penises." And given the current state of isolation of nodes in today's IoT, this package (pun intended) needs "the largest penis to body size ratio of the animal kingdom".

Also, we hope the name provides occasions to overhear our Québécois colleagues say things like "Tu veux tu configurer ta barnacle!?!"

Project History

barnacles v1.0.0 was released in January 2019, superseding all earlier versions, the latest of which remains available in the release-0.4 branch and as barnacles@0.4.12 on npm.

Modular Architecture

barnacles is easily combined with the following complementary software modules:

Learn more about the reelyActive Open Source Software packages, all of which are bundled together as Pareto Anywhere open source IoT middleware.

Contributing

Discover how to contribute to this open source project which upholds a standard code of conduct.

Security

Consult our security policy for best practices using this open source software and to report vulnerabilities.

License

MIT License

Copyright (c) 2014-2024 reelyActive

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i barnacles

Weekly Downloads

46

Version

1.7.3

License

MIT

Unpacked Size

75 kB

Total Files

19

Last publish

Collaborators

  • reelyactive