infsoft-locaware / blzlib

Bluetooth GATT Library for Linux / Bluez
GNU Lesser General Public License v3.0
26 stars 8 forks source link
ble bluetoo bluetooth bluez bluez-dbus gatt linux

blzlib - Bluetooth GATT Library for Linux / Bluez

blzlib is a C library providing an easy interface to acess Bluetooth Low Energy (BLE) Generic Attribute Profile (GATT) Services and Characteristics on Linux. It interfaces with the Bluez Bluetooth daemon on Linux via its D-Bus API. It depends on libsystemd (sd-bus) and is licensed under the LGPLv3.

Currently the following features are supported:

Dependencies

Building

Currently building with meson as well as cmake is supported.

Meson:

meson build
cd build/
ninja

CMake:

mkdir build
cd build
cmake ..
make

Examples

Here is a simple example how to write a characteristic:

blz* blz = blz_init("hci0");
blz_dev* dev = blz_connect(blz, "00:11:22:33:44:55", NULL);
blz_serv* srv = blz_get_serv_from_uuid(dev, "6e400001-b5a3-f393-e0a9-e50e24dcca9e");
blz_char* ch = blz_get_char_from_uuid(srv, "6e400002-b5a3-f393-e0a9-e50e24dcca9e");
blz_char_write(ch, "test", 4);

More real-life examples can be found in the examples/ directory.