Skip to main content

No project description provided

Project description

bleep

A BLE abstraction layer for Python inspired by bleat. Currently only supports Linux, with experimental support for Mac OS X.

Current Support

  • Discovering devices
  • Reading advertising data
  • Connecting to devices
  • Discovering services, characteristics and descriptors
  • Read from characteristics

Installation

Linux

First, install my fork of pygattlib and its dependencies:

sudo apt-get install libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev

You should also make sure that your version of libbluetooth is at least 4.101:

apt-cache policy libbluetooth-dev | grep Installed

Then, clone the repository, and install the python package.

git clone https://github.com/matthewelse/pygattlib.git
cd pygattlib
sudo python setup.py install

This will build the dynamic library, and install the python package.

You can then install bleep easily:

sudo pip install bleep

If you want to develop bleep, instead of the last line, run:

sudo python setup.py develop

This will cause any changes you make to bleep to be reflected when you import the library.

NOTE: You may need to run all BLE code with sudo, even when using the Python interactive shell.

Mac OS X

Installation on Mac OS X is very simple:

brew install boost-python

git clone https://github.com/matthewelse/bleep.git
cd bleep
sudo python setup.py install

Likewise, if you would like to develop bleep, run this instead of the last line:

sudo python setup.py develop

Examples

tree.py

You can run tree.py to see all of the services, characteristics and descriptors attached to a device with a specific mac address. In order to find the device's mac address, you could use hcitool lescan, or use BLEDevice.discoverDevices().

usage: tree.py [-h] mac

Usage

Include bleep

>>> from bleep import BLEDevice

Scan for devices

>>> devices = BLEDevice.discoverDevices()
>>> devices
[Device Name:  (5A:79:8E:91:83:1C), Device Name:  (C1:20:68:1B:00:26), Device Name: BLE Keyboard (C9:E8:56:3B:4D:B1), Device Name:  (4C:25:F5:C2:E6:61), Device Name:  (60:03:08:B2:47:F1), Device Name:  (C1:62:3A:1D:00:14)]

This will return a list of Device objects, however you won't be connected to any of them, so pick one you like, and connect to it:

>>> device = devices[2]
>>> device.connect()

You can then access the device's services:

>>> device.services
[Generic Access, Generic Attribute, Device Information, Battery Service, Human Interface Device]

each service's characteristics

>>> service = device.services[4]
>>> service
Human Interface Device
>>> service.characteristics
[HID Information, Report Map, Protocol Mode, HID Control Point, Report, Report]

and each characteristic's descriptors

>>> char = service.characteristics[4]
>>> char
Report
>>> char.descriptors
[Client Characteristic Configuration, Report Reference]

Useful Functionality

BLEDevice.discoverDevices supports parameters which allow you to specify which BLE device to connect to (ignored on OSes other than Linux), how long to sample for, as well as a function which returns a boolean value, allowing you to cherry-pick your devices.

def discoverDevices(device='hci0', timeout=5, filter=lambda x: True)

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

bleep-0.5.tar.gz (25.2 kB view details)

Uploaded Source

Built Distributions

bleep-0.5-cp37-abi3-win_amd64.whl (600.4 kB view details)

Uploaded CPython 3.7+ Windows x86-64

bleep-0.5-cp37-abi3-win32.whl (529.3 kB view details)

Uploaded CPython 3.7+ Windows x86

bleep-0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

bleep-0.5-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.8 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

bleep-0.5-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.6 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

bleep-0.5-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.3 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

bleep-0.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

bleep-0.5-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (2.5 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.12+ i686

bleep-0.5-cp37-abi3-macosx_11_0_arm64.whl (869.7 kB view details)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

bleep-0.5-cp37-abi3-macosx_10_7_x86_64.whl (907.0 kB view details)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

File details

Details for the file bleep-0.5.tar.gz.

File metadata

  • Download URL: bleep-0.5.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.3

File hashes

Hashes for bleep-0.5.tar.gz
Algorithm Hash digest
SHA256 4cd42d6da52b13a844d59f7595652156691098f4486b45778b1e2284e6b4f31c
MD5 ada879ec10c0b2df5d436a5c1e4e014a
BLAKE2b-256 7d869bed7e9ccc929105fe3006be70b4a6a47a1a0895488d491bc36fb5fccda3

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: bleep-0.5-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 600.4 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.3

File hashes

Hashes for bleep-0.5-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 251e735297954358ba62c1415c50b2fd68e97ad3a80ac7fac7ecdc342afeaa6e
MD5 07a613a4a7670b899f1cc0da4c80af9d
BLAKE2b-256 4c84ce8395eeb6c5fcf21321d3f3e44870ce21d456fb92ed1c37618748f4e1aa

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-win32.whl.

File metadata

  • Download URL: bleep-0.5-cp37-abi3-win32.whl
  • Upload date:
  • Size: 529.3 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.3

File hashes

Hashes for bleep-0.5-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 f8400fbe71d279c635e1d65db00fdd5da1283cfa1cceac6a8af54d3f80a77eb9
MD5 67550abd361aca48dedcbe3c51c2eb15
BLAKE2b-256 a29a5fea9f71a8ee7d3ec997cffd14899accc35b1a121be2ea2d6d429293b4ac

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d26b1263fb6d96f5180953938627ad7057445a8623043d748586b1c8c40696a
MD5 1dfb77af74cd0751612aa3f04591ea20
BLAKE2b-256 0656e8cb8ce4a3299e9d03396375606101df865ea07918f049145ac9a01c29b0

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 544787106fcfe9954e6bf18e0dca906dbb47d35446ea6f5d859ff74d7a612d9c
MD5 0badca27d84254ca31608fa111ace373
BLAKE2b-256 cd35aa6d9a21c5bc3d046175418ad4fdf19bc5e90efb4571f5feb24f99f835ad

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 1c83ad6ca3122019212ecd419d42d8ea32c2854b0007881151ad54d4e1c3a584
MD5 2435e20140ab39cf0cc089897e609c1c
BLAKE2b-256 48aa2a48b8c0d4ada372774bc5e2c9ac19c4ef25fef604ab4b0ea852d43b5ea5

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bde1ee3c2b8267fe3faf13bba2318ed7f3a7377d3ac02c45dff43064a07b5ebd
MD5 d49cd4fe4ec85bc89b36f58b2fcdb460
BLAKE2b-256 44c7c4330302530998118364c566c8f6d5ff9d6a6842158579618cc047a9d858

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 295dfc3a03304efdaf338b3b2249499840a258bd5114e0022488ab50377ffbca
MD5 12305eace2713f7521629800a7a7dad2
BLAKE2b-256 ba16e9483c4a0f204fd83010e5182197f9ec3ed533ddca46fba07a5bb5185541

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 de2cd0cf90dd740c86093760384df8c433d003f2cf9c9f173f30e7d9ea85cdb7
MD5 28d38d0732ba0109fc1fbd5510950ad0
BLAKE2b-256 c62cff1d232741433231ef832b749747fb69f21dd33a528e95c8c6c9dd140a4d

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fcd4b2194532de548bff268c66502e5ba55dc6a4856372cd76b28e9b706cdf2
MD5 aa1fd641a74c0ca5b98b58790357a206
BLAKE2b-256 0d75697e696287dc3b245b9d7134538e35ed7272f9c1204df8b9daaa7eb6328e

See more details on using hashes here.

File details

Details for the file bleep-0.5-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for bleep-0.5-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 da14721f3035c14d8732d75880df367cf3a10604cd232cf172a13d557e4d3380
MD5 c8d5cb2c58d22308e0144d21a0aa095a
BLAKE2b-256 252cf8d1bef09511c11d8b13cb00754b3c22ace3a1a70982377a656f1cd2a591

See more details on using hashes here.

Supported by

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