sensebox / ttn-osem-integration

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

full integration via TTN api & MQTT #8

Open noerw opened 7 years ago

noerw commented 7 years ago

I discovered that it is possible to automate device registration and LoRa-message subscription via APIs provided by TTN. This would free the user from the hassle of registering at 2 services, and keep the configuration state in sync. The current webhook could still be provided for users with existing TTN applications, sending data via the TTN HTTP Integration.

proposed workflow

  1. user provides TTN config at oSeM (decoding profile + options only?)
  2. oSeM pushes notification to ttn-osem-integration (or ttn-osem-integration polls for changes)
  3. ttn-osem-integration creates new device in TTN
  4. ttn-osem-integration subscribes to new device, and decodes as is implemented so far
noerw commented 7 years ago

Possible issue is authentication; how is ensured that only the correct physical LoRa device can submit measurements? Assuming we choose app_id = 'opensensemap' and dev_id = box._id for all boxes, these IDs are no secrets, and would allow anybody to submit measurements via LoRa.

idea: set dev_id = box._id + randomSalt()

ubergesundheit commented 7 years ago

The integration is a really good idea! The the random String for identifying the senseBox is also a good idea for the main API

noerw commented 6 years ago

Progress can be found on branch feature/mqtt:

The integration now has its own TTN application, on which devices can be registered. This registration is done by calling /v1.1/ttndevice/:boxId, which then returns TTN device information for a given box. This info can then be used to generate a sketch for example.

A subscription to messages from devices that were registered using this route is automatically set up via TTN MQTT broker.

TODOs: