Protobuf + TTN

In case anyone else is interested in using protobuf definitions for their messages, I compiled a sample repository that shows the end-to-end usage

Protofile → Arduino files → OTW → TTN console → Validate/Decode/Convert (& Encode)

The sample repo is here: GitHub - thesolarnomad/ttn-proto-utils: The Things Network utilities for protobuf

It uses a docker file that comes preloaded with all the tools needed: GitHub - thesolarnomad/platformio-sodaqsamd-node: Docker image for PlatformIO + SODAQ SAMD + Node and it uses another project GitHub - thesolarnomad/ttn-proto-generator: Generator for TTN decoder, validator and converter functions from a given .proto descriptor for generating the TTN function files.

cc @htdvisser @johan

1 Like

Very cool!!

So I see two steps forward from here, not necessarily depending on each other:

  1. Add a story using this to The Things Network Labs: https://www.thethingsnetwork.org/labs
  2. See if we can get this integrated in the Handler. As we use Go there, a compiled language, we can’t really dynamically (de)serialise protobufs, unless I’m not aware of a package that does this in memory. So then, we’d need to use a standardised message format, like Cayenne LPP, with optional fields.

What do you think?

  1. happy to write a labs story - are there specific rules?
  2. The payload functions I generate are pure JS, self-contained and Otto-compatible, so they can be used out of the box with the current console. No need for Go. I think we could integrate it in a way that you can upload a proto file and it populates the payload functions for you - we would even be able to make them much smaller as we could preload protobuf.js into the execution chain of Otto if that was favorable.
2 Likes

Hi @joscha oscha

How far did you come with this? I’m currently trying https://github.com/thesolarnomad/ttn-proto-utils but fail with

TypeError: yargs.usage(...).describe(...).describe(...).describe(...).demandOption is not a function
at Object.<anonymous> (C:\Users\nid\AppData\Roaming\npm\node_modules\ttn-proto-generator\index.js:14:6)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

and can’t figure out what’s going wrong.

Can you give some advice?

Best regards
Dieter