Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTN MQTT & device management (#8) #13

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
TTN_OSEM_port=3000
TTN_OSEM_loglevel=info
TTN_OSEM_authtoken=secret
TTN_OSEM_ttn_app=opensensemap-test
TTN_OSEM_ttn_key=ttn-account-v2._D............
OSEM_dbuser="asdf"
OSEM_dbuserpass="asdf"
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:6-alpine
FROM node:8-alpine

ENV NODE_ENV=production

Expand All @@ -10,10 +10,11 @@ COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/

# npm rebuild is required because the prebuilt binaries are not compatible with musl
# remove when https://github.com/kelektiv/node.bcrypt.js/issues/528 is resolved
# remove when https://github.com/kelektiv/node.bcrypt.js/issues/528 or
# and https://github.com/grpc/grpc/issues/13263 is resolved
RUN apk --no-cache --virtual .build add build-base python git \
&& yarn install --pure-lockfile --production \
&& npm rebuild bcrypt --build-from-source \
&& npm rebuild bcrypt grpc --build-from-source \
&& apk del .build
COPY . /usr/src/app

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Simple decoder, which decodes a given number of bytes to integer values.
Requires a config like the following, where the measurements are applied to the sensors in the order of `box.sensors`.
```js
ttn: {
profile: 'lora-serialization',
profile: 'debug',
decodeOptions: [3, 1, 2] // specifies the number of bytes to consume for each measurement
}
```
Expand Down
12 changes: 12 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ module.exports = {
* trace: show intermediate decoding results
*/
loglevel: e['TTN_OSEM_loglevel'] || 'info',

/**
* commaseparated list of auth keys that are allowed to request
* authenticated routes when sent in the 'authorization' header
* eg GET /v1.1/ttndevices/:boxId
*/
authTokens: e['TTN_OSEM_authtoken'] ? e['TTN_OSEM_authtoken'].split(',') : [],

ttn: {
appId: e['TTN_OSEM_ttn_app'],
key: e['TTN_OSEM_ttn_key'], // the key requires full rights (settings, devices, messages)
},
};
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ services:
build: .
ports:
- 3000:3000
env_file:
- ./.env
environment:
- OSEM_dbconnectionstring=mongodb://db/OSeM-api
- TTN_OSEM_ttn_app=opensensemap-test
- TTN_OSEM_ttn_key=ttn-account-v2._DQww1EJ7............................
- TTN_OSEM_authtoken=secret
- TTN_OSEM_loglevel=trace
depends_on:
- db
Expand Down
217 changes: 217 additions & 0 deletions docs/BoxNotFoundError.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: BoxNotFoundError</title>

<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

<h1 class="page-title">Class: BoxNotFoundError</h1>






<section>

<header>

<h2><span class="attribs"><span class="type-signature"></span></span>BoxNotFoundError<span class="signature">(message)</span><span class="type-signature"></span></h2>

<div class="class-description">Thrown with { code: 404 } when a box was not found in DB.</div>


</header>

<article>
<div class="container-overview">




<h2>Constructor</h2>



<h4 class="name" id="BoxNotFoundError"><span class="type-signature"></span>new BoxNotFoundError<span class="signature">(message)</span><span class="type-signature"></span></h4>














<h5>Parameters:</h5>


<table class="params">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>message</code></td>


<td class="type">


<span class="param-type">string</span>



</td>





<td class="description last"></td>
</tr>


</tbody>
</table>






<dl class="details">


























<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_errors.js.html">lib/errors.js</a>, <a href="lib_errors.js.html#line14">line 14</a>
</li></ul></dd>







</dl>



















</div>




















</article>

</section>




</div>

<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-decoding.html">decoding</a></li><li><a href="module-decoding_debug.html">decoding/debug</a></li><li><a href="module-decoding_helpers.html">decoding/helpers</a></li><li><a href="module-decoding_lora-serialization.html">decoding/lora-serialization</a></li><li><a href="module-decoding_sensebox_home.html">decoding/sensebox_home</a></li><li><a href="module-routes_v1_1.html">routes/v1_1</a></li></ul><h3>Classes</h3><ul><li><a href="BoxNotFoundError.html">BoxNotFoundError</a></li><li><a href="DecodingError.html">DecodingError</a></li><li><a href="LoraError.html">LoraError</a></li><li><a href="PayloadError.html">PayloadError</a></li><li><a href="TTNError.html">TTNError</a></li></ul><h3>Global</h3><ul><li><a href="global.html#boxFromDevId">boxFromDevId</a></li><li><a href="global.html#createLogger">createLogger</a></li><li><a href="global.html#getOrRegisterDevice">getOrRegisterDevice</a></li><li><a href="global.html#initApp">initApp</a></li><li><a href="global.html#initMqtt">initMqtt</a></li></ul>
</nav>

<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sat Dec 02 2017 19:42:50 GMT+0100 (CET)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
Loading