-
Notifications
You must be signed in to change notification settings - Fork 17
Description
About
Based on my thoughts shared at GH-132, I am trying to generalize a few new requirements around data acquisition from TTN into another design principle of Kotori. On this matter, I am thinking about finally adding a device-based addressing/endpoint scheme, additionally to the channel-based approach Kotori is offering from the very beginning.
Please note while referring to TTN and HTTP within this proposal, the functionality is meant to be generally available, also for MQTT-based data acquisition.
Relation to the TTN integration
In this way, we will have a more generic foundation to build upon, and can specialize it by adding specific concerns around TTN on top of it. From a different perspective, the TTN WAN support feature would not take any significant detour from what Kotori will be offering anyway.
Requirements recap
We identified two more sensible variants to submit measurement/metric/telemetry data to Kotori.
- Address information (device identifier) is encoded into the URL, but not using classic "URL path"-based semantics.
- Address information (device identifier) is encoded into the message payload, in whatever format that may be.
Proposal
So, my proposal to implement those variants would be to introduce a new endpoint infix, but not special to TTN, which would just be /d, which means "device". If this would be followed by a device identifier, the device identifier would be picked from the URL. When there is no device identifier, and the data will be submitted straight to the realm address, the machinery will attempt to decode it from the message payload.
Device identifier in URL
http:/api/{realm:mqttkit-1}/d/{device_id:.*}/{slot:data}
realm ....^^
special identifier "d" .....^
device identifier .............^^
well-known slot identifier "data" ............^^
Example:
# HTTP variant
https://daq.example.org/api/mqttkit-1/d/itest-foo-bar/data
# MQTT variant
mqttkit-1/d/itest-foo-bar/data.json
Device identifier in message payload
http:/api/{realm:mqttkit-1}/d/{slot:data}
realm ....^^
special identifier "d" .....^
well-known slot identifier ....^^
Example:
# HTTP variant
https://daq.example.org/api/mqttkit-1/data
# MQTT variant
mqttkit-1/data.json
Feature request
The original feature request from @thiasB is:
My idea is that the topic should be derived from the TTN
devIDviareplace(/-/g, '/') + "/data". It means that thedevIDmust have 4 components that correspond to the MQTT topic levels, separated by the-character instead of the/character, which is disallowed on that level. This has the advantage that you can put all your devices in the same TTN application, and still have control over the entire topic.-- https://community.hiveeyes.org/t/tts-ttn-daten-an-kotori-weiterleiten/1422/35
As it is only a proposal yet, I will be happy to take your thoughts into consideration.
/cc @einsiedlerkrebs, @thiasB, @u-l-m-i, @ClemensGruber, @wetterfrosch, @MKO1640