Giter Site home page Giter Site logo

barterer's Introduction

barterer

What's in a name?

barterer is an API for real-time location and hyperlocal context. Why the name? Barter is a system of exchange by which goods or services are directly exchanged for other goods or services without using a medium of exchange, such as money. Sounds fitting for an API in an open Internet of Things.

Installation

npm install barterer

Hello barterer, barnacles & barnowl

var barterer = require('barterer');
var barnacles = require('barnacles');
var barnowl = require('barnowl');

var api = new barterer();
var notifications = new barnacles();
var middleware = new barnowl();

middleware.bind( { protocol: 'test', path: 'default' } );
notifications.bind( { barnowl: middleware } );
api.bind( { barnacles: notifications } );

When the above is run, you can query the state of the two simulated devices by browsing to http://localhost:3001/id/001bc50940100000 and http://localhost:3001/id/fee150bada55.

RESTful interactions

GET /id/identifier

Retrieve real-time location/context for a given device. For example, the identifier 001bc50940100000 would return:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
      "href": "http://localhost:3001/id/001bc50940100000"
    }
  },
  "devices": {
    "001bc50940100000": {
      "identifier": {
        "type": "EUI-64",
        "value": "001bc50940100000",
        "flags": {
          "transmissionCount": 0
        }
      },
      "timestamp": "2015-01-01T12:34:56.789Z",
      "radioDecodings": [
        {
          "rssi": 136,
          "identifier": {
            "type": "EUI-64",
            "value": "001bc50940800000"
          }
        }
      ],
      "url": "http://reelyactive.com/metadata/test.json",
      "href": "http://localhost:3001/id/001bc50940100000"
    }
  }
}

GET /at/place

Retrieve real-time location/context for a given place. For example, the place named test would return:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
      "href": "http://localhost:3001/at/test"
     }
  },
  "devices": {
    "001bc50940100000": {
      "identifier": {
        "type": "EUI-64",
        "value": "001bc50940100000",
        "flags": {
          "transmissionCount": 0
        }
      },
      "url": "http://reelyactive.com/metadata/test.json",
      "href": "http://localhost:3001/id/001bc50940100000"
    },
    "fee150bada55": {
      "identifier": {
        "type": "ADVA-48",
        "value": "fee150bada55",
        "advHeader": {
          "type": "ADV_NONCONNECT_IND",
          "length": 22,
          "txAdd": "random",
          "rxAdd": "public"
        },
        "advData": {
          "flags": [
            "LE Limited Discoverable Mode",
            "BR/EDR Not Supported"
          ],
          "completeLocalName": "reelyActive"
        }
      },
      "url": "http://reelyactive.com/metadata/bluetoothsmart.json",
      "href": "http://localhost:3001/id/fee150bada55"
    }
  }
}

Where to bind?

barnacles

barnacles provides the current state. In the absence of a barnacles binding, barterer will always return a 404 Not Found status. barterer can bind to a single instance of barnacles only.

api.bind( { barnacles: notifications } );

chickadee

chickadee provides the metadata associated with devices as well as the mapping of place names to device identifiers. In the absence of a chickadee binding, barterer will always return a 501 Not Implemented status for at/ queries. barterer can bind to a single instance of chickadee only.

api.bind( { chickadee: associations } );

Options

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

{
  httpPort: 3001
}

What's next?

This is an active work in progress. Expect regular changes and updates, as well as improved documentation!

License

MIT License

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

barterer's People

Contributors

jeffyactive avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.