sensebox / ttn-osem-integration

integration for thethingsnetwork.org to opensensemap.org
MIT License
6 stars 3 forks source link

TTN MQTT & device management (#8) #13

Open noerw opened 6 years ago

noerw commented 6 years ago

implements the feature that was suggested in #8. Also featuring a rewrite of error handling code

Things to consider (@ubergesundheit):

TODO

ubergesundheit commented 6 years ago

Just pushed a docker image of this branch to sensebox/ttn-osem-integration:feature_mqtt

ubergesundheit commented 6 years ago

Running the image results in a Cannot find module babel-runtime/regenerator error


> ttn-osem-integration@1.0.0 start /usr/src/app
> node lib/index.js | bunyan -o short

module.js:471
    throw err;
    ^

Error: Cannot find module 'babel-runtime/regenerator'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/node_modules/ttn/dist/index.js:8:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/lib/ttn.js:6:36)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
noerw commented 6 years ago

I have this dependency in node_modules on my local installation.. sigh, shouldn't yarn.lock protect us from stuff like this?

See https://github.com/TheThingsNetwork/node-app-sdk/commit/e1eca3f41a820338e81092a0ea200341e09143eb, it seems the babel people (™) have messed with semver or something. Instead of adding this dependency here, lets use the ttn beta release for now, it only contains changes from my PR anyway.

noerw commented 6 years ago

Also, I can finally test this with actual LoRa hardware in the next days. Will add end-to-end tests then

ubergesundheit commented 6 years ago

Very good! There is an additional error related to alpine/muslibc/glibc for the dependency grpc of the ttn package..

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/app/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64/grpc_node.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/node/src/client.js:38:12)
noerw commented 6 years ago

@ubergesundheit Hey, this is ready, implementation wise. For these changes to be useful, they have to be integrated with the main API. I cannot do that atm, due to lack of time and understanding of the new package architecture.

If required I can add comprehensive documentation on the required changes, a short list is in the TODO at the top of this PR already.

ubergesundheit commented 6 years ago

Alright! Are there any changes to the angular app needed?

noerw commented 6 years ago

yeah. the user should be able to select between his own TTN device with http integration (current solution), or the auto-creation of a device with our application. If he chooses the latter, he may provide an dev_eui, and gets the lora keys (otaa and abp?) back in the completed registration overview.

noerw commented 6 years ago

alternatively, a full integration with a Lora sketch containing the Lora keys comes to mind. would this be feasible, or does the lora hardware require custom solutions anyway?

ubergesundheit commented 6 years ago

With the new senseBox MCU in the pipeline, a LoRa Bee addon is planned. The generation of a full working sketch should be possible then.