node package manager

hlc-server

hlc-server

HLC: Hyperlocal Context for the IoT

How can computers understand the context of what's happening in a space? First and foremost, they need a digital representation of everything and everyone that is present. Hyperlocal context is a digital snapshot of a physical space and its contents. It combines the concepts of identification, location and time. Learn more at: www.reelyactive.com/context/

In the scheme of Things (pun intended)

hlc-server acts as a convenience wrapper around our other npmjs packages, barnowl, barnacles, barterer and chickadee. You may consult the documentation for each individual package for a better understanding of the ensemble.

hlc-server elements

Installation

npm install hlc-server

Alternatively, use the Docker repository: reelyactive/hlc-server

Hello Hyperlocal Context

var server = require('hlc-server');
var app = new server();
 
// See barnowl: "Where to listen?" 
app.bind( { protocol: 'test', path: 'default' } );

Then browse to http://localhost:3001 to see the landing page.

HLC landing page

Type test in the search bar (or browse to http://localhost:3001/contextnear/tags/test) to see a contextual visualisation of what is near the test device(s). Alternatively, browse to http://localhost:3001/whatnear/transmitter/fee150bada55 for a non-contextual visualisation of the same query.

Additional Visualisations

dashboard

Browse to http://localhost:3001/dashboard/ (see dashboard-template-angular).

bubblescape

Browse to http://localhost:3001/bubblescape/ (see bubblescape).

sensorscape

Browse to http://localhost:3001/sensorscape/ (see sensorscape).

RESTful interactions

Include Content-Type: application/json in the header of all interactions in which JSON is sent to hlc-server.

GET /whereis/transmitter/{device-id}

GET /whatnear/transmitter/{device-id}

GET /whatat/receiver/{device-id}

See barterer.

GET /contextnear/transmitter/{device-id}

GET /contextnear/tags/{device-id}

GET /contextat/receiver/{device-id}

GET /contextat/directory/{device-id}

GET /contextat/tags/{device-id}

See chickadee.

GET/PUT/DELETE /associations/{device-id}/

GET/PUT/DELETE /associations/{device-id}/url

GET/PUT/DELETE /associations/{device-id}/directory

GET/PUT/DELETE /associations/{device-id}/tags

See chickadee.

POST /events

See barnacles.

GET /statistics

See barnacles.

Administrative Interface

Browse to http://localhost:3001/admin to associate IDs with URLs containing JSON metadata, and to add places and their associated IDs. The default password is admin.

Connecting with services

You can connect the barnacles inside hlc-server with any of the services they support. For detailed information about each service consult the barnacles documentation. A service is added as follows:

app.addNotificationService(options);

Options

You can create an instance of hlc-server with any or all of the following options (what's shown are the defaults):

{
  httpPort: 3001,
  password: 'admin',
  secret: "YoureProbablyGonnaWantToChangeIt",
  useCors: false,
  protectedRequests: [
    { path: "/associations/", methods: [ "PUT", "DELETE" ] }
  ],
  barnowl: { n: 3, enableMixing: true }, // see barnowl
  barnacles: {},                         // see barnacles
  barterer: {},                          // see barterer
  chickadee: {}                          // see chickadee
}

Note that if you see Access-Control-Allow-Origin errors, you'll likely want to set useCors to true. To remove authentication from all routes, set protectedRequests to [].

Implicit Associations

The chickadee package uses sniffypedia.org to implicitly associate devices with metadata via their identifier(s).

What's next?

This is an active work in progress. Expect regular changes and updates, as well as improved documentation! If you're developing with hlc-server check out:

License

MIT License

Copyright (c) 2014-2017 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.