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
  • Data model classes for location and sensor data
  • Packet classes for telemetry, configuration, power on, motion start/stop
  • 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 (
    LocationData, SensorDataBasic, TelemetryPacket,
)

imei = "358419511056392"
loc = LocationData.gnss(52.5200, 13.4050)
sensor = SensorDataBasic(sensor_type=1, temperature=21.5, battery=95, rssi=30)
tele = TelemetryPacket(imei=imei, timestamp=1724900000, transaction_id=1, location_data=loc, sensor_data=sensor)
packet_bytes = tele.to_bytes()
print(packet_bytes.hex())

API Overview

  • encoding.encode_var_string(str) -> bytes
  • decoder.PacketDecoder.parse_response_data(str)
  • decoder.PacketDecoder.decode_packet_header(hex_str)
  • decoder.DataReader for reading from bytes
  • data.LocationData (gnss/cell)
  • data.SensorData, data.SensorMultiData, data.NullSensorData, data.MotionSensorData
  • packets.Packet base + TelemetryPacket, ConfigPacket, PowerOnPacket, MotionStartPacket, MotionStopPacket

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.1.1.tar.gz (9.3 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.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: compact_binary_protocol-0.1.1.tar.gz
  • Upload date:
  • Size: 9.3 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.1.1.tar.gz
Algorithm Hash digest
SHA256 d7218475b1fdd5bdbed9891f607f9d6dbe02335a4de9d6ec34bb1db0199332aa
MD5 4fc5217240a1138bb1571af6e2853924
BLAKE2b-256 0d8fd66b3e900493fb850fccc6a3735faafb104759867b6134d5dd3fc1a959da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for compact_binary_protocol-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1c8f4c0921c03b6b80c65cc05249d32eead4f3a5e14c7b32abb7372ab6580e1
MD5 4112cc241ac719a31f9c8855a0a52153
BLAKE2b-256 00ef364c2cf2211e96a33d12b0367c71cd22ca26037a7ab5cd3779d8d7593073

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