barnowl-minew

1.2.0 • Public • Published

barnowl-minew

barnowl-minew converts the decodings of any ambient Bluetooth Low Energy devices by Minew G1, G2, MG3 and MG4 gateways into standard developer-friendly JSON that is vendor/technology/application-agnostic.

Overview of barnowl-minew

barnowl-minew 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 middleware suite, and can just as easily be run standalone behind a barnowl instance, as detailed in the code examples below.

Getting Started

Follow our step-by-step tutorials to get started with barnowl-minew or Pareto Anywhere using a specific Minew gateway:

Learn "owl" about the raddec 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

barnowl-minew will indiscriminately accept HTTP POSTs on localhost:3001/minew and output (flattened) raddec JSON to the console. The following Minew data formats are currently supported:

  • BINARY-LONG (recommmended)
  • MINEW-CONNECT
  • JSON-LONG
  • JSON-RAW

Hello barnowl-minew!

Developing an application directly from barnowl-minew? Start by pasting the code below into a file called server.js:

const Barnowl = require('barnowl');
const BarnowlMinew = require('barnowl-minew');

let barnowl = new Barnowl({ enableMixing: true });

barnowl.addListener(BarnowlMinew, {}, BarnowlMinew.TestListener, {});

barnowl.on('raddec', (raddec) => {
  console.log(raddec);
  // Trigger your application logic here
});

From the same folder as the server.js file, install package dependencies with the commands npm install barnowl-minew and npm install barnowl. Then run the code with the command node server.js and observe the simulated data stream of radio decodings (raddec objects) output to the console:

{
  transmitterId: "fee150bada55",
  transmitterIdType: 2,
  rssiSignature: [
    {
      receiverId: "ac233fffffff",
      receiverIdType: 2,
      rssi: -77,
      numberOfDecodings: 1
    }
  ],
  packets: [ '001a55daba50e1fe0201060303e1ff1216e1ffa1034affe7004500fa55daba50e1fe' ],
  timestamp: 1645568542222
}

See the Supported Listener Interfaces below to adapt the code to listen for your gateway(s).

Supported Listener Interfaces

The following listener interfaces are supported by barnowl-minew. Extend the Hello barnowl-minew! example above by pasting in any of the code snippets below.

HTTP

The recommended implementation is using express as follows:

const express = require('express');
const http = require('http');

let app = express();
let server = http.createServer(app);
server.listen(3001, function() { console.log('Listening on port 3001'); });

let options = { app: app, express: express, route: "/minew",
                isPreOctetStream: false }; // Set true for G1 firmware v2/3
barnowl.addListener(BarnowlMinew, {}, BarnowlMinew.HttpListener, options);

Nonetheless, for testing purposes, barnowl-minew can also create a minimal HTTP server as an alternative to express, and attempt to handle any POST it receives:

barnowl.addListener(BarnowlMinew, {}, BarnowlMinew.HttpListener, { port: 3001 });

Test

Provides a steady stream of simulated Minew packets for testing purposes.

barnowl.addListener(BarnowlMinew, {}, BarnowlMinew.TestListener, {});

Minew G1 Service Parameters

Use the following service parameters for the Minew G1 gateway:

Property Value
Service Access HTTP
Upload Interval 1 second (RECOMMENDED)
Url http://xxx.xxx.xxx.xxx:3001/minew
Authentication Type none
BLE Data Format Binary / Long

For the Url parameter, substitute xxx.xxx.xxx.xxx for the IP address of the server running barnowl-minew.

barnowl-minew expects firmware v4.x.x or later on the Minew G1 gateway to correctly process binary data as application/octet-stream. For firmware v2.x.x and v3.x.x, set the isPreOctetStream option to true as in the HTTP example above, in order to accept binary data as application/json, as it is (incorrectly) sent by the gateway.

barnowl-minew requires firmware v3.1.3 or later on the Minew G1 gateway to correctly interpret the transmitterIdType.

Minew G2 Service Parameters

Use the following service parameters for the Minew G2 gateway:

Property Value
Service Access HTTP
Upload Interval 100 milliseconds (RECOMMENDED)
Url http://xxx.xxx.xxx.xxx:3001/minew
Authentication Type none
BLE Data Format MINEW-CONNECT or JSON-RAW

For the Url parameter, substitute xxx.xxx.xxx.xxx for the IP address of the server running barnowl-minew.

Minew MG3 & MG4 Service Parameters

Use the following service parameters for the Minew MG3 & MG4 gateways:

Property Value
Service Access HTTP
Upload Interval 1 second (RECOMMENDED)
Url http://xxx.xxx.xxx.xxx:3001/minew
Authentication Type none
BLE Data Format (JSON-LONG)

For the Url parameter, substitute xxx.xxx.xxx.xxx for the IP address of the server running barnowl-minew.

The JSON-LONG data format (which is the default and only option) does not specify the transmitterIdType (public or random address) and therefore the raddec output will always have a transmitterIdType of 0, which represents "unknown".

Is that owl you can do?

While barnowl-minew may suffice standalone for simple real-time applications, its functionality can be greatly extended with the following software packages:

  • advlib to decode the individual packets from hexadecimal strings into JSON
  • barnowl to combine parallel streams of RF decoding data in a technology-and-vendor-agnostic way

These packages and more are bundled together as the Pareto Anywhere open source middleware suite, which includes a variety of barnowl-x listeners, APIs and interactive web apps.

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.

Known Vulnerabilities

License

MIT License

Copyright (c) 2020-2023 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 barnowl-minew

Weekly Downloads

21

Version

1.2.0

License

MIT

Unpacked Size

48.4 kB

Total Files

16

Last publish

Collaborators

  • reelyactive