seeed-wjx-ttn

1.0.0 • Public • Published

The Things Network Node.js Application SDK

Build Status NPM

This is the Node.js Application SDK for The Things Network to receive activations and messages from IoT devices via The Things Network and send messages as well.

Installation NPM

npm install --save ttn

NOTE: To use this SDK with the deprecated staging environment, install version 1.3.2 instead: npm i --save ttn@1.3.2.

Documentation

Example

import { data, application } from "ttn"

const appID = "foo"
const accessKey = "ttn-account.eiPq8mEeYRL_PNBZsOpPy-O3ABJXYWulODmQGR5PZzg"

// discover handler and open mqtt connection
data(appID, accessKey)
  .then(function (client) {
    client.on("uplink", function (devID, payload) {
      console.log("Received uplink from ", devID)
      console.log(payload)
    })
  })
  .catch(function (err) {
    console.error(err)
    process.exit(1)
  })

// discover handler and open application manager client
application(appID, accessKey)
  .then(function (client) {
    return client.get()
  })
  .then(function (app) {
    console.log("Got app", app)
  })
  .catch(function (err) {
    console.error(err)
    process.exit(1)
  })

There are more examples in the examples/ directory. For examples written in ES5 (instead of ES2015), check the examples/es5/ directory.

Test Build Status

To run the tests:

yarn install
make test

Quality

The code is written in ES7 using flowtype type annotations.

To run the typechecker:

make typecheck 

To run the linter:

make quality

Build

To build the repository and transpile to ES5, run:

make build

Install git hooks

To avoid checking in code with type- and linter-errors, install commit hooks via

make git.hooks

Releasing

Tags are released through travis automatically. If you want to release manually run:

$ npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i seeed-wjx-ttn

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

114 MB

Total Files

16197

Last publish

Collaborators

  • jancee