Skip to main content

A library implementing a compact binary protocol

Project description

compact-binary-protocol

A small, self-contained Python library that defines the compact binary protocol used by Tartabit client components.

Features:

  • Encoding helpers (VarString, etc.)
  • Data model classes for typed data items (DataLocation, DataMulti, DataKv, ...)
  • Packet classes for telemetry, configuration (server→device), and update requests/status
  • Decoding helpers for responses and header parsing

All multi-byte values are encoded using big-endian format.

Install (pypi)

To install the package from PyPI, run:

pip install compact-binary-protocol

Install (local)

This repository is part of a monorepo. To use the library from adjacent components, import it directly via the package name compact_binary_protocol (no installation step needed if package path is in PYTHONPATH). For packaging, add a minimal pyproject or install in editable mode:

pip install -e ./compact-binary-protocol

Quick start

from compact_binary_protocol import (
    DataMulti, TelemetryPacket,
)

imei = "358419511056392"
item = DataMulti(
    battery=95,
    rssi=30,
    first_timestamp=1724900000,
    interval=60,
    records=[{"temperature": 21.5, "humidity": 40.0}]
)
tele = TelemetryPacket(imei, 1724900000, 1, 'T', item)
packet_bytes = tele.to_bytes()
print(packet_bytes.hex())

API Overview

  • encode_var_string(str) -> bytes
  • PacketDecoder.parse_response_data(str)
  • PacketDecoder.decode_packet_header(hex_str) -> (version, command, transaction_id, remainder_bytes)
  • DataReader for reading from bytes
  • DataLocation (gnss/cell)
  • DataBasic, DataMulti, DataNull, DataSteps, DataVersions, DataNetworkInfo, DataCustomerId, DataKv
  • Packets: Packet (base), TelemetryPacket, ConfigPacket (server→device body decoder)

Building

To build the package, run the following command:

pip install build twine
python -m venv .venv
. venv/bin/activate
python -m build
twine upload dist/*

License

Copyright 2024-2025 Tartabit, LLC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compact_binary_protocol-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compact_binary_protocol-0.2.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file compact_binary_protocol-0.2.0.tar.gz.

File metadata

  • Download URL: compact_binary_protocol-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for compact_binary_protocol-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a5a658c6e7ce99cd70a0e77c171d536bdc42c156340c8fc8749dc067bef71d49
MD5 3d75f7e76b138290ec2d5e8cf6397a01
BLAKE2b-256 56343188ded95935c99508fa8c779df77eda017d7307818e2fb4bdf6f8fea3e4

See more details on using hashes here.

File details

Details for the file compact_binary_protocol-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for compact_binary_protocol-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 785184b2050d4d4d3f0f6be4c5d749cd664b3940105e2ae6bec8e2cc8465ddbb
MD5 ce76fe61f4e6e8ca4c7427f4b79dae75
BLAKE2b-256 fbd1d3b00529e22474900411fb4b484bc619cb2c62b508bd348fb2d16ba03f93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page