No description
Find a file
Tobias Brunner c66409e3f3
All checks were successful
Build Main Branch / Build Docker Image (push) Successful in 1m27s
Fix TTN MQTT message structure
MQTT payload is ApplicationUp directly, not wrapped in "data"
object like webhook format. Remove the extra nesting level.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 18:08:51 +01:00
.forgejo/workflows specify ko version 2025-12-23 22:24:05 +01:00
docs/plans Add ttntrackit design document 2025-12-23 22:02:40 +01:00
.gitignore Add configurable log level 2025-12-23 22:30:23 +01:00
.ko.yaml Implement TTN to Reitti bridge 2025-12-23 22:11:03 +01:00
go.mod Implement TTN to Reitti bridge 2025-12-23 22:11:03 +01:00
go.sum Implement TTN to Reitti bridge 2025-12-23 22:11:03 +01:00
main.go Fix TTN MQTT message structure 2025-12-25 18:08:51 +01:00
README.md Add configurable log level 2025-12-23 22:30:23 +01:00

ttntrackit

A simple Go service that connects to The Things Network via MQTT, receives GPS data from wisnode trackit devices, and forwards locations to Reitti.

Configuration

Environment variables:

Variable Description Example
TTN_MQTT_SERVER TTN MQTT broker address eu1.cloud.thethings.network:8883
TTN_APP_ID TTN application ID my-trackit-app
TTN_API_KEY TTN API key for MQTT access NNSXS.xxxxx
REITTI_URL Reitti instance URL https://reitti.example.com
DEVICE_TOKENS Device to Reitti token mapping white1:token-aaa,black1:token-bbb
LOG_LEVEL Log level (debug, info, warn, error) info (default)

Build

Requires ko:

# Build locally
ko build ./ --local

# Build and push to registry
KO_DOCKER_REPO=git.tbrnt.ch/tobru/ttntrackit ko build ./ --bare --tags latest

Run

docker run -e TTN_MQTT_SERVER=eu1.cloud.thethings.network:8883 \
           -e TTN_APP_ID=my-app \
           -e TTN_API_KEY=NNSXS.xxxxx \
           -e REITTI_URL=https://reitti.example.com \
           -e DEVICE_TOKENS=white1:token-aaa,black1:token-bbb \
           git.tbrnt.ch/tobru/ttntrackit:latest

How it works

  1. Connects to TTN MQTT broker
  2. Subscribes to uplink messages for configured application
  3. Parses incoming GPS data from trackit devices
  4. Filters out messages without GPS fix (fix != 1)
  5. Forwards locations to Reitti's /api/v1/ingest/owntracks endpoint
  6. Logs all activity to stdout in JSON format