Skip to main content

Bluetooth Low Energy platform Agnostic Klient

Project description

Build and Test https://img.shields.io/pypi/v/bleak.svg PyPI - Downloads Documentation Status https://img.shields.io/badge/code%20style-black-000000.svg

Bleak is an acronym for Bluetooth Low Energy platform Agnostic Klient.

Bleak is a GATT client software, capable of connecting to BLE devices acting as GATT servers. It is designed to provide a asynchronous, cross-platform Python API to connect and communicate with e.g. sensors.

Installation

$ pip install bleak

Features

  • Supports Windows 11, version 22000 and greater

  • Supports Linux distributions with BlueZ >= 5.55

  • OS X/macOS support via Core Bluetooth API, from at least OS X version 10.15

  • Android backend compatible with python-for-android

Bleak supports reading, writing and getting notifications from GATT servers, as well as a function for discovering BLE devices.

Usage

To discover Bluetooth devices that can be connected to:

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d)

asyncio.run(main())

Connect to a Bluetooth device and read its model number:

import asyncio
from bleak import BleakClient

address = "24:71:89:cc:09:05"
MODEL_NBR_UUID = "2A24"

async def main(address):
    async with BleakClient(address) as client:
        model_number = await client.read_gatt_char(MODEL_NBR_UUID)
        print(f"Model Number: {model_number.decode()}")

asyncio.run(main(address))

DO NOT NAME YOUR SCRIPT bleak.py! It will cause a circular import error.

See examples folder for more code, for instance example code for connecting to a TI SensorTag CC2650

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

bleak-3.0.2.tar.gz (125.3 kB view details)

Uploaded Source

Built Distribution

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

bleak-3.0.2-py3-none-any.whl (146.5 kB view details)

Uploaded Python 3

File details

Details for the file bleak-3.0.2.tar.gz.

File metadata

  • Download URL: bleak-3.0.2.tar.gz
  • Upload date:
  • Size: 125.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bleak-3.0.2.tar.gz
Algorithm Hash digest
SHA256 c2229cb8238d5876b4bd05c74bf7a1aea1f88da39d2e51ac9dfd5cc319d5265f
MD5 0e9fc5ca42eaa90f0aa99f6d2b941533
BLAKE2b-256 16df05a3f80ca8e3f7f5b0dba68a9e618147c909ccdba1468f07487dc8d72a9d

See more details on using hashes here.

File details

Details for the file bleak-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: bleak-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 146.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bleak-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39092feb9e83f1df5ad2f88e837723c7211c982ce9e9cda6235104bc2ebe0d0d
MD5 7220fd4fd46f08cdd67164e5929b3b0b
BLAKE2b-256 265405aceb9cd80073805b3ed8522e3196e8cb22f70e741873fa51406c31f4e7

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