Skip to main content

Headless Python client interfaces for BitChat bridges

Project description

python-bitchat-client

python-bitchat-client is a small, headless Python package for integrating with the BitChat BLE mesh protocol. It comes with a basic sample client application, but it's intended to be embedded and used by other tools.

It doesn't currently implement channel discovery.

What this package provides

  • A minimal client interface (BitChatClient) for:
    • starting/stopping BLE mesh connectivity
    • joining a channel (defaults to #mesh)
    • receiving inbound messages via callback
    • sending text messages to the current channel
    • receiving status telemetry (connected, disconnected, retries, errors)
  • A BLE implementation (BleBitChatClient) powered by bleak
  • A fallback no-op implementation (NullBitChatClient) when BLE backend is not available
  • Protocol helpers for packet parsing/building

Installation

You can install this package from pypi using pip install python-bitchat-client

Basic usage

from python_bitchat_client import create_client

client = create_client()
client.set_handle("crystal-jim")
client.join_channel("#mesh")

def on_message(msg):
    print(f"[{msg.channel}] <{msg.sender}> {msg.text}")

def on_status(status):
    print(f"[{status.level}] {status.code}: {status.detail}")

client.set_message_handler(on_message)
client.set_status_handler(on_status)
client.start()

ok = client.send_message("@crystal-jim say hello from python")
print("sent:", ok)

Interactive test harness

A simple terminal harness is included for manual send/receive testing.

Path:

  • examples/terminal_harness.py

Run from repository root:

uv run python examples/terminal_harness.py --handle my-handle --channel "#mesh"

# Verbose packet/transport debugging
uv run python examples/terminal_harness.py --handle my-handle --channel "#mesh" --log-level DEBUG

Harness commands:

  • Type any line and press Enter to send it to the channel
  • /quit or /exit to stop
  • /help to print command help
  • --log-level DEBUG to include package debug logs

Inbound channel messages are printed to stdout while the prompt remains active.

Runtime notes and permissions

  • This package does not require running your whole app as root.
  • BLE access depends on host Bluetooth policy.
  • On Linux, you typically need:
    • bluetoothd running
    • user permission to access BlueZ over D-Bus
    • distro-specific group/polkit setup

If no peer is found, the client reports status code no_peer_found and keeps retrying.

Status telemetry

Common status codes emitted by the BLE client:

  • starting
  • peer_found
  • connected
  • disconnected
  • no_peer_found
  • connect_failed
  • send_failed
  • stopped
  • backend_unavailable (fallback client)

Development

Run package-related tests from repository root:

uv run pytest tests/test_python_bitchat_client_protocol.py tests/test_python_bitchat_client_client.py

Set up pre-commit hooks:

uvx pre-commit install
uvx pre-commit run --all-files

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

python_bitchat_client-0.1.0.tar.gz (72.8 kB view details)

Uploaded Source

Built Distribution

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

python_bitchat_client-0.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_bitchat_client-0.1.0.tar.gz
  • Upload date:
  • Size: 72.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_bitchat_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e285499c5c6bca77bd9475ff1fd932b8440a2b71c0c220207a53294ca72b74c
MD5 2ab69a21688977dd9536141561aa7b7c
BLAKE2b-256 70c26cbeb034ba9d165b843d725a3b19c9093e3f82ac7bc78a8c664fc62535c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_bitchat_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_bitchat_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54ad6bea0440c8c94e6a24190aeb2a03eeff5bed76b64ceaaee1139b6ec447ed
MD5 eff6e7e9e65ba4fa4cf6bf77fb4634c7
BLAKE2b-256 00ed49f2154676b194e5883a654b4098ba4ec18f23c900915bf77e9941d6d99b

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