Skip to content
/ ble Public

Bluetooth Low Energy

Notifications You must be signed in to change notification settings

horace1024/ble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bluetooth Low Energy

BLE Advertiser and Observer classes for Python based on bluez library

Design

These scripts are built for Raspberry Pi but may work on other Linux platforms. Rather than using BluePy, these scripts are based directly on Bluez, the official Linux Bluetooth C libraries. Python calls to the underlying C libraries is achieved through ctypes.

Installation

The following packages should be installed on your system:

sudo apt update
sudo apt install -y bluetooth pi-bluetooth bluez libglib2.0-dev python-dbus python-gobject libbluetooth-dev

Testing

Ideally use two devices such as two Raspberry Pis. Failing that, use one Pi as the Advertiser and use a phone as the Observer. Clone this repo to each pi. Install the requirements above. Then on the advertiser run:

sudo python run_adv.py

and on the observer run:

sudo python run_obs.py

You should see advertisement packets being received on the observer. To log received RSSI values to file, instead of running the observer, use:

sudo python run_range.py

When prompted, enter a distance at which the measurement is being taken. This should be a float to 2dp. Any non-numeric character (except ".") will end the task. The number of collected RSSI data points can be changed by editing the value of numt in this file. Data is saved in the file ./range.csv.

Editing

In run_obs.py you can change the MAC address that will be filtered in the Observer.py class. If you're testing in a busy environment this is useful.

In run_adv.py you can change the interval at which advertisements will be sent. You can also set the name of the device which is attached to the advertisement in a AD Structure with Bluetooth number 0x09.

About

Bluetooth Low Energy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages