Skip to main content

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

Apache-2.0

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

blerpc_protocol-0.8.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

blerpc_protocol-0.8.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

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

Hashes for blerpc_protocol-0.8.0.tar.gz
Algorithm Hash digest
SHA256 7d1ecfc4c72c31b5fd8eb84dff24bcf1609f0620c859f38227236154cc90f37d
MD5 01ca48ec465c358ae9ffedf9b6bdf194
BLAKE2b-256 d1925f24b29ed674ca1f609a21f450ee861cc80faf7991c30bcb8631b10ecbf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for blerpc_protocol-0.8.0.tar.gz:

Publisher: publish.yml on tdaira/blerpc-protocol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file blerpc_protocol-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blerpc_protocol-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 996800765e969189c1cc8eb8ddb1c7df1f8fc0779f54bd8f7c0b209093f7d129
MD5 166bb7f5144bac1dcfd63307ba6055a7
BLAKE2b-256 7c124198a9e92e3b768c27c3f1804d9fe4581e13e2a66f310f64a4b5f1fb2f05

See more details on using hashes here.

Provenance

The following attestation bundles were made for blerpc_protocol-0.8.0-py3-none-any.whl:

Publisher: publish.yml on tdaira/blerpc-protocol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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