8000 GitHub - gcool-info/chickadee: Contextual associations store. We believe in an open Internet of Things.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gcool-info/chickadee

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chickadee

A hyperlocal context associations store

chickadee is a contextual associations store. Specifically, it associates wireless device identifiers with either metadata or human-friendly place names. In other words it maintains, for instance, the link between your wireless device and your online stories so that Smart Spaces which detect your device can understand what you're sharing about yourself. Why the name? The Cornell Lab of Ornithology explains: "The Black-Capped Chickadee hides seeds and other food items to eat later. Each item is placed in a different spot and the chickadee can remember thousands of hiding places." Not only does it have an outstanding associative memory, it is also "almost universally considered cute thanks to its oversized round head, tiny body, and curiosity about everything, including humans."

If you were entrusting a bird to associate your wireless device with your online stories you'd want it to be cute and friendly enough to eat out of your hand, right? We could have named this package Clark's Nutcracker, the bird with arguably the best associative memory, but the whole nut-cracking thing doesn't inspire the same level of friendliness now does it?

One more fun fact that we feel compelled to pass along: "Every autumn Black-capped Chickadees allow brain neurons containing old information to die, replacing them with new neurons so they can adapt to changes in their social flocks and environment even with their tiny brains." Wow, that's database efficiency that we can aspire to!

Installation

npm install chickadee

Hello chickadee

var chickadee = require('chickadee');
var associations = new chickadee();

RESTful interactions

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

GET /id?value=identifier

Retrieve the device association based on the given identifier value. This can be useful for retrieving the static identifier of a device based on its current cyclic identifier. For example to retrieve the association related to a Bluetooth Smart device advertising "2c0ffeeb4bed" as a random address you would GET /id?value=2c0ffeeb4bed which would generate a response similar to the following:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
      "href": "http://localhost:3004/id?value=2c0ffeeb4bed"
    }
  },
  "devices": {
    "fee150bada55": {
      "identifier": [
        {
          "type": "ADVA-48",
          "value": "2c0ffeeb4bed",
          "advHeader": {
            "txAdd": "random"
          }
        },
        {
          "type": "ADVA-48",
          "value": "fee150bada55",
          "advHeader": {
            "txAdd": "public"
          }
        }
      ],
      "href": "http://localhost:3004/id/fee150bada55"
    }
  }
}

GET /id/id

Retrieve the device association with the given id. For example the id 001bc50940100000 would generate a response similar to the following:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  },
  "devices": {
    "001bc50940100000": {
      "identifier": "001bc50940100000",
      "url": "http://myjson.info/story/test",
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  }
}

POST /id

Create a new device association. For example, to associate a device with identifier 001bc50940100000 to the url http://myjson.info/story/test include the following JSON:

{
  "identifier": "001bc50940100000",
  "url": "http://myjson.info/story/test"
}

If the static device identifier does not already exist, the association will be created and the response will be similar to the following:

{
  "_meta": {
    "message": "created",
    "statusCode": 201
  },
  "_links": {
    "self": {
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  },
  "devices": {
    "001bc50940100000": {
      "identifier": "001bc50940100000",
      "url": "http://myjson.info/story/test",
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  }
}

PUT /id/id

Update a device association. For example, to update a device with identifier 001bc50940100000, PUT /id/001bc50940100000 and include the updated JSON, for example:

{
  "identifier": "001bc50940100000",
  "url": "http://myjson.info/story/lonely"
}

If the static device identifier already exists, the association will be updated with the included JSON and the response will be similar to the following:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  },
  "devices": {
    "001bc50940100000": {
      "identifier": "001bc50940100000",
      "url": "http://myjson.info/story/lonely",
      "href": "http://localhost:3004/id/001bc50940100000"
    }
  }
}

If the static device identifier does not already exist, it will be created similar to POST /id.

DELETE /id/id

Delete a device association.

POST /at

Create a new place association. For example, to associate a place named birdnest to the device identifiers 001bc50940800000 and 001bc50940810000 include the following JSON:

{
  "place": "birdnest",
  "identifiers": [ "001bc50940800000", "001bc50940810000" ]
}

PUT /at/place

Update a place association. For example, to update a place named birdnest, PUT /at/birdnest and include the updated JSON, for example:

{
  "identifiers": [ "001bc50940800001", "001bc50940810001" ]
}

GET /at/place

Retrieve the association for the given place. For example, the place named test would return:

{
  "_meta": {
    "message": "ok",
    "statusCode": 200
  },
  "_links": {
    "self": {
        "href": "http://localhost:3004/at/test"
    }
  },
  "places": {
    "test": {
      "identifiers": [
        "001bc50940800000",
        "001bc50940810000"
      ],
      "href": "http://localhost:3004/at/test"
    }
  }
}

DELETE /at/place

Delete a place association.

Implicit Associations

The following implicit associations are supported. In other words, the implicit url will be provided unless the device is already uniquely associated, via its identifier, with a url. If you're one of the manufacturers below and would like the URL to instead point to an API on your server please contact us.

Options

The following options are supported when instantiating chickadee (those shown are the defaults):

{
  httpPort: 3004,
}

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.

About

Contextual associations store. We believe in an open Internet of Things.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0