Skip to content

truvami/decoder

Repository files navigation

codecov

πŸŽ‰ truvami Decoder πŸš€

truvami Decoder is a command-line interface (CLI) tool written in Go for decoding truvami payloads. This reference implementation supports various payload types, including Nomad XS and different Tag formats. πŸ› οΈ

🎬 Demo

Check out this demo to see truvami Decoder in action! πŸ‘‡

Demo

🌟 Features

  • πŸ” Payload Decoding: Decode Nomad XS, Tag S/L, and Tag XL payloads with ease.
  • 🌐 HTTP Server: Start a local HTTP server to decode payloads using RESTful APIs.
  • πŸ“„ Flexible Output: Choose between standard console output and JSON format.
  • πŸ› οΈ Debugging & Verbosity: Enable debugging and verbose output for detailed insights.
  • πŸ–‹οΈ Autocompletion: Generate autocompletion scripts for your favorite shell.
  • πŸš€ Cross-Platform: Works on Windows, macOS, and Linux.

πŸ“¦ Installation

πŸ”§ Binaries

You can install the truvami Decoder binary easily using the following command:

# This will install the binary at $(go env GOPATH)/bin/decoder
curl -sSfL https://raw.githubusercontent.com/truvami/decoder/main/install.sh | sh -s -- -b $(go env GOPATH)/bin

# βœ… Verify the installation by checking the help
decoder --help

πŸ–₯️ Windows

For Windows users, you can install the truvami Decoder binary using Chocolatey:

# Install using Chocolatey
choco install truvami-decoder

# βœ… Verify the installation by checking the help
decoder --help

🐳 Docker

You can also run the truvami Decoder using Docker:

# Pull the latest Docker image
docker pull ghcr.io/truvami/decoder

# Run the Docker container
docker run -it ghcr.io/truvami/decoder decoder --help

# Run the Docker container to start the HTTP server
docker run -p 8080:8080 ghcr.io/truvami/decoder decoder http --port 8080 --host 0.0.0.0

πŸ› οΈ Usage

truvami Decoder provides a variety of commands and options to help you decode payloads efficiently. Below is an overview of the available commands and flags.

πŸ—‚οΈ Basic Command Structure

decoder [command] [flags]

πŸ“ Available Commands

  • completion - πŸ–‹οΈ Generate the autocompletion script for the specified shell.
  • help - ℹ️ Display help information about any command.
  • nomadxs - 🧩 Decode Nomad XS payloads.
  • tagsl - 🏷️ Decode Tag S / L payloads.
  • tagxl - 🏷️ Decode Tag XL payloads.
  • http - 🌐 Start local HTTP server to decode payloads.

🚩 Global Flags

  • -d, --debug - πŸ› Display debugging output in the console. (default: false)
  • -h, --help - ℹ️ Display help information.
  • -j, --json - πŸ“„ Output the result in JSON format. (default: false)
  • -v, --verbose - πŸ“’ Display more verbose output in the console. (default: false)

πŸ’‘ Example Usage

# πŸ” Decode a Nomad XS payload with verbose output
decoder nomadxs 1 0002c420ff005ed85a12b4180719142607240001ffbaffc2fc6f09a71d2e

# πŸ“ Decode a Tag S / L payload and output the result in JSON format
decoder tagsl 1 8002cdcd1300744f5e166018040b14341a -j

# 🌐 Start a HTTP server
decoder http --port 8080 --host 0.0.0.0

# πŸ“„ Call HTTP server using curl
curl -XPOST -H "Content-type: application/json" -d '{
    "port": 1,
    "payload": "8002cdcd1300744f5e166018040b14341a",
    "devEui": ""
}' 'http://localhost:8080/tagsl/v1'

# πŸ–‹οΈ Generate autocompletion script for bash
decoder completion bash

For more detailed information on each command, use:

decoder [command] --help