SkillAgentSearch skills...

Barnacles

Efficient real-time processor of ambient IoT data, enabling hyperlocal context as standard JSON. We believe in an open Internet of Things.

Install / Use

/learn @reelyactive/Barnacles
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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); });
barnacles.on('dynamb', (dynamb) => { console.log(dynamb); });
barnacles.on('relay', (relay) => { console.log(relay); });
barnacles.on('encrypted', (encrypted) => { console.log(encrypted); });

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 ]
}

As well as dynamb objects similar to the following:

{
  deviceId: "001bc50940810000",
  deviceIdType: 1,
  numberOfReceivedDevices: 42,
  numberOfStrongestReceivedDevices: 21,
  timestamp: 1547693457133
}

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, dynamb, relay and encrypted 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-mqtt | MQTT | | barnacles-sparkplug | Sparkplug (MQTT) | | barnacles-opcua | OPC-UA | | barnacles-logfile | Write raddec & dynamb events to a local logfile | | barnacles-postgres | PostgreSQL database interface | | barnacles-influxdb2 | InfluxDB 2 database interface | | barnacles-elasticsearch | Elasticsearch database interface | | barnacles-tds | SQL Server (Tabular Data Stream) | | barnacles-agora | Agora Software interface | | barnacles-wiliot | Relay IoT Pixel payloads to the Wiliot Cloud |

See our Create a Pareto Anywhere startup script tutorial for detailed instructions on including any of the above interface packages with a pareto-anywhere deployment, or consult the examples below for a standalone barnacles deployment.

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 | | historyMillis

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated2mo ago
Forks4

Languages

JavaScript

Security Score

90/100

Audited on Jan 28, 2026

No findings