Bluetooth Low Energy¶
Please make sure your Bluetooth device is powered on and ready for use. Follow the Bluetooth wiki page if required.
Simulating BLE devices¶
You can simulate the BLE peripheral by installing and running the
following Android app:
https://play.google.com/store/apps/details?id=io.github.webbluetoothcg.bletestperipheral&hl=en_US&gl=US
The BLE Peripheral Simulator is an Android app that allows developers to try out new features
of Web Bluetooth without the need for a BLE Peripheral Device.
You can check the code at:
https://github.com/WebBluetoothCG/ble-test-peripheral-android

Finding BLE devices¶
Use btmgmt tool to find BLE devices and detect their MAC address type (random vs public).
Discovery started
hci0 type 7 discovering on
hci0 dev_found: 74:B9:AB:CF:13:A9 type LE Random rssi -90 flags 0x0000
AD flags 0x1a
name Galaxy S5
hci0 type 7 discovering off
In this example, a single BLE device was detected with MAC address 74:B9:AB:CF:13:A9 and a random MAC address type.
Connecting to BLE devices¶
Use gatttool to connect to BLE devices. Pass the -t random
parameter if the scan reported a random MAC address.
Attempting to connect to 74:B9:AB:CF:13:A9
[74:B9:AB:CF:13:A9][LE]>
Connection successful
Indication handle = 0x0003 value: 01 00 ff ff
[74:B9:AB:CF:13:A9][LE]>
Accessing BLE devices¶
After a successful connection, BLE device characteristics can be accessed via gatttool. Continuing the example above:
characteristics
char-read-hnd 0x0002
char-read-hnd 0x0015
char-read-hnd 0x0017
char-read-hnd 0x0019
char-read-hnd 0x0029
handle: 0x0002, char properties: 0x20, char value handle: 0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002aa6-0000-1000-8000-00805f9b34fb
handle: 0x0029, char properties: 0x12, char value handle: 0x002a, uuid: 00002a19-0000-1000-8000-00805f9b34fb
Characteristic value/descriptor: 20 03 00 05 2a
Characteristic value/descriptor: 02 16 00 00 2a
Characteristic value/descriptor: 02 18 00 01 2a
Characteristic value/descriptor: 02 1a 00 a6 2a
Characteristic value/descriptor: 12 2a 00 19 2a
Receiving notifications from BLE devices¶
Notifications sent from connected BLE devices can be seen in gatttool. The example below shows a heart rate notification sent by the Android "BLE Peripheral Simulator".
