Container and command protocol layers for BLE RPC
Project description
blerpc-protocol
BLE RPC protocol library for Python and C.
Part of the bleRPC project.
Overview
Python and C implementation of the bleRPC binary protocol:
- Container fragmentation and reassembly with MTU-aware splitting
- Command packet encoding/decoding with protobuf payload support
- Control messages (timeout, stream end, capabilities, error)
- Encryption layer — E2E encryption with X25519 key exchange, Ed25519 signatures, and AES-128-GCM
The Python and C implementations are fully compatible and share the same wire format.
Installation
pip install blerpc-protocol
Usage
from blerpc_protocol import ContainerSplitter, ContainerAssembler, CommandPacket, CommandType
# Encode a command
packet = CommandPacket(CommandType.REQUEST, "Echo", protobuf_bytes)
payload = packet.serialize()
# Split into BLE-sized containers
splitter = ContainerSplitter(mtu=247)
containers = splitter.split(payload)
# Send containers over BLE, then reassemble on the other side
assembler = ContainerAssembler()
for container in received_containers:
result = assembler.feed(container)
if result is not None:
response = CommandPacket.deserialize(result)
Encryption
The library provides E2E encryption using a 4-step key exchange protocol (X25519 ECDH + Ed25519 signatures) and AES-128-GCM session encryption.
from blerpc_protocol.crypto import central_perform_key_exchange, BlerpcCryptoSession
# Perform key exchange (central side)
session = await central_perform_key_exchange(send=ble_send, receive=ble_receive)
# Encrypt outgoing commands
ciphertext = session.encrypt(plaintext)
# Decrypt incoming commands
plaintext = session.decrypt(ciphertext)
C Library
The C implementation is a Zephyr module with zero external dependencies. Add it to your west.yml manifest:
- name: blerpc-protocol
url: https://github.com/tdaira/blerpc-protocol
revision: main
path: modules/lib/blerpc-protocol
Headers are in c/include/blerpc_protocol/. See container.h, command.h, and crypto.h for the API.
Requirements
- Python 3.11+
License
Project details
Release history Release notifications | RSS feed
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 blerpc_protocol-0.8.0.tar.gz.
File metadata
- Download URL: blerpc_protocol-0.8.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d1ecfc4c72c31b5fd8eb84dff24bcf1609f0620c859f38227236154cc90f37d
|
|
| MD5 |
01ca48ec465c358ae9ffedf9b6bdf194
|
|
| BLAKE2b-256 |
d1925f24b29ed674ca1f609a21f450ee861cc80faf7991c30bcb8631b10ecbf8
|
Provenance
The following attestation bundles were made for blerpc_protocol-0.8.0.tar.gz:
Publisher:
publish.yml on tdaira/blerpc-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blerpc_protocol-0.8.0.tar.gz -
Subject digest:
7d1ecfc4c72c31b5fd8eb84dff24bcf1609f0620c859f38227236154cc90f37d - Sigstore transparency entry: 2070523576
- Sigstore integration time:
-
Permalink:
tdaira/blerpc-protocol@733a6b03d21e69bd80351eac17dc4b983fd0c48f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tdaira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@733a6b03d21e69bd80351eac17dc4b983fd0c48f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file blerpc_protocol-0.8.0-py3-none-any.whl.
File metadata
- Download URL: blerpc_protocol-0.8.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
996800765e969189c1cc8eb8ddb1c7df1f8fc0779f54bd8f7c0b209093f7d129
|
|
| MD5 |
166bb7f5144bac1dcfd63307ba6055a7
|
|
| BLAKE2b-256 |
7c124198a9e92e3b768c27c3f1804d9fe4581e13e2a66f310f64a4b5f1fb2f05
|
Provenance
The following attestation bundles were made for blerpc_protocol-0.8.0-py3-none-any.whl:
Publisher:
publish.yml on tdaira/blerpc-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blerpc_protocol-0.8.0-py3-none-any.whl -
Subject digest:
996800765e969189c1cc8eb8ddb1c7df1f8fc0779f54bd8f7c0b209093f7d129 - Sigstore transparency entry: 2070523685
- Sigstore integration time:
-
Permalink:
tdaira/blerpc-protocol@733a6b03d21e69bd80351eac17dc4b983fd0c48f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tdaira
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@733a6b03d21e69bd80351eac17dc4b983fd0c48f -
Trigger Event:
workflow_dispatch
-
Statement type: