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 10, version 16299 (Fall Creators Update) or greater

  • Supports Linux distributions with BlueZ >= 5.55

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

  • 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("Model Number: {0}".format("".join(map(chr, model_number))))

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-1.0.1.tar.gz (115.1 kB view details)

Uploaded Source

Built Distribution

bleak-1.0.1-py3-none-any.whl (135.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bleak-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6177487c4eb08743a155e1295ff871eb2a61669b538bdbf35db45ea29cf7a41d
MD5 2a0a677214827b570415ca67f0fd59ab
BLAKE2b-256 d26484a97528641bf917d0213bb28a1dc0ced916836edc3e342e25c4e8b1a63b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bleak-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f99bcb2fb74950466622b1f932ab661c74dcd48a3d122e95b661aa0705e5a6a
MD5 9476934d204502e36f240ae34d7df0c1
BLAKE2b-256 079798ba9c8f645f0bf6648b4f5bd997170b3f794d9006c20fdbfe0096c803eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page