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 (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, SensorData, TelemetryPacket,
)

imei = "358419511056392"
loc = LocationData.gnss(52.5200, 13.4050)
sensor = SensorData(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:

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.0.tar.gz (7.0 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.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for compact_binary_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7b356a718ffb0854c92207305d77c4712553a1f53cc73ffdee9fe5071ebfe57a
MD5 f1c889bb309a11529a6a32c674959d7a
BLAKE2b-256 a62270b207e857561d1bdd9d793289158e9006dcb45e6752cae09e62865dcd65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for compact_binary_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ec391faa12267751612c526782819aab567bd61744cab01ad684e1c8fcaac42
MD5 f64db9034dabc697fbff8f1566c5ea77
BLAKE2b-256 49f0de030178f9104b4ceda84720fb786cccbeca16d423728ab26f3facd80e23

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