Skip to main content

BLE library for the BlueRetro retro-console Bluetooth adapter

Project description

BlueRetro

blueretro-ble

Tests PyPI Python License: MIT

Pure-Python BLE library for the BlueRetro retro-console Bluetooth adapter. Talks to the BlueRetro GATT server via bleak + bleak-retry-connector (connect → read/write → disconnect).

Powers the BlueRetro Home Assistant integration.

Install

pip install blueretro-ble

Usage

from blueretro_ble import BlueRetroDevice, supports

# `supports(advertisement)` is a discovery predicate: True if a BLE
# advertisement (anything exposing `.name` and `.service_uuids`) looks
# like a BlueRetro adapter.

device = BlueRetroDevice()
state = await device.async_update(ble_device)  # a bleak BLEDevice
print(state.fw_version, state.game_id, state.game_name)

await device.async_reboot(ble_device)
await device.async_deep_sleep(ble_device)

async_update connects, reads ABI/firmware/BD-address directly, runs the command-then-read cycles (game id, config source, firmware name), reads the global config (system/multitap/inquiry/card bank), resolves the game name from the bundled gameid.db, always disconnects, and never raises — on failure it returns a BlueRetroState(available=False).

CLI

Installing the package provides a blueretro command (also python -m blueretro_ble):

blueretro scan                       # list nearby adapters
blueretro info AA:BB:CC:DD:EE:FF     # connect and print the full state
blueretro reboot AA:BB:CC:DD:EE:FF
blueretro sleep AA:BB:CC:DD:EE:FF

Notes

  • The adapter only accepts connections while idle (no controller connected). During gameplay, connections fail and async_update returns an unavailable state.
  • gameid.db is a SQLite database (games(id TEXT, name TEXT)) bundled with the package, sourced from darthcloud/BlueRetroWebCfg.
  • The BLE protocol is reverse-engineered from the official web config; verify cfg_src (0x05) against real hardware.

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ".[test]"
pytest

License

MIT

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

blueretro_ble-0.4.0.tar.gz (345.2 kB view details)

Uploaded Source

Built Distribution

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

blueretro_ble-0.4.0-py3-none-any.whl (273.8 kB view details)

Uploaded Python 3

File details

Details for the file blueretro_ble-0.4.0.tar.gz.

File metadata

  • Download URL: blueretro_ble-0.4.0.tar.gz
  • Upload date:
  • Size: 345.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blueretro_ble-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1021f347f99e02a57ca03306bd7aac7da336a7bc5cb8bac9af2b93911dc4cef6
MD5 e1baeeb5f57e59c6abbb3bd6fbdef3ce
BLAKE2b-256 5ed2ab83f242ad9a2f4493f11240de6367a0d19c9cdd22a577f2d1f4e62ca055

See more details on using hashes here.

Provenance

The following attestation bundles were made for blueretro_ble-0.4.0.tar.gz:

Publisher: publish.yml on hudsonbrendon/blueretro-ble

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

File details

Details for the file blueretro_ble-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: blueretro_ble-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 273.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blueretro_ble-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71ba83c5a0524d6c0bf4df513e046cc8c5d25d86078182f785ccd74930bbe17e
MD5 3e83631e9eae7234d27b178815de2a25
BLAKE2b-256 12ae1151809c7c331d7c241434c6db5e4e7d01cbe3ecd705ad6e1c889523f7a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for blueretro_ble-0.4.0-py3-none-any.whl:

Publisher: publish.yml on hudsonbrendon/blueretro-ble

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