The GATT server example code “example-gatt-server” is in “test” directory.

1

2

$ls bluez-5.43/test/example-gatt-server

bluez-5.43/test/example-gatt-server

2. Install Requisite
2-1. Update package list.

1

sudo apt-get update

2-2. Install python package manager.

1

sudo apt-get install python3-pip-y

2-3. Install dbus.

1

sudo pip3 install pydbus

3. Execute Example Code
3-1. Execute BLE GATT server example code.

1

./bluez-5.43/test/example-gatt-server

3-2. Check the output. If everything is fine, it should be like this:

1

2

3

4

5

6

$./bluez/bluez-5.43/test/example-gatt-server

Registering GATT application...

GetManagedObjects

GATT application registered

Battery Level drained:98

Battery Level drained:96

Now, the GATT server is running. Since the example code implements “Fake Battery service that emulates a draining battery”, it outputs “Battery Level drained” message on the console every 5 seconds.

4. Start Advertising BLE
The next step is to start advertising in order to be detected by other devices. To make the steps easier, I’ll use hciconfig command. If you want to use dbus interface instead of hciconfig, please refer this post to run BLE advertising example code (i.e. example-advertisement).

4-1. Open other terminal and type below to start advertising.

1

sudo hciconfig hci0 leadv0

Type below in case you need to stop the advertisement,

1

sudo hciconfig hci0 noleadv

5. Verify
To verify, you can use smartphone apps. The below image was captured with “BLE Scanner” on iPhone.