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] Add TTS (The Things Stack) / TTN (The Things Network) decoder #81

Merged
merged 2 commits into from
May 8, 2023

Conversation

amotl
Copy link
Member

@amotl amotl commented Jan 19, 2022

Dear @thiasB, @MKO1640, @einsiedlerkrebs, @ClemensGruber, and @u-l-m-i,

following up on GH-8, and attaching to your requests at [1] ff., this patch adds a basic decoder for TTS/TTN v3 Uplink Messages [2], submitted using Webhooks [3].

It will also have a dedicated documentation page within the "Channel decoders" section [4], with a short but concise walkthrough tutorial how to configure a corresponding webhook within the TTS/TTN console, like [5].

You can invoke the specific test cases related to TTN after checking out the referenced branch by running those commands within the toplevel directory of the repository in two different terminals.

make start-foundation-services
source .venv/bin/activate
pytest -m ttn

With kind regards,
Andreas.

[1] https://community.hiveeyes.org/t/ttn-daten-an-kotori-weiterleiten/1422/34
[2] https://www.thethingsindustries.com/docs/reference/data-formats/#uplink-messages
[3] https://www.thethingsindustries.com/docs/integrations/webhooks/
[4] https://getkotori.org/docs/handbook/decoders/
[5] https://www.thethingsindustries.com/docs/integrations/webhooks/creating-webhooks/

P.S.: While this only implements the decoder part on the first iteration, it will be expanded, for example into a full-fledged multi-tenant forwarder implementation, on behalf of a subsequent iteration at GH-132.

@thiasB
Copy link
Contributor

thiasB commented Apr 29, 2022

What else is needed. Would you like to do some more testing?

@amotl
Copy link
Member Author

amotl commented May 25, 2022

Dear @thiasB,

thank you for the heads up. I hope to be able to follow up on this soon. It needs additional thinking if the patch already covers what we are aiming at and then some testing and polishing, including corresponding documentation.

With kind regards,
Andreas.

Comment on lines 22 to 36
@staticmethod
def decode(payload: str):

# Decode from JSON.
message = json.loads(payload)

# Use timestamp and decoded payload.
data = OrderedDict()
data["timestamp"] = message["received_at"]
data.update(message["uplink_message"]["decoded_payload"])

# TODO: Add more data / metadata.
# This is an implementation from scratch. It can be improved by
# cherry-picking more specific decoding routines from `ttnlogger`.
# https://github.com/daq-tools/ttnlogger
Copy link
Member Author

@amotl amotl May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thiasB: This is the gist of decoding TTN uplink messages which would then happen inside Kotori. I can remember that you contributed crafting an advanced version of this within ttnlogger the other day, right?

So, when we are aiming to get en par with the implementation from ttnlogger, we would need to fill some gaps here within a subsequent iteration.

@amotl amotl changed the title Add TTS (The Things Stack) / TTN (The Things Network) decoder adapter Add TTS (The Things Stack) / TTN (The Things Network) decoder May 7, 2023
@codecov
Copy link

codecov bot commented May 7, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.14 🎉

Comparison is base (ea4981e) 52.69% compared to head (fe6aaa7) 52.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
+ Coverage   52.69%   52.84%   +0.14%     
==========================================
  Files          99      100       +1     
  Lines        5224     5240      +16     
==========================================
+ Hits         2753     2769      +16     
  Misses       2471     2471              
Flag Coverage Δ
unittests 52.84% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
kotori/daq/decoder/__init__.py 96.87% <100.00%> (+0.57%) ⬆️
kotori/daq/decoder/tts_ttn.py 100.00% <100.00%> (ø)
kotori/daq/services/mig.py 86.36% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@amotl
Copy link
Member Author

amotl commented May 7, 2023

What else is needed. Would you like to do some more testing?

I just added a corresponding documentation section with fe6aaa7, and I think it will be fine now for a first iteration. Let me know if you can spot any errors, or where you see opportunities for improvements 1.

Footnotes

  1. I also just invited you as a member to the daq-tools organization, so it's easier to add you as a reviewer on corresponding, TTN-related patches for Kotori.

@amotl amotl marked this pull request as ready for review May 7, 2023 21:58
@amotl amotl changed the title Add TTS (The Things Stack) / TTN (The Things Network) decoder [TTN] Add TTS (The Things Stack) / TTN (The Things Network) decoder May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants