BluezV5.42 DBUS C API for BLE?

2020-06-28 08:28发布

问题:

I have developed BLE application for openwrt using BLUEZV5.30. I was able to create the application by extracting source code gatttool and hcitool. I have also added few more functionality then provided by these tools (like reading rssi).

However, i have upgraded my bluez stack to 5.42 and i am planning to use DBUS interface for all BLE related operations. The functionality i want:

  1. Reading RSSI
  2. Connecting and Disconnecting
  3. Bonding
  4. Pairing
  5. Deleting Bonding information
  6. Discovery
  7. Scanning
  8. Advertising
  9. Write/Reading to Characteristics
  10. Notifications and Indications

I was able to perform all the above operations (except bonding and pairing) using my code written in C++. However, due to some issues with my existing code and inability to pair/bond, i want to migrate to dbus interface. However, i am not sure about the bugs in BLUEZ DBUS API and functionality provided by the APIs. I have read this API Doc but it didn't give any clear picture of DBUS interface.

My question is I am not sure if i can get all of the required functionality with dbus api? I have read the documentation (bluez dbus api) but i am still not sure.

回答1:

As you mention in the other post I updated gattlib to support Bluez DBUS API.
gattlib is written in C. If you do not want to use it looking at its code should help you to progress.

Sinve Bluez v5.42, GATT D-BUS API is not longer mark as experimental.

The DBUS API is described here: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc. There are also (python) examples that demonstrate the API.

  • Reading RSSI
  • Connecting and Disconnecting
  • Pairing
  • Discovery
  • Scanning
  • Advertising
  • Write/Reading to Characteristics
  • Notifications and Indications
  • Bonding and Deleting Bonding information: it looks it is transparent when using DBUS API.