Skip to main content

Introduction

Documentation Status Discord Build Status

_bleio for Blinka based on bleak and bluez.

Dependencies

This driver depends on:

It optionally also depends on these Debian packages not install on Raspbian by default:

  • bluez-hcidump

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-blinka-bleio

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-blinka-bleio

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-blinka-bleio

Support for Duplicate Advertisement scanning on Linux

The regular Linux kernel bluez driver is set up to suppress multiple advertisements sent from the same BLE device. As of this writing, this cannot be changed. If you are using BLE advertisements to send changing data that you retrieve by scanning, the de-duplication can cause you to lose data when scanning via bleak.

To get around this problem, this library can instead look at raw BLE scanning data using the hcidump and hcitool tools and avoid going through the kernel driver. But this requires special setup.

Normally, only root has enough privileges to do see the raw scanning data. Since running as root is dangerous, you can instead use Linux capabilities to grant hcitool and hcidump raw network access. This is very powerful and not something to do casually. To limit access we recommend you change file execution permissions to restrict this capability to users in the bluetooth group.

If you are not using advertising to transmit changing data, you do not need to add these permissions. This library falls back to using bleak for regular scanning if hcitool does not have these extra permissions.

If you explicitly want to choose the backend to ensure consistent behavior, you can do the following:

ble = BLERadio()
ble._adapter.ble_backend = "bleak" # Forces bleak even if hcitool works.
# ble._adapter.ble_backend = "hcitool" # Forces hcitool. Raises exception if unavailable.

To add yourself to the bluetooth group do:

sudo usermod -a -G bluetooth <your username>

You must then logout and log back in to be in the new group.

To set permissions on hcitool and hcidump do:

sudo chown :bluetooth /usr/bin/hcitool /usr/bin/hcidump
sudo chmod o-x /usr/bin/hcitool /usr/bin/hcidump
sudo setcap 'cap_net_raw,cap_net_admin+eip' /usr/bin/hcitool
sudo setcap 'cap_net_raw,cap_net_admin+eip' /usr/bin/hcidump

Usage Example

Do not use this library directly. Use CircuitPython BLE instead: https://github.com/adafruit/Adafruit_CircuitPython_BLE/

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

Troubleshooting

Raspberry Pi 3b Rev 1.2

The Raspberry Pi 3b’s BLE chip is connected over UART to the main processor without flow control. This can cause unreliability with BLE. To improve reliability, we can slow the UART. To do so, edit /usr/bin/btuart and replace the 921600 with 460800.

Metadata

Release files for adafruit-blinka-bleio 4.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adafruit-blinka-bleio 4.1.2
File Size Uploaded
adafruit-blinka-bleio-4.1.2.tar.gz 45.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adafruit-blinka-bleio 4.1.2
File Interpreter ABI Platform
adafruit_blinka_bleio-4.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 71.2 kB

Release files / adafruit-blinka-bleio-4.1.2.tar.gz

Download URL adafruit-blinka-bleio-4.1.2.tar.gz
Size 45.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4fb2bab1984a827e28e09e518d3e6777689566eb96d2d00ce14f596c10937fa3
BLAKE2b-256 checksum
How to use checksums
d558c955780ace5c7a98f6da44a0d54fbfa3d55a053927e635dd85977bc40e92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / adafruit_blinka_bleio-4.1.2-py3-none-any.whl

Download URL adafruit_blinka_bleio-4.1.2-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4e21ed7072d05e86261c69b43c72b050c3d8b1b3297b6c71b36292ffbfc3275
BLAKE2b-256 checksum
How to use checksums
9705b5fa1fcc4cc68bda4bd317cb60a826eef753d9ab8efcd2d28fbcc7d60dd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

4.1.2 This release

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.1

1 release file

2.2.0

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.8.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page