BlueZ 5.30: D-Bus GATT API - Simply Discover and Connect to a BLE device in C

删除回忆录丶 提交于 2019-12-03 00:38:07
Jorge Martinez

The best way to start with DBUS GATT API is to hace a look at the source code here: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/

Under client folder you can find a full sample of how to use the DBUS GATT API. Actually that is the source of bluetoothctl tool.

Note that DBUS GATT API is still experimental but you can enable it running bluetoothd service with -E flag.

I had a similar issue which is to interact with a BLE device with a GATT C/C++ API.

In my case I had to use Bluez v4.101 - the latest Bluez version available in Ubuntu 14.04 LTS (read my story). In Bluez v4.x, there is no DBus API.
And actually, I have recently worked with Bluez v5 DBus API and I discovered if you do not use at least Bluez v5.39 (from April 2016) it is likely you will have issue with the DBus API. And as said before the DBus API is still experimental.

So to solve my Bluez v4.x dependency I had to pull the GATT source files out from Bluez and create my own library 'gattlib'. The project is Open-Source to encourage feedback and contribution. I am using this library in my own GATT client project. I wrote few examples to help people to start using it see the folder /examples of the project.

EDIT March 2017: I have just added DBus support to gattlib (https://github.com/labapart/gattlib/). From Bluez v5.42, gattlib automatically uses DBus API (DBus gattlib backend can also be forced when building the library to use it before v5.42).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!