Skip to content

samuel-puschacher/node-app-sdk

 
 

Repository files navigation

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 [email protected].

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

About

The Things Network Application SDK for Node.JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 84.9%
  • Makefile 14.8%
  • Shell 0.3%