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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compact_binary_protocol-0.3.0.tar.gz.
File metadata
- Download URL: compact_binary_protocol-0.3.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0cb9e6d137abfbbf6b22a3f6ed7bfebf5f823d3576e47cb4816ebf098c7ce76
|
|
| MD5 |
61caa2c120efebd9ce4150f76edfd9b8
|
|
| BLAKE2b-256 |
c67b2ca5af7dd1fc13dee2ccb33cdc16c47864a486f509dfac4096b7d1caa7ff
|
File details
Details for the file compact_binary_protocol-0.3.0-py3-none-any.whl.
File metadata
- Download URL: compact_binary_protocol-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c8af48d9e372671fa8e93c331afad3ef5bbff31d8a02125fe7fa86deb1cda2
|
|
| MD5 |
da08e4410046a2d09b4315926db54b1f
|
|
| BLAKE2b-256 |
08acc65520e4e8f649630effbb785ca983a7dfe5431461e7580af68e9f966ff4
|