Working with Bluetooth Low Energy with Python
A BLE abstraction layer for Python inspired by pygattlib. Currently only supports Linux, with experimental support for Mac OS X.
- Discovering devices
- Reading advertising data
- Connecting to devices
- Discovering services, characteristics and descriptors
- Read from characteristics
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.
This python BLE wrapper works with hcitoo and Gatttoolwith the help of subprocess module and can perform operations more reliably.
nRF() is python class, 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 characterstics Read/write responses, allowing you to cherry-pick your devices.
- Creating a log of sensor data
- Performing a analytics on log files.