1

I am fairly new to the BLE world. Assuming I have a BLE device Eg: A heart rate monitor, How do I interact with that BLE device using C code.

I am able to see the Heart rate data using the command line tool 'bluetoothctl'. If I want connect to the same device through C code and see the Notified data, how do I go about it?

Though some codes on the Internet and GitHub helped me to scan for the device, I do not have any idea on how to connect to the device, read the GATT characteristics of the BLE device. I'd even appreaciate it if anyone points me to the API documentations of BlueZ, I literally have no clue what the programs are all about. Any assistance would be of great help.

Maneesh N
  • 43
  • 6

1 Answers1

2

The preferred API for BlueZ uses the D-Bus bindings. The documentation for those APIs are at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

There are Python examples of how to use the D-Bus API at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test

bluetoothctl is written in C and the source is available at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • Thanks, ukBaz. I still am finding it difficult to connect to the BLE device and perform the read characteristic. any sample code available on how to connect and read / write characterisrics? – Maneesh N Jun 10 '21 at 06:14
  • Even Python is also fine if I'm able to read/write characteristics of a service. – Maneesh N Jun 10 '21 at 07:05
  • 1
    I have a python example at: https://stackoverflow.com/a/63751113/7721752 – ukBaz Jun 10 '21 at 07:21
  • You can have a look into this python library https://pypi.org/project/bleuio/ at_gapconnect() function might be helpful – Shuhad zaman Nov 04 '21 at 12:08