Bluetooth Low Energy is all about services and attributes. Exploring these attributes is an interesting way to gain more insight in how a device works and is invaluable for testing. In order to make this process more comfortable a testing tool is invaluable. Hence the BTLE-explorer was born.
BTLE-explorer is a cross-platform tool (OSX and Linux tested, Windows should be easy to add) written in python and using the Bluegiga BGLib interface for accessing Bluetooth Low Energy. The Bluegiga BGLib interface is exposed over USB-Serial (USB CDC) and is used by the tool as a serial device, making the code independent of the native Bluetooth stack of the operating system. This requires a Bluegiga BLE112 based device like the productize BLE112 Test Device or the Bluegiga BLED112 running the Bluegiga BGLib USB CDC stack.
On startup BTLE-Explorer goes into “collect” mode where it just listens for Bluetooth Low Energy advertisements. This allows you to find devices to connect to, or capture data encapsulated into advertisements.
Here the collect mode received an advertisement from two Productize ambient Light Sensor prototypes. The advertisement data contains iBeacon style data. One of the devices seems to be in a dark place 🙂
Let’s try to connect to a device. I’m going to use the cute TI Sensor Tag to demonstrate this. After enabling the device it is promptly discovered.
Double-clicking the device sets up a connection, and promptly does a primary service discovery.
After each service is discovered it automatically retrieves all attributes for all services. This may take a few seconds, which BTLE-explorer will indicate by means of the busy cursor.
Double-clicking on a service shows the associated attributes for the service.
Read an attribute by double-clicking on it, or right-click and select read for the service to read all of them one-by-one.
The temperature is decoded by an attribute specific piece of code. 0.00 seems to be incorrect though. Let’s enable the sensor and read the value again. Right-click on attribute 40 to be able to enable the sensor. An attribute specific dialog is shown.
Let’s enable the sensor and double-click the Sensor Data again.
To be automatically notified of the temperature every second, the sensor supports notification. Enable this by writing the Client Characteristic Configuration and enabling notification, again using an attribute specific dialog.
With notification enabled the temperature field in the Data attribute will be updated every second. This is made visible by the background of the value field changing to green every time the value changes.
This works similarly for the other services, e.g. for the Simple Key service.
Here I am pressing the button 1 on the Sensor Tag, which is notified nicely.
This tool is one of the tools used internally at Productize for working on BTLE enabled devices. If you want to give it a try yourself the full code is available at https://github.com/productize/BTLE-explorer. If you find this tool useful, don’t hesitate to drop me a message!