With the last release of BlueZ (5.30) the highlight was the completion of the GATT D-Bus apis. My goal is to programmatically (in C), as a BLE client:
- scan for ble devices (which I can do with the hci layer)
- Connect to an advertising BLE device
- Get the UUIDs
- Execute Read and Write to handles
The BlueZ community is strongly suggesting to use the GATT-Dbus api to accomplish this. After multiple searches and head scratching I was not successful to find a proper way or example that would perform this through GATT-DBUs api. It seems more complicate than just use directly the GATT layer. Unfortunately BlueZ removed direct access to make calls to gatt.
I'm very close to just pull the GATT source files out from Bluez, compile it as it's own independent library and directly use the GATT layer and calls to connect and execute reads/writes to ble device server. I know it is not the suggested way compared to the DBUS-GATT api but I'm out of options.
If anybody has any input on this or suggestion (with some sample code) please advise.
thank you in advance!
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.